From 03011cd215c0c6ec556116c811e537b011ee5ca6 Mon Sep 17 00:00:00 2001 From: hc-github-team-tf-azure <> Date: Mon, 31 Jul 2023 14:32:27 +0000 Subject: [PATCH] Updating based on 756d06b21 --- .../apimanagement/2021-08-01/api/client.go | 22 +- .../apimanagement/2021-08-01/api/constants.go | 84 +- .../2021-08-01/api/method_createorupdate.go | 103 ++ .../api/method_createorupdate_autorest.go | 108 -- .../2021-08-01/api/method_delete.go | 79 ++ .../2021-08-01/api/method_delete_autorest.go | 100 -- .../2021-08-01/api/method_get.go | 51 + .../2021-08-01/api/method_get_autorest.go | 68 -- .../2021-08-01/api/method_getentitytag.go | 46 + .../api/method_getentitytag_autorest.go | 66 -- .../2021-08-01/api/method_listbyservice.go | 133 +++ .../api/method_listbyservice_autorest.go | 235 ----- .../2021-08-01/api/method_update.go | 84 ++ .../2021-08-01/api/method_update_autorest.go | 98 -- .../2021-08-01/apidiagnostic/client.go | 22 +- .../2021-08-01/apidiagnostic/constants.go | 84 +- .../apidiagnostic/method_createorupdate.go | 85 ++ .../method_createorupdate_autorest.go | 98 -- .../2021-08-01/apidiagnostic/method_delete.go | 76 ++ .../apidiagnostic/method_delete_autorest.go | 95 -- .../2021-08-01/apidiagnostic/method_get.go | 51 + .../apidiagnostic/method_get_autorest.go | 68 -- .../apidiagnostic/method_getentitytag.go | 46 + .../method_getentitytag_autorest.go | 66 -- .../apidiagnostic/method_listbyservice.go | 125 +++ .../method_listbyservice_autorest.go | 225 ----- .../2021-08-01/apidiagnostic/method_update.go | 84 ++ .../apidiagnostic/method_update_autorest.go | 98 -- .../2021-08-01/apiissue/client.go | 22 +- .../2021-08-01/apiissue/constants.go | 19 +- .../apiissue/method_createorupdate.go | 85 ++ .../method_createorupdate_autorest.go | 98 -- .../2021-08-01/apiissue/method_delete.go | 76 ++ .../apiissue/method_delete_autorest.go | 95 -- .../2021-08-01/apiissue/method_get.go | 80 ++ .../apiissue/method_get_autorest.go | 97 -- .../apiissue/method_getentitytag.go | 46 + .../apiissue/method_getentitytag_autorest.go | 66 -- .../apiissue/method_listbyservice.go | 129 +++ .../apiissue/method_listbyservice_autorest.go | 230 ----- .../2021-08-01/apiissue/method_update.go | 84 ++ .../apiissue/method_update_autorest.go | 98 -- .../2021-08-01/apiissueattachment/client.go | 22 +- .../method_createorupdate.go | 85 ++ .../method_createorupdate_autorest.go | 98 -- .../apiissueattachment/method_delete.go | 76 ++ .../method_delete_autorest.go | 95 -- .../apiissueattachment/method_get.go | 51 + .../apiissueattachment/method_get_autorest.go | 68 -- .../apiissueattachment/method_getentitytag.go | 46 + .../method_getentitytag_autorest.go | 66 -- .../method_listbyservice.go | 125 +++ .../method_listbyservice_autorest.go | 225 ----- .../2021-08-01/apiissuecomment/client.go | 22 +- .../apiissuecomment/method_createorupdate.go | 85 ++ .../method_createorupdate_autorest.go | 98 -- .../apiissuecomment/method_delete.go | 76 ++ .../apiissuecomment/method_delete_autorest.go | 95 -- .../2021-08-01/apiissuecomment/method_get.go | 51 + .../apiissuecomment/method_get_autorest.go | 68 -- .../apiissuecomment/method_getentitytag.go | 46 + .../method_getentitytag_autorest.go | 66 -- .../apiissuecomment/method_listbyservice.go | 125 +++ .../method_listbyservice_autorest.go | 225 ----- .../2021-08-01/apimanagementservice/client.go | 22 +- .../apimanagementservice/constants.go | 149 ++- ...method_applynetworkconfigurationupdates.go | 74 ++ ...plynetworkconfigurationupdates_autorest.go | 79 -- .../apimanagementservice/method_backup.go | 74 ++ .../method_backup_autorest.go | 79 -- .../method_checknameavailability.go | 57 ++ .../method_checknameavailability_autorest.go | 71 -- .../method_createorupdate.go | 75 ++ .../method_createorupdate_autorest.go | 79 -- .../apimanagementservice/method_delete.go | 71 ++ .../method_delete_autorest.go | 78 -- .../apimanagementservice/method_get.go | 51 + .../method_get_autorest.go | 68 -- .../method_getdomainownershipidentifier.go | 53 + ...d_getdomainownershipidentifier_autorest.go | 70 -- .../method_getssotoken.go | 52 + .../method_getssotoken_autorest.go | 69 -- .../apimanagementservice/method_list.go | 90 ++ .../method_list_autorest.go | 187 ---- .../method_listbyresourcegroup.go | 90 ++ .../method_listbyresourcegroup_autorest.go | 187 ---- .../apimanagementservice/method_restore.go | 74 ++ .../method_restore_autorest.go | 79 -- .../apimanagementservice/method_update.go | 74 ++ .../method_update_autorest.go | 79 -- .../apimanagementserviceskus/client.go | 22 +- .../apimanagementserviceskus/constants.go | 32 +- .../method_listavailableserviceskus.go | 89 ++ ...ethod_listavailableserviceskus_autorest.go | 186 ---- .../2021-08-01/apioperation/client.go | 22 +- .../apioperation/method_createorupdate.go | 85 ++ .../method_createorupdate_autorest.go | 98 -- .../2021-08-01/apioperation/method_delete.go | 76 ++ .../apioperation/method_delete_autorest.go | 95 -- .../2021-08-01/apioperation/method_get.go | 51 + .../apioperation/method_get_autorest.go | 68 -- .../apioperation/method_getentitytag.go | 46 + .../method_getentitytag_autorest.go | 66 -- .../apioperation/method_listbyapi.go | 129 +++ .../apioperation/method_listbyapi_autorest.go | 230 ----- .../2021-08-01/apioperation/method_update.go | 84 ++ .../apioperation/method_update_autorest.go | 98 -- .../2021-08-01/apioperationpolicy/client.go | 22 +- .../apioperationpolicy/constants.go | 32 +- .../method_createorupdate.go | 85 ++ .../method_createorupdate_autorest.go | 99 -- .../apioperationpolicy/method_delete.go | 76 ++ .../method_delete_autorest.go | 96 -- .../apioperationpolicy/method_get.go | 80 ++ .../apioperationpolicy/method_get_autorest.go | 98 -- .../apioperationpolicy/method_getentitytag.go | 47 + .../method_getentitytag_autorest.go | 67 -- .../method_listbyoperation.go | 52 + .../method_listbyoperation_autorest.go | 69 -- .../2021-08-01/apioperationsbytag/client.go | 22 +- .../apioperationsbytag/constants.go | 58 +- .../method_operationlistbytags.go | 129 +++ .../method_operationlistbytags_autorest.go | 230 ----- .../2021-08-01/apioperationtag/client.go | 22 +- .../method_tagassigntooperation.go | 52 + .../method_tagassigntooperation_autorest.go | 68 -- .../method_tagdetachfromoperation.go | 47 + .../method_tagdetachfromoperation_autorest.go | 66 -- .../method_taggetbyoperation.go | 51 + .../method_taggetbyoperation_autorest.go | 68 -- .../method_taggetentitystatebyoperation.go | 46 + ...d_taggetentitystatebyoperation_autorest.go | 66 -- .../method_taglistbyoperation.go | 125 +++ .../method_taglistbyoperation_autorest.go | 225 ----- .../2021-08-01/apipolicy/client.go | 22 +- .../2021-08-01/apipolicy/constants.go | 32 +- .../apipolicy/method_createorupdate.go | 85 ++ .../method_createorupdate_autorest.go | 99 -- .../2021-08-01/apipolicy/method_delete.go | 76 ++ .../apipolicy/method_delete_autorest.go | 96 -- .../2021-08-01/apipolicy/method_get.go | 80 ++ .../apipolicy/method_get_autorest.go | 98 -- .../apipolicy/method_getentitytag.go | 47 + .../apipolicy/method_getentitytag_autorest.go | 67 -- .../2021-08-01/apipolicy/method_listbyapi.go | 52 + .../apipolicy/method_listbyapi_autorest.go | 69 -- .../2021-08-01/apiproduct/client.go | 22 +- .../2021-08-01/apiproduct/constants.go | 19 +- .../apiproduct/method_listbyapis.go | 125 +++ .../apiproduct/method_listbyapis_autorest.go | 225 ----- .../2021-08-01/apirelease/client.go | 22 +- .../apirelease/method_createorupdate.go | 85 ++ .../method_createorupdate_autorest.go | 98 -- .../2021-08-01/apirelease/method_delete.go | 76 ++ .../apirelease/method_delete_autorest.go | 95 -- .../2021-08-01/apirelease/method_get.go | 51 + .../apirelease/method_get_autorest.go | 68 -- .../apirelease/method_getentitytag.go | 46 + .../method_getentitytag_autorest.go | 66 -- .../apirelease/method_listbyservice.go | 125 +++ .../method_listbyservice_autorest.go | 225 ----- .../2021-08-01/apirelease/method_update.go | 84 ++ .../apirelease/method_update_autorest.go | 98 -- .../2021-08-01/apirevision/client.go | 22 +- .../apirevision/method_listbyservice.go | 125 +++ .../method_listbyservice_autorest.go | 225 ----- .../2021-08-01/apisbytag/client.go | 22 +- .../2021-08-01/apisbytag/constants.go | 58 +- .../apisbytag/method_apilistbytags.go | 129 +++ .../method_apilistbytags_autorest.go | 230 ----- .../2021-08-01/apischema/client.go | 22 +- .../apischema/method_createorupdate.go | 103 ++ .../method_createorupdate_autorest.go | 108 -- .../2021-08-01/apischema/method_delete.go | 79 ++ .../apischema/method_delete_autorest.go | 100 -- .../2021-08-01/apischema/method_get.go | 51 + .../apischema/method_get_autorest.go | 68 -- .../apischema/method_getentitytag.go | 46 + .../apischema/method_getentitytag_autorest.go | 66 -- .../2021-08-01/apischema/method_listbyapi.go | 125 +++ .../apischema/method_listbyapi_autorest.go | 225 ----- .../apimanagement/2021-08-01/apitag/client.go | 22 +- .../apitag/method_tagassigntoapi.go | 52 + .../apitag/method_tagassigntoapi_autorest.go | 68 -- .../apitag/method_tagdetachfromapi.go | 47 + .../method_tagdetachfromapi_autorest.go | 66 -- .../2021-08-01/apitag/method_taggetbyapi.go | 51 + .../apitag/method_taggetbyapi_autorest.go | 68 -- .../apitag/method_taggetentitystatebyapi.go | 46 + .../method_taggetentitystatebyapi_autorest.go | 66 -- .../2021-08-01/apitag/method_taglistbyapi.go | 125 +++ .../apitag/method_taglistbyapi_autorest.go | 225 ----- .../2021-08-01/apitagdescription/client.go | 22 +- .../method_createorupdate.go | 85 ++ .../method_createorupdate_autorest.go | 98 -- .../apitagdescription/method_delete.go | 76 ++ .../method_delete_autorest.go | 95 -- .../apitagdescription/method_get.go | 51 + .../apitagdescription/method_get_autorest.go | 68 -- .../apitagdescription/method_getentitytag.go | 46 + .../method_getentitytag_autorest.go | 66 -- .../apitagdescription/method_listbyservice.go | 125 +++ .../method_listbyservice_autorest.go | 225 ----- .../2021-08-01/apiversionset/client.go | 22 +- .../2021-08-01/apiversionset/constants.go | 19 +- .../apiversionset/method_createorupdate.go | 85 ++ .../method_createorupdate_autorest.go | 98 -- .../2021-08-01/apiversionset/method_get.go | 51 + .../apiversionset/method_get_autorest.go | 68 -- .../apiversionset/method_getentitytag.go | 46 + .../method_getentitytag_autorest.go | 66 -- .../apiversionset/method_listbyservice.go | 125 +++ .../method_listbyservice_autorest.go | 225 ----- .../2021-08-01/apiversionset/method_update.go | 84 ++ .../apiversionset/method_update_autorest.go | 98 -- .../2021-08-01/apiversionsets/client.go | 22 +- .../method_apiversionsetdelete.go | 76 ++ .../method_apiversionsetdelete_autorest.go | 95 -- .../2021-08-01/authorizationserver/client.go | 22 +- .../authorizationserver/constants.go | 58 +- .../method_createorupdate.go | 85 ++ .../method_createorupdate_autorest.go | 98 -- .../authorizationserver/method_delete.go | 76 ++ .../method_delete_autorest.go | 95 -- .../authorizationserver/method_get.go | 51 + .../method_get_autorest.go | 68 -- .../method_getentitytag.go | 46 + .../method_getentitytag_autorest.go | 66 -- .../method_listbyservice.go | 125 +++ .../method_listbyservice_autorest.go | 225 ----- .../authorizationserver/method_listsecrets.go | 52 + .../method_listsecrets_autorest.go | 69 -- .../authorizationserver/method_update.go | 84 ++ .../method_update_autorest.go | 98 -- .../2021-08-01/backend/client.go | 22 +- .../2021-08-01/backend/constants.go | 19 +- .../backend/method_createorupdate.go | 85 ++ .../backend/method_createorupdate_autorest.go | 98 -- .../2021-08-01/backend/method_delete.go | 76 ++ .../backend/method_delete_autorest.go | 95 -- .../2021-08-01/backend/method_get.go | 51 + .../2021-08-01/backend/method_get_autorest.go | 68 -- .../2021-08-01/backend/method_getentitytag.go | 46 + .../backend/method_getentitytag_autorest.go | 66 -- .../backend/method_listbyservice.go | 125 +++ .../backend/method_listbyservice_autorest.go | 225 ----- .../2021-08-01/backend/method_update.go | 84 ++ .../backend/method_update_autorest.go | 98 -- .../2021-08-01/backendreconnect/client.go | 22 +- .../method_backendreconnect.go | 51 + .../method_backendreconnect_autorest.go | 68 -- .../apimanagement/2021-08-01/cache/client.go | 22 +- .../2021-08-01/cache/method_createorupdate.go | 85 ++ .../cache/method_createorupdate_autorest.go | 98 -- .../2021-08-01/cache/method_delete.go | 76 ++ .../cache/method_delete_autorest.go | 95 -- .../2021-08-01/cache/method_get.go | 51 + .../2021-08-01/cache/method_get_autorest.go | 68 -- .../2021-08-01/cache/method_getentitytag.go | 46 + .../cache/method_getentitytag_autorest.go | 66 -- .../2021-08-01/cache/method_listbyservice.go | 121 +++ .../cache/method_listbyservice_autorest.go | 220 ---- .../2021-08-01/cache/method_update.go | 84 ++ .../cache/method_update_autorest.go | 98 -- .../2021-08-01/certificate/client.go | 22 +- .../certificate/method_createorupdate.go | 85 ++ .../method_createorupdate_autorest.go | 98 -- .../2021-08-01/certificate/method_delete.go | 76 ++ .../certificate/method_delete_autorest.go | 95 -- .../2021-08-01/certificate/method_get.go | 51 + .../certificate/method_get_autorest.go | 68 -- .../certificate/method_getentitytag.go | 46 + .../method_getentitytag_autorest.go | 66 -- .../certificate/method_listbyservice.go | 129 +++ .../method_listbyservice_autorest.go | 230 ----- .../certificate/method_refreshsecret.go | 52 + .../method_refreshsecret_autorest.go | 69 -- .../apimanagement/2021-08-01/client.go | 832 +++++++++------ .../2021-08-01/contenttype/client.go | 22 +- .../contenttype/method_createorupdate.go | 85 ++ .../method_createorupdate_autorest.go | 98 -- .../2021-08-01/contenttype/method_delete.go | 76 ++ .../contenttype/method_delete_autorest.go | 95 -- .../2021-08-01/contenttype/method_get.go | 51 + .../contenttype/method_get_autorest.go | 68 -- .../contenttype/method_listbyservice.go | 89 ++ .../method_listbyservice_autorest.go | 186 ---- .../contenttypecontentitem/client.go | 22 +- .../method_contentitemcreateorupdate.go | 85 ++ ...thod_contentitemcreateorupdate_autorest.go | 98 -- .../method_contentitemdelete.go | 76 ++ .../method_contentitemdelete_autorest.go | 95 -- .../method_contentitemget.go | 51 + .../method_contentitemget_autorest.go | 68 -- .../method_contentitemgetentitytag.go | 46 + ...method_contentitemgetentitytag_autorest.go | 66 -- .../method_contentitemlistbyservice.go | 89 ++ ...ethod_contentitemlistbyservice_autorest.go | 186 ---- .../2021-08-01/delegationsettings/client.go | 22 +- .../method_createorupdate.go | 84 ++ .../method_createorupdate_autorest.go | 99 -- .../delegationsettings/method_get.go | 52 + .../delegationsettings/method_get_autorest.go | 69 -- .../delegationsettings/method_getentitytag.go | 47 + .../method_getentitytag_autorest.go | 67 -- .../delegationsettings/method_listsecrets.go | 52 + .../method_listsecrets_autorest.go | 69 -- .../delegationsettings/method_update.go | 79 ++ .../method_update_autorest.go | 97 -- .../2021-08-01/deletedservice/client.go | 22 +- .../deletedservice/method_getbyname.go | 51 + .../method_getbyname_autorest.go | 68 -- .../method_listbysubscription.go | 90 ++ .../method_listbysubscription_autorest.go | 187 ---- .../2021-08-01/deletedservice/method_purge.go | 71 ++ .../deletedservice/method_purge_autorest.go | 78 -- .../2021-08-01/diagnostic/client.go | 22 +- .../2021-08-01/diagnostic/constants.go | 84 +- .../diagnostic/method_createorupdate.go | 85 ++ .../method_createorupdate_autorest.go | 98 -- .../2021-08-01/diagnostic/method_delete.go | 76 ++ .../diagnostic/method_delete_autorest.go | 95 -- .../2021-08-01/diagnostic/method_get.go | 51 + .../diagnostic/method_get_autorest.go | 68 -- .../diagnostic/method_getentitytag.go | 46 + .../method_getentitytag_autorest.go | 66 -- .../diagnostic/method_listbyservice.go | 125 +++ .../method_listbyservice_autorest.go | 225 ----- .../2021-08-01/diagnostic/method_update.go | 84 ++ .../diagnostic/method_update_autorest.go | 98 -- .../2021-08-01/emailtemplate/client.go | 22 +- .../emailtemplate/method_listbyservice.go | 125 +++ .../method_listbyservice_autorest.go | 225 ----- .../2021-08-01/emailtemplates/client.go | 22 +- .../2021-08-01/emailtemplates/constants.go | 19 +- .../method_emailtemplatecreateorupdate.go | 85 ++ ...od_emailtemplatecreateorupdate_autorest.go | 98 -- .../method_emailtemplatedelete.go | 76 ++ .../method_emailtemplatedelete_autorest.go | 95 -- .../emailtemplates/method_emailtemplateget.go | 51 + .../method_emailtemplateget_autorest.go | 68 -- .../method_emailtemplategetentitytag.go | 46 + ...thod_emailtemplategetentitytag_autorest.go | 66 -- .../method_emailtemplateupdate.go | 84 ++ .../method_emailtemplateupdate_autorest.go | 98 -- .../2021-08-01/gateway/client.go | 22 +- .../gateway/method_createorupdate.go | 85 ++ .../gateway/method_createorupdate_autorest.go | 98 -- .../2021-08-01/gateway/method_delete.go | 76 ++ .../gateway/method_delete_autorest.go | 95 -- .../2021-08-01/gateway/method_get.go | 51 + .../2021-08-01/gateway/method_get_autorest.go | 68 -- .../2021-08-01/gateway/method_getentitytag.go | 46 + .../gateway/method_getentitytag_autorest.go | 66 -- .../gateway/method_listbyservice.go | 125 +++ .../gateway/method_listbyservice_autorest.go | 225 ----- .../2021-08-01/gateway/method_update.go | 84 ++ .../gateway/method_update_autorest.go | 98 -- .../2021-08-01/gatewayapi/client.go | 22 +- .../2021-08-01/gatewayapi/constants.go | 71 +- .../gatewayapi/method_createorupdate.go | 56 ++ .../method_createorupdate_autorest.go | 69 -- .../2021-08-01/gatewayapi/method_delete.go | 47 + .../gatewayapi/method_delete_autorest.go | 66 -- .../gatewayapi/method_getentitytag.go | 46 + .../method_getentitytag_autorest.go | 66 -- .../gatewayapi/method_listbyservice.go | 125 +++ .../method_listbyservice_autorest.go | 225 ----- .../gatewaycertificateauthority/client.go | 22 +- .../method_createorupdate.go | 85 ++ .../method_createorupdate_autorest.go | 98 -- .../method_delete.go | 76 ++ .../method_delete_autorest.go | 95 -- .../gatewaycertificateauthority/method_get.go | 51 + .../method_get_autorest.go | 68 -- .../method_getentitytag.go | 46 + .../method_getentitytag_autorest.go | 66 -- .../method_listbyservice.go | 125 +++ .../method_listbyservice_autorest.go | 225 ----- .../2021-08-01/gatewaygeneratetoken/client.go | 22 +- .../gatewaygeneratetoken/constants.go | 19 +- .../method_gatewaygeneratetoken.go | 56 ++ .../method_gatewaygeneratetoken_autorest.go | 70 -- .../gatewayhostnameconfiguration/client.go | 22 +- .../method_createorupdate.go | 85 ++ .../method_createorupdate_autorest.go | 98 -- .../method_delete.go | 76 ++ .../method_delete_autorest.go | 95 -- .../method_get.go | 51 + .../method_get_autorest.go | 68 -- .../method_getentitytag.go | 46 + .../method_getentitytag_autorest.go | 66 -- .../method_listbyservice.go | 125 +++ .../method_listbyservice_autorest.go | 225 ----- .../2021-08-01/gatewaylistkeys/client.go | 22 +- .../gatewaylistkeys/method_gatewaylistkeys.go | 52 + .../method_gatewaylistkeys_autorest.go | 69 -- .../2021-08-01/gatewayregeneratekey/client.go | 22 +- .../gatewayregeneratekey/constants.go | 19 +- .../method_gatewayregeneratekey.go | 51 + .../method_gatewayregeneratekey_autorest.go | 68 -- .../apimanagement/2021-08-01/group/client.go | 22 +- .../2021-08-01/group/constants.go | 19 +- .../2021-08-01/group/method_createorupdate.go | 85 ++ .../group/method_createorupdate_autorest.go | 98 -- .../2021-08-01/group/method_delete.go | 76 ++ .../group/method_delete_autorest.go | 95 -- .../2021-08-01/group/method_get.go | 51 + .../2021-08-01/group/method_get_autorest.go | 68 -- .../2021-08-01/group/method_getentitytag.go | 46 + .../group/method_getentitytag_autorest.go | 66 -- .../2021-08-01/group/method_listbyservice.go | 125 +++ .../group/method_listbyservice_autorest.go | 225 ----- .../2021-08-01/group/method_update.go | 84 ++ .../group/method_update_autorest.go | 98 -- .../2021-08-01/groupuser/client.go | 22 +- .../2021-08-01/groupuser/constants.go | 32 +- .../groupuser/method_checkentityexists.go | 46 + .../method_checkentityexists_autorest.go | 66 -- .../2021-08-01/groupuser/method_create.go | 52 + .../groupuser/method_create_autorest.go | 68 -- .../2021-08-01/groupuser/method_delete.go | 47 + .../groupuser/method_delete_autorest.go | 66 -- .../2021-08-01/groupuser/method_list.go | 125 +++ .../groupuser/method_list_autorest.go | 225 ----- .../2021-08-01/identityprovider/client.go | 22 +- .../2021-08-01/identityprovider/constants.go | 19 +- .../identityprovider/method_createorupdate.go | 85 ++ .../method_createorupdate_autorest.go | 98 -- .../identityprovider/method_delete.go | 76 ++ .../method_delete_autorest.go | 95 -- .../2021-08-01/identityprovider/method_get.go | 51 + .../identityprovider/method_get_autorest.go | 68 -- .../identityprovider/method_getentitytag.go | 46 + .../method_getentitytag_autorest.go | 66 -- .../identityprovider/method_listbyservice.go | 89 ++ .../method_listbyservice_autorest.go | 186 ---- .../identityprovider/method_listsecrets.go | 52 + .../method_listsecrets_autorest.go | 69 -- .../identityprovider/method_update.go | 84 ++ .../method_update_autorest.go | 98 -- .../apimanagement/2021-08-01/issue/client.go | 22 +- .../2021-08-01/issue/constants.go | 19 +- .../2021-08-01/issue/method_get.go | 51 + .../2021-08-01/issue/method_get_autorest.go | 68 -- .../2021-08-01/issue/method_listbyservice.go | 125 +++ .../issue/method_listbyservice_autorest.go | 225 ----- .../apimanagement/2021-08-01/logger/client.go | 22 +- .../2021-08-01/logger/constants.go | 19 +- .../logger/method_createorupdate.go | 85 ++ .../logger/method_createorupdate_autorest.go | 98 -- .../2021-08-01/logger/method_delete.go | 76 ++ .../logger/method_delete_autorest.go | 95 -- .../2021-08-01/logger/method_get.go | 51 + .../2021-08-01/logger/method_get_autorest.go | 68 -- .../2021-08-01/logger/method_getentitytag.go | 46 + .../logger/method_getentitytag_autorest.go | 66 -- .../2021-08-01/logger/method_listbyservice.go | 125 +++ .../logger/method_listbyservice_autorest.go | 225 ----- .../2021-08-01/logger/method_update.go | 84 ++ .../logger/method_update_autorest.go | 98 -- .../2021-08-01/namedvalue/client.go | 22 +- .../namedvalue/method_createorupdate.go | 103 ++ .../method_createorupdate_autorest.go | 108 -- .../2021-08-01/namedvalue/method_delete.go | 76 ++ .../namedvalue/method_delete_autorest.go | 95 -- .../2021-08-01/namedvalue/method_get.go | 51 + .../namedvalue/method_get_autorest.go | 68 -- .../namedvalue/method_getentitytag.go | 46 + .../method_getentitytag_autorest.go | 66 -- .../namedvalue/method_listbyservice.go | 129 +++ .../method_listbyservice_autorest.go | 230 ----- .../2021-08-01/namedvalue/method_listvalue.go | 52 + .../namedvalue/method_listvalue_autorest.go | 69 -- .../namedvalue/method_refreshsecret.go | 70 ++ .../method_refreshsecret_autorest.go | 78 -- .../2021-08-01/namedvalue/method_update.go | 102 ++ .../namedvalue/method_update_autorest.go | 108 -- .../2021-08-01/networkstatus/client.go | 22 +- .../2021-08-01/networkstatus/constants.go | 19 +- .../networkstatus/method_listbylocation.go | 52 + .../method_listbylocation_autorest.go | 69 -- .../networkstatus/method_listbyservice.go | 52 + .../method_listbyservice_autorest.go | 69 -- .../2021-08-01/notification/client.go | 22 +- .../2021-08-01/notification/constants.go | 19 +- .../notification/method_createorupdate.go | 80 ++ .../method_createorupdate_autorest.go | 97 -- .../2021-08-01/notification/method_get.go | 51 + .../notification/method_get_autorest.go | 68 -- .../notification/method_listbyservice.go | 121 +++ .../method_listbyservice_autorest.go | 220 ---- .../notificationrecipientemail/client.go | 22 +- .../notificationrecipientemail/constants.go | 19 +- .../method_checkentityexists.go | 46 + .../method_checkentityexists_autorest.go | 66 -- .../method_createorupdate.go | 52 + .../method_createorupdate_autorest.go | 68 -- .../method_delete.go | 47 + .../method_delete_autorest.go | 66 -- .../method_listbynotification.go | 52 + .../method_listbynotification_autorest.go | 69 -- .../notificationrecipientuser/client.go | 22 +- .../notificationrecipientuser/constants.go | 19 +- .../method_checkentityexists.go | 46 + .../method_checkentityexists_autorest.go | 66 -- .../method_createorupdate.go | 52 + .../method_createorupdate_autorest.go | 68 -- .../method_delete.go | 47 + .../method_delete_autorest.go | 66 -- .../method_listbynotification.go | 52 + .../method_listbynotification_autorest.go | 69 -- .../openidconnectprovider/client.go | 22 +- .../method_createorupdate.go | 85 ++ .../method_createorupdate_autorest.go | 98 -- .../openidconnectprovider/method_delete.go | 76 ++ .../method_delete_autorest.go | 95 -- .../openidconnectprovider/method_get.go | 51 + .../method_get_autorest.go | 68 -- .../method_getentitytag.go | 46 + .../method_getentitytag_autorest.go | 66 -- .../method_listbyservice.go | 125 +++ .../method_listbyservice_autorest.go | 225 ----- .../method_listsecrets.go | 52 + .../method_listsecrets_autorest.go | 69 -- .../openidconnectprovider/method_update.go | 84 ++ .../method_update_autorest.go | 98 -- .../client.go | 22 +- .../method_listbyservice.go | 52 + .../method_listbyservice_autorest.go | 69 -- .../performconnectivitycheck/client.go | 22 +- .../performconnectivitycheck/constants.go | 97 +- .../performconnectivitycheck/method_async.go | 74 ++ .../method_async_autorest.go | 79 -- .../apimanagement/2021-08-01/policy/client.go | 22 +- .../2021-08-01/policy/constants.go | 32 +- .../policy/method_createorupdate.go | 85 ++ .../policy/method_createorupdate_autorest.go | 99 -- .../2021-08-01/policy/method_delete.go | 76 ++ .../policy/method_delete_autorest.go | 96 -- .../2021-08-01/policy/method_get.go | 80 ++ .../2021-08-01/policy/method_get_autorest.go | 98 -- .../2021-08-01/policy/method_getentitytag.go | 47 + .../policy/method_getentitytag_autorest.go | 67 -- .../2021-08-01/policy/method_listbyservice.go | 52 + .../policy/method_listbyservice_autorest.go | 69 -- .../2021-08-01/policydescription/client.go | 22 +- .../2021-08-01/policydescription/constants.go | 19 +- .../policydescription/method_listbyservice.go | 80 ++ .../method_listbyservice_autorest.go | 98 -- .../2021-08-01/portalrevision/client.go | 22 +- .../2021-08-01/portalrevision/constants.go | 19 +- .../portalrevision/method_createorupdate.go | 74 ++ .../method_createorupdate_autorest.go | 79 -- .../2021-08-01/portalrevision/method_get.go | 51 + .../portalrevision/method_get_autorest.go | 68 -- .../portalrevision/method_getentitytag.go | 46 + .../method_getentitytag_autorest.go | 66 -- .../portalrevision/method_listbyservice.go | 125 +++ .../method_listbyservice_autorest.go | 225 ----- .../portalrevision/method_update.go | 102 ++ .../portalrevision/method_update_autorest.go | 108 -- .../2021-08-01/portalsettings/client.go | 22 +- .../portalsettings/method_listbyservice.go | 52 + .../method_listbyservice_autorest.go | 69 -- .../privateendpointconnections/client.go | 22 +- .../privateendpointconnections/constants.go | 32 +- ...privateendpointconnectioncreateorupdate.go | 74 ++ ...dpointconnectioncreateorupdate_autorest.go | 79 -- .../method_privateendpointconnectiondelete.go | 71 ++ ...rivateendpointconnectiondelete_autorest.go | 78 -- ...thod_privateendpointconnectiongetbyname.go | 51 + ...ateendpointconnectiongetbyname_autorest.go | 68 -- ...ndpointconnectiongetprivatelinkresource.go | 51 + ...nnectiongetprivatelinkresource_autorest.go | 68 -- ..._privateendpointconnectionlistbyservice.go | 52 + ...ndpointconnectionlistbyservice_autorest.go | 69 -- ...pointconnectionlistprivatelinkresources.go | 52 + ...ectionlistprivatelinkresources_autorest.go | 69 -- .../2021-08-01/product/client.go | 22 +- .../2021-08-01/product/constants.go | 19 +- .../product/method_createorupdate.go | 85 ++ .../product/method_createorupdate_autorest.go | 98 -- .../2021-08-01/product/method_delete.go | 79 ++ .../product/method_delete_autorest.go | 100 -- .../2021-08-01/product/method_get.go | 51 + .../2021-08-01/product/method_get_autorest.go | 68 -- .../2021-08-01/product/method_getentitytag.go | 46 + .../product/method_getentitytag_autorest.go | 66 -- .../product/method_listbyservice.go | 133 +++ .../product/method_listbyservice_autorest.go | 235 ----- .../2021-08-01/product/method_update.go | 84 ++ .../product/method_update_autorest.go | 98 -- .../2021-08-01/productapi/client.go | 22 +- .../2021-08-01/productapi/constants.go | 58 +- .../productapi/method_checkentityexists.go | 46 + .../method_checkentityexists_autorest.go | 66 -- .../productapi/method_createorupdate.go | 52 + .../method_createorupdate_autorest.go | 68 -- .../2021-08-01/productapi/method_delete.go | 47 + .../productapi/method_delete_autorest.go | 66 -- .../productapi/method_listbyproduct.go | 125 +++ .../method_listbyproduct_autorest.go | 225 ----- .../2021-08-01/productgroup/client.go | 22 +- .../2021-08-01/productgroup/constants.go | 19 +- .../productgroup/method_checkentityexists.go | 46 + .../method_checkentityexists_autorest.go | 66 -- .../productgroup/method_createorupdate.go | 52 + .../method_createorupdate_autorest.go | 68 -- .../2021-08-01/productgroup/method_delete.go | 47 + .../productgroup/method_delete_autorest.go | 66 -- .../productgroup/method_listbyproduct.go | 125 +++ .../method_listbyproduct_autorest.go | 225 ----- .../2021-08-01/productpolicy/client.go | 22 +- .../2021-08-01/productpolicy/constants.go | 32 +- .../productpolicy/method_createorupdate.go | 85 ++ .../method_createorupdate_autorest.go | 99 -- .../2021-08-01/productpolicy/method_delete.go | 76 ++ .../productpolicy/method_delete_autorest.go | 96 -- .../2021-08-01/productpolicy/method_get.go | 80 ++ .../productpolicy/method_get_autorest.go | 98 -- .../productpolicy/method_getentitytag.go | 47 + .../method_getentitytag_autorest.go | 67 -- .../productpolicy/method_listbyproduct.go | 52 + .../method_listbyproduct_autorest.go | 69 -- .../2021-08-01/productsbytag/client.go | 22 +- .../2021-08-01/productsbytag/constants.go | 58 +- .../productsbytag/method_productlistbytags.go | 129 +++ .../method_productlistbytags_autorest.go | 230 ----- .../2021-08-01/productsubscription/client.go | 22 +- .../productsubscription/constants.go | 19 +- .../productsubscription/method_list.go | 125 +++ .../method_list_autorest.go | 225 ----- .../2021-08-01/producttag/client.go | 22 +- .../producttag/method_tagassigntoproduct.go | 52 + .../method_tagassigntoproduct_autorest.go | 68 -- .../producttag/method_tagdetachfromproduct.go | 47 + .../method_tagdetachfromproduct_autorest.go | 66 -- .../producttag/method_taggetbyproduct.go | 51 + .../method_taggetbyproduct_autorest.go | 68 -- .../method_taggetentitystatebyproduct.go | 46 + ...hod_taggetentitystatebyproduct_autorest.go | 66 -- .../producttag/method_taglistbyproduct.go | 125 +++ .../method_taglistbyproduct_autorest.go | 225 ----- .../2021-08-01/quotabycounterkeys/client.go | 22 +- .../method_listbyservice.go | 51 + .../method_listbyservice_autorest.go | 68 -- .../quotabycounterkeys/method_update.go | 55 + .../method_update_autorest.go | 69 -- .../2021-08-01/quotabyperiodkeys/client.go | 22 +- .../quotabyperiodkeys/method_get.go | 51 + .../quotabyperiodkeys/method_get_autorest.go | 68 -- .../quotabyperiodkeys/method_update.go | 55 + .../method_update_autorest.go | 69 -- .../apimanagement/2021-08-01/region/client.go | 22 +- .../2021-08-01/region/method_listbyservice.go | 89 ++ .../region/method_listbyservice_autorest.go | 186 ---- .../2021-08-01/reports/client.go | 22 +- .../2021-08-01/reports/method_listbyapi.go | 129 +++ .../reports/method_listbyapi_autorest.go | 230 ----- .../2021-08-01/reports/method_listbygeo.go | 125 +++ .../reports/method_listbygeo_autorest.go | 225 ----- .../reports/method_listbyoperation.go | 129 +++ .../method_listbyoperation_autorest.go | 230 ----- .../reports/method_listbyproduct.go | 129 +++ .../reports/method_listbyproduct_autorest.go | 230 ----- .../reports/method_listbyrequest.go | 88 ++ .../reports/method_listbyrequest_autorest.go | 108 -- .../reports/method_listbysubscription.go | 129 +++ .../method_listbysubscription_autorest.go | 230 ----- .../2021-08-01/reports/method_listbytime.go | 133 +++ .../reports/method_listbytime_autorest.go | 235 ----- .../2021-08-01/reports/method_listbyuser.go | 129 +++ .../reports/method_listbyuser_autorest.go | 230 ----- .../apimanagement/2021-08-01/schema/client.go | 22 +- .../2021-08-01/schema/constants.go | 19 +- .../method_globalschemacreateorupdate.go | 103 ++ ...hod_globalschemacreateorupdate_autorest.go | 108 -- .../schema/method_globalschemadelete.go | 76 ++ .../method_globalschemadelete_autorest.go | 95 -- .../schema/method_globalschemaget.go | 51 + .../schema/method_globalschemaget_autorest.go | 68 -- .../schema/method_globalschemagetentitytag.go | 46 + ...ethod_globalschemagetentitytag_autorest.go | 66 -- .../method_globalschemalistbyservice.go | 125 +++ ...thod_globalschemalistbyservice_autorest.go | 225 ----- .../2021-08-01/signinsettings/client.go | 22 +- .../signinsettings/method_createorupdate.go | 84 ++ .../method_createorupdate_autorest.go | 99 -- .../2021-08-01/signinsettings/method_get.go | 52 + .../signinsettings/method_get_autorest.go | 69 -- .../signinsettings/method_getentitytag.go | 47 + .../method_getentitytag_autorest.go | 67 -- .../signinsettings/method_update.go | 79 ++ .../signinsettings/method_update_autorest.go | 97 -- .../2021-08-01/signupsettings/client.go | 22 +- .../signupsettings/method_createorupdate.go | 84 ++ .../method_createorupdate_autorest.go | 99 -- .../2021-08-01/signupsettings/method_get.go | 52 + .../signupsettings/method_get_autorest.go | 69 -- .../signupsettings/method_getentitytag.go | 47 + .../method_getentitytag_autorest.go | 67 -- .../signupsettings/method_update.go | 79 ++ .../signupsettings/method_update_autorest.go | 97 -- .../apimanagement/2021-08-01/skus/client.go | 22 +- .../2021-08-01/skus/constants.go | 45 +- .../skus/method_apimanagementskuslist.go | 90 ++ .../method_apimanagementskuslist_autorest.go | 187 ---- .../2021-08-01/subscription/client.go | 22 +- .../2021-08-01/subscription/constants.go | 32 +- .../subscription/method_createorupdate.go | 92 ++ .../method_createorupdate_autorest.go | 108 -- .../2021-08-01/subscription/method_delete.go | 76 ++ .../subscription/method_delete_autorest.go | 95 -- .../2021-08-01/subscription/method_get.go | 51 + .../subscription/method_get_autorest.go | 68 -- .../subscription/method_getentitytag.go | 46 + .../method_getentitytag_autorest.go | 66 -- .../2021-08-01/subscription/method_list.go | 125 +++ .../subscription/method_list_autorest.go | 225 ----- .../subscription/method_listsecrets.go | 52 + .../method_listsecrets_autorest.go | 69 -- .../method_regenerateprimarykey.go | 47 + .../method_regenerateprimarykey_autorest.go | 67 -- .../method_regeneratesecondarykey.go | 47 + .../method_regeneratesecondarykey_autorest.go | 67 -- .../2021-08-01/subscription/method_update.go | 91 ++ .../subscription/method_update_autorest.go | 108 -- .../method_usersubscriptionget.go | 51 + .../method_usersubscriptionget_autorest.go | 68 -- .../apimanagement/2021-08-01/tag/client.go | 22 +- .../2021-08-01/tag/method_createorupdate.go | 85 ++ .../tag/method_createorupdate_autorest.go | 98 -- .../2021-08-01/tag/method_delete.go | 76 ++ .../2021-08-01/tag/method_delete_autorest.go | 95 -- .../2021-08-01/tag/method_get.go | 51 + .../2021-08-01/tag/method_get_autorest.go | 68 -- .../2021-08-01/tag/method_getentitystate.go | 46 + .../tag/method_getentitystate_autorest.go | 66 -- .../2021-08-01/tag/method_listbyservice.go | 129 +++ .../tag/method_listbyservice_autorest.go | 230 ----- .../2021-08-01/tag/method_update.go | 84 ++ .../2021-08-01/tag/method_update_autorest.go | 98 -- .../2021-08-01/tagresource/client.go | 22 +- .../2021-08-01/tagresource/constants.go | 58 +- .../tagresource/method_listbyservice.go | 125 +++ .../method_listbyservice_autorest.go | 225 ----- .../2021-08-01/tenantaccess/client.go | 22 +- .../2021-08-01/tenantaccess/constants.go | 19 +- .../2021-08-01/tenantaccess/method_create.go | 84 ++ .../tenantaccess/method_create_autorest.go | 98 -- .../2021-08-01/tenantaccess/method_get.go | 51 + .../tenantaccess/method_get_autorest.go | 68 -- .../tenantaccess/method_getentitytag.go | 46 + .../method_getentitytag_autorest.go | 66 -- .../tenantaccess/method_listbyservice.go | 117 +++ .../method_listbyservice_autorest.go | 215 ---- .../tenantaccess/method_listsecrets.go | 52 + .../method_listsecrets_autorest.go | 69 -- .../method_regenerateprimarykey.go | 47 + .../method_regenerateprimarykey_autorest.go | 67 -- .../method_regeneratesecondarykey.go | 47 + .../method_regeneratesecondarykey_autorest.go | 67 -- .../2021-08-01/tenantaccess/method_update.go | 84 ++ .../tenantaccess/method_update_autorest.go | 98 -- .../2021-08-01/tenantaccessgit/client.go | 22 +- .../2021-08-01/tenantaccessgit/constants.go | 19 +- .../method_regenerateprimarykey.go | 47 + .../method_regenerateprimarykey_autorest.go | 67 -- .../method_regeneratesecondarykey.go | 47 + .../method_regeneratesecondarykey_autorest.go | 67 -- .../2021-08-01/tenantconfiguration/client.go | 22 +- .../tenantconfiguration/constants.go | 19 +- .../tenantconfiguration/method_deploy.go | 74 ++ .../method_deploy_autorest.go | 79 -- .../tenantconfiguration/method_save.go | 74 ++ .../method_save_autorest.go | 79 -- .../tenantconfiguration/method_validate.go | 74 ++ .../method_validate_autorest.go | 79 -- .../tenantconfigurationsyncstate/client.go | 22 +- .../method_tenantconfigurationgetsyncstate.go | 52 + ...enantconfigurationgetsyncstate_autorest.go | 69 -- .../2021-08-01/tenantsettings/client.go | 22 +- .../2021-08-01/tenantsettings/method_get.go | 52 + .../tenantsettings/method_get_autorest.go | 69 -- .../tenantsettings/method_listbyservice.go | 117 +++ .../method_listbyservice_autorest.go | 215 ---- .../apimanagement/2021-08-01/user/client.go | 22 +- .../2021-08-01/user/constants.go | 58 +- .../2021-08-01/user/method_createorupdate.go | 88 ++ .../user/method_createorupdate_autorest.go | 103 -- .../2021-08-01/user/method_delete.go | 87 ++ .../2021-08-01/user/method_delete_autorest.go | 110 -- .../2021-08-01/user/method_get.go | 51 + .../2021-08-01/user/method_get_autorest.go | 68 -- .../2021-08-01/user/method_getentitytag.go | 46 + .../user/method_getentitytag_autorest.go | 66 -- .../2021-08-01/user/method_listbyservice.go | 129 +++ .../user/method_listbyservice_autorest.go | 230 ----- .../2021-08-01/user/method_update.go | 84 ++ .../2021-08-01/user/method_update_autorest.go | 98 -- .../userconfirmationpasswordsend/client.go | 22 +- .../userconfirmationpasswordsend/constants.go | 19 +- .../method_userconfirmationpasswordsend.go | 75 ++ ...d_userconfirmationpasswordsend_autorest.go | 96 -- .../2021-08-01/usergroup/client.go | 22 +- .../2021-08-01/usergroup/constants.go | 19 +- .../2021-08-01/usergroup/method_list.go | 125 +++ .../usergroup/method_list_autorest.go | 225 ----- .../2021-08-01/useridentity/client.go | 22 +- .../useridentity/method_useridentitieslist.go | 89 ++ .../method_useridentitieslist_autorest.go | 186 ---- .../apimanagement/2021-08-01/users/client.go | 22 +- .../users/method_usergeneratessourl.go | 52 + .../method_usergeneratessourl_autorest.go | 69 -- .../2021-08-01/usersubscription/client.go | 22 +- .../2021-08-01/usersubscription/constants.go | 19 +- .../usersubscription/method_list.go | 125 +++ .../usersubscription/method_list_autorest.go | 225 ----- .../2021-08-01/usertoken/client.go | 22 +- .../2021-08-01/usertoken/constants.go | 19 +- .../method_usergetsharedaccesstoken.go | 56 ++ ...ethod_usergetsharedaccesstoken_autorest.go | 70 -- .../apimanagement/2022-08-01/api/client.go | 22 +- .../apimanagement/2022-08-01/api/constants.go | 97 +- .../2022-08-01/api/method_createorupdate.go | 103 ++ .../api/method_createorupdate_autorest.go | 108 -- .../2022-08-01/api/method_delete.go | 79 ++ .../2022-08-01/api/method_delete_autorest.go | 100 -- .../2022-08-01/api/method_get.go | 51 + .../2022-08-01/api/method_get_autorest.go | 68 -- .../2022-08-01/api/method_getentitytag.go | 46 + .../api/method_getentitytag_autorest.go | 66 -- .../2022-08-01/api/method_listbyservice.go | 133 +++ .../api/method_listbyservice_autorest.go | 235 ----- .../2022-08-01/api/method_update.go | 84 ++ .../2022-08-01/api/method_update_autorest.go | 98 -- .../2022-08-01/apidiagnostic/client.go | 22 +- .../2022-08-01/apidiagnostic/constants.go | 84 +- .../apidiagnostic/method_createorupdate.go | 85 ++ .../method_createorupdate_autorest.go | 98 -- .../2022-08-01/apidiagnostic/method_delete.go | 76 ++ .../apidiagnostic/method_delete_autorest.go | 95 -- .../2022-08-01/apidiagnostic/method_get.go | 51 + .../apidiagnostic/method_get_autorest.go | 68 -- .../apidiagnostic/method_getentitytag.go | 46 + .../method_getentitytag_autorest.go | 66 -- .../apidiagnostic/method_listbyservice.go | 125 +++ .../method_listbyservice_autorest.go | 225 ----- .../2022-08-01/apidiagnostic/method_update.go | 84 ++ .../apidiagnostic/method_update_autorest.go | 98 -- .../2022-08-01/apiissue/client.go | 22 +- .../2022-08-01/apiissue/constants.go | 19 +- .../apiissue/method_createorupdate.go | 85 ++ .../method_createorupdate_autorest.go | 98 -- .../2022-08-01/apiissue/method_delete.go | 76 ++ .../apiissue/method_delete_autorest.go | 95 -- .../2022-08-01/apiissue/method_get.go | 80 ++ .../apiissue/method_get_autorest.go | 97 -- .../apiissue/method_getentitytag.go | 46 + .../apiissue/method_getentitytag_autorest.go | 66 -- .../apiissue/method_listbyservice.go | 129 +++ .../apiissue/method_listbyservice_autorest.go | 230 ----- .../2022-08-01/apiissue/method_update.go | 84 ++ .../apiissue/method_update_autorest.go | 98 -- .../2022-08-01/apiissueattachment/client.go | 22 +- .../method_createorupdate.go | 85 ++ .../method_createorupdate_autorest.go | 98 -- .../apiissueattachment/method_delete.go | 76 ++ .../method_delete_autorest.go | 95 -- .../apiissueattachment/method_get.go | 51 + .../apiissueattachment/method_get_autorest.go | 68 -- .../apiissueattachment/method_getentitytag.go | 46 + .../method_getentitytag_autorest.go | 66 -- .../method_listbyservice.go | 125 +++ .../method_listbyservice_autorest.go | 225 ----- .../2022-08-01/apiissuecomment/client.go | 22 +- .../apiissuecomment/method_createorupdate.go | 85 ++ .../method_createorupdate_autorest.go | 98 -- .../apiissuecomment/method_delete.go | 76 ++ .../apiissuecomment/method_delete_autorest.go | 95 -- .../2022-08-01/apiissuecomment/method_get.go | 51 + .../apiissuecomment/method_get_autorest.go | 68 -- .../apiissuecomment/method_getentitytag.go | 46 + .../method_getentitytag_autorest.go | 66 -- .../apiissuecomment/method_listbyservice.go | 125 +++ .../method_listbyservice_autorest.go | 225 ----- .../2022-08-01/apimanagementservice/client.go | 22 +- .../apimanagementservice/constants.go | 162 ++- ...method_applynetworkconfigurationupdates.go | 74 ++ ...plynetworkconfigurationupdates_autorest.go | 79 -- .../apimanagementservice/method_backup.go | 74 ++ .../method_backup_autorest.go | 79 -- .../method_checknameavailability.go | 57 ++ .../method_checknameavailability_autorest.go | 71 -- .../method_createorupdate.go | 74 ++ .../method_createorupdate_autorest.go | 79 -- .../apimanagementservice/method_delete.go | 71 ++ .../method_delete_autorest.go | 78 -- .../apimanagementservice/method_get.go | 51 + .../method_get_autorest.go | 68 -- .../method_getdomainownershipidentifier.go | 53 + ...d_getdomainownershipidentifier_autorest.go | 70 -- .../method_getssotoken.go | 52 + .../method_getssotoken_autorest.go | 69 -- .../apimanagementservice/method_list.go | 90 ++ .../method_list_autorest.go | 187 ---- .../method_listbyresourcegroup.go | 90 ++ .../method_listbyresourcegroup_autorest.go | 187 ---- .../method_migratetostv2.go | 70 ++ .../method_migratetostv2_autorest.go | 78 -- .../apimanagementservice/method_restore.go | 74 ++ .../method_restore_autorest.go | 79 -- .../apimanagementservice/method_update.go | 74 ++ .../method_update_autorest.go | 79 -- .../apimanagementserviceskus/client.go | 22 +- .../apimanagementserviceskus/constants.go | 32 +- .../method_listavailableserviceskus.go | 89 ++ ...ethod_listavailableserviceskus_autorest.go | 186 ---- .../2022-08-01/apioperation/client.go | 22 +- .../apioperation/method_createorupdate.go | 85 ++ .../method_createorupdate_autorest.go | 98 -- .../2022-08-01/apioperation/method_delete.go | 76 ++ .../apioperation/method_delete_autorest.go | 95 -- .../2022-08-01/apioperation/method_get.go | 51 + .../apioperation/method_get_autorest.go | 68 -- .../apioperation/method_getentitytag.go | 46 + .../method_getentitytag_autorest.go | 66 -- .../apioperation/method_listbyapi.go | 129 +++ .../apioperation/method_listbyapi_autorest.go | 230 ----- .../2022-08-01/apioperation/method_update.go | 84 ++ .../apioperation/method_update_autorest.go | 98 -- .../2022-08-01/apioperationpolicy/client.go | 22 +- .../apioperationpolicy/constants.go | 32 +- .../method_createorupdate.go | 85 ++ .../method_createorupdate_autorest.go | 99 -- .../apioperationpolicy/method_delete.go | 76 ++ .../method_delete_autorest.go | 96 -- .../apioperationpolicy/method_get.go | 80 ++ .../apioperationpolicy/method_get_autorest.go | 98 -- .../apioperationpolicy/method_getentitytag.go | 47 + .../method_getentitytag_autorest.go | 67 -- .../method_listbyoperation.go | 52 + .../method_listbyoperation_autorest.go | 69 -- .../2022-08-01/apioperationsbytag/client.go | 22 +- .../apioperationsbytag/constants.go | 58 +- .../method_operationlistbytags.go | 129 +++ .../method_operationlistbytags_autorest.go | 230 ----- .../2022-08-01/apioperationtag/client.go | 22 +- .../method_tagassigntooperation.go | 52 + .../method_tagassigntooperation_autorest.go | 68 -- .../method_tagdetachfromoperation.go | 47 + .../method_tagdetachfromoperation_autorest.go | 66 -- .../method_taggetbyoperation.go | 51 + .../method_taggetbyoperation_autorest.go | 68 -- .../method_taggetentitystatebyoperation.go | 46 + ...d_taggetentitystatebyoperation_autorest.go | 66 -- .../method_taglistbyoperation.go | 125 +++ .../method_taglistbyoperation_autorest.go | 225 ----- .../2022-08-01/apipolicy/client.go | 22 +- .../2022-08-01/apipolicy/constants.go | 32 +- .../apipolicy/method_createorupdate.go | 85 ++ .../method_createorupdate_autorest.go | 99 -- .../2022-08-01/apipolicy/method_delete.go | 76 ++ .../apipolicy/method_delete_autorest.go | 96 -- .../2022-08-01/apipolicy/method_get.go | 80 ++ .../apipolicy/method_get_autorest.go | 98 -- .../apipolicy/method_getentitytag.go | 47 + .../apipolicy/method_getentitytag_autorest.go | 67 -- .../2022-08-01/apipolicy/method_listbyapi.go | 52 + .../apipolicy/method_listbyapi_autorest.go | 69 -- .../2022-08-01/apiproduct/client.go | 22 +- .../2022-08-01/apiproduct/constants.go | 19 +- .../apiproduct/method_listbyapis.go | 125 +++ .../apiproduct/method_listbyapis_autorest.go | 225 ----- .../2022-08-01/apirelease/client.go | 22 +- .../apirelease/method_createorupdate.go | 85 ++ .../method_createorupdate_autorest.go | 98 -- .../2022-08-01/apirelease/method_delete.go | 76 ++ .../apirelease/method_delete_autorest.go | 95 -- .../2022-08-01/apirelease/method_get.go | 51 + .../apirelease/method_get_autorest.go | 68 -- .../apirelease/method_getentitytag.go | 46 + .../method_getentitytag_autorest.go | 66 -- .../apirelease/method_listbyservice.go | 125 +++ .../method_listbyservice_autorest.go | 225 ----- .../2022-08-01/apirelease/method_update.go | 84 ++ .../apirelease/method_update_autorest.go | 98 -- .../2022-08-01/apirevision/client.go | 22 +- .../apirevision/method_listbyservice.go | 125 +++ .../method_listbyservice_autorest.go | 225 ----- .../2022-08-01/apisbytag/client.go | 22 +- .../2022-08-01/apisbytag/constants.go | 58 +- .../apisbytag/method_apilistbytags.go | 129 +++ .../method_apilistbytags_autorest.go | 230 ----- .../2022-08-01/apischema/client.go | 22 +- .../apischema/method_createorupdate.go | 103 ++ .../method_createorupdate_autorest.go | 108 -- .../2022-08-01/apischema/method_delete.go | 79 ++ .../apischema/method_delete_autorest.go | 100 -- .../2022-08-01/apischema/method_get.go | 51 + .../apischema/method_get_autorest.go | 68 -- .../apischema/method_getentitytag.go | 46 + .../apischema/method_getentitytag_autorest.go | 66 -- .../2022-08-01/apischema/method_listbyapi.go | 125 +++ .../apischema/method_listbyapi_autorest.go | 225 ----- .../apimanagement/2022-08-01/apitag/client.go | 22 +- .../apitag/method_tagassigntoapi.go | 52 + .../apitag/method_tagassigntoapi_autorest.go | 68 -- .../apitag/method_tagdetachfromapi.go | 47 + .../method_tagdetachfromapi_autorest.go | 66 -- .../2022-08-01/apitag/method_taggetbyapi.go | 51 + .../apitag/method_taggetbyapi_autorest.go | 68 -- .../apitag/method_taggetentitystatebyapi.go | 46 + .../method_taggetentitystatebyapi_autorest.go | 66 -- .../2022-08-01/apitag/method_taglistbyapi.go | 125 +++ .../apitag/method_taglistbyapi_autorest.go | 225 ----- .../2022-08-01/apitagdescription/client.go | 22 +- .../method_createorupdate.go | 85 ++ .../method_createorupdate_autorest.go | 98 -- .../apitagdescription/method_delete.go | 76 ++ .../method_delete_autorest.go | 95 -- .../apitagdescription/method_get.go | 51 + .../apitagdescription/method_get_autorest.go | 68 -- .../apitagdescription/method_getentitytag.go | 46 + .../method_getentitytag_autorest.go | 66 -- .../apitagdescription/method_listbyservice.go | 125 +++ .../method_listbyservice_autorest.go | 225 ----- .../2022-08-01/apiversionset/client.go | 22 +- .../2022-08-01/apiversionset/constants.go | 19 +- .../apiversionset/method_createorupdate.go | 85 ++ .../method_createorupdate_autorest.go | 98 -- .../2022-08-01/apiversionset/method_get.go | 51 + .../apiversionset/method_get_autorest.go | 68 -- .../apiversionset/method_getentitytag.go | 46 + .../method_getentitytag_autorest.go | 66 -- .../apiversionset/method_listbyservice.go | 125 +++ .../method_listbyservice_autorest.go | 225 ----- .../2022-08-01/apiversionset/method_update.go | 84 ++ .../apiversionset/method_update_autorest.go | 98 -- .../2022-08-01/apiversionsets/client.go | 22 +- .../method_apiversionsetdelete.go | 76 ++ .../method_apiversionsetdelete_autorest.go | 95 -- .../2022-08-01/apiwiki/client.go | 22 +- .../apiwiki/method_createorupdate.go | 85 ++ .../apiwiki/method_createorupdate_autorest.go | 99 -- .../2022-08-01/apiwiki/method_delete.go | 76 ++ .../apiwiki/method_delete_autorest.go | 96 -- .../2022-08-01/apiwiki/method_get.go | 52 + .../2022-08-01/apiwiki/method_get_autorest.go | 69 -- .../2022-08-01/apiwiki/method_getentitytag.go | 47 + .../apiwiki/method_getentitytag_autorest.go | 67 -- .../2022-08-01/apiwiki/method_list.go | 125 +++ .../apiwiki/method_list_autorest.go | 225 ----- .../2022-08-01/apiwiki/method_update.go | 84 ++ .../apiwiki/method_update_autorest.go | 99 -- .../2022-08-01/authorization/client.go | 22 +- .../2022-08-01/authorization/constants.go | 32 +- .../authorization/method_createorupdate.go | 85 ++ .../method_createorupdate_autorest.go | 98 -- .../2022-08-01/authorization/method_delete.go | 76 ++ .../authorization/method_delete_autorest.go | 95 -- .../2022-08-01/authorization/method_get.go | 51 + .../authorization/method_get_autorest.go | 68 -- .../authorizationaccesspolicy/client.go | 22 +- .../method_createorupdate.go | 85 ++ .../method_createorupdate_autorest.go | 98 -- .../method_delete.go | 76 ++ .../method_delete_autorest.go | 95 -- .../authorizationaccesspolicy/method_get.go | 51 + .../method_get_autorest.go | 68 -- .../method_listbyauthorization.go | 125 +++ .../method_listbyauthorization_autorest.go | 225 ----- .../authorizationconfirmconsentcode/client.go | 22 +- .../method_authorizationconfirmconsentcode.go | 51 + ...uthorizationconfirmconsentcode_autorest.go | 68 -- .../authorizationloginlinks/client.go | 22 +- .../authorizationloginlinks/method_post.go | 56 ++ .../method_post_autorest.go | 70 -- .../authorizationprovider/client.go | 22 +- .../method_createorupdate.go | 85 ++ .../method_createorupdate_autorest.go | 98 -- .../authorizationprovider/method_delete.go | 76 ++ .../method_delete_autorest.go | 95 -- .../authorizationprovider/method_get.go | 51 + .../method_get_autorest.go | 68 -- .../method_listbyservice.go | 125 +++ .../method_listbyservice_autorest.go | 225 ----- .../2022-08-01/authorizations/client.go | 22 +- .../2022-08-01/authorizations/constants.go | 32 +- ...uthorizationlistbyauthorizationprovider.go | 125 +++ ...ionlistbyauthorizationprovider_autorest.go | 225 ----- .../2022-08-01/authorizationserver/client.go | 22 +- .../authorizationserver/constants.go | 58 +- .../method_createorupdate.go | 85 ++ .../method_createorupdate_autorest.go | 98 -- .../authorizationserver/method_delete.go | 76 ++ .../method_delete_autorest.go | 95 -- .../authorizationserver/method_get.go | 51 + .../method_get_autorest.go | 68 -- .../method_getentitytag.go | 46 + .../method_getentitytag_autorest.go | 66 -- .../method_listbyservice.go | 125 +++ .../method_listbyservice_autorest.go | 225 ----- .../authorizationserver/method_listsecrets.go | 52 + .../method_listsecrets_autorest.go | 69 -- .../authorizationserver/method_update.go | 84 ++ .../method_update_autorest.go | 98 -- .../2022-08-01/backend/client.go | 22 +- .../2022-08-01/backend/constants.go | 19 +- .../backend/method_createorupdate.go | 85 ++ .../backend/method_createorupdate_autorest.go | 98 -- .../2022-08-01/backend/method_delete.go | 76 ++ .../backend/method_delete_autorest.go | 95 -- .../2022-08-01/backend/method_get.go | 51 + .../2022-08-01/backend/method_get_autorest.go | 68 -- .../2022-08-01/backend/method_getentitytag.go | 46 + .../backend/method_getentitytag_autorest.go | 66 -- .../backend/method_listbyservice.go | 125 +++ .../backend/method_listbyservice_autorest.go | 225 ----- .../2022-08-01/backend/method_update.go | 84 ++ .../backend/method_update_autorest.go | 98 -- .../2022-08-01/backendreconnect/client.go | 22 +- .../method_backendreconnect.go | 51 + .../method_backendreconnect_autorest.go | 68 -- .../apimanagement/2022-08-01/cache/client.go | 22 +- .../2022-08-01/cache/method_createorupdate.go | 85 ++ .../cache/method_createorupdate_autorest.go | 98 -- .../2022-08-01/cache/method_delete.go | 76 ++ .../cache/method_delete_autorest.go | 95 -- .../2022-08-01/cache/method_get.go | 51 + .../2022-08-01/cache/method_get_autorest.go | 68 -- .../2022-08-01/cache/method_getentitytag.go | 46 + .../cache/method_getentitytag_autorest.go | 66 -- .../2022-08-01/cache/method_listbyservice.go | 121 +++ .../cache/method_listbyservice_autorest.go | 220 ---- .../2022-08-01/cache/method_update.go | 84 ++ .../cache/method_update_autorest.go | 98 -- .../2022-08-01/certificate/client.go | 22 +- .../certificate/method_createorupdate.go | 85 ++ .../method_createorupdate_autorest.go | 98 -- .../2022-08-01/certificate/method_delete.go | 76 ++ .../certificate/method_delete_autorest.go | 95 -- .../2022-08-01/certificate/method_get.go | 51 + .../certificate/method_get_autorest.go | 68 -- .../certificate/method_getentitytag.go | 46 + .../method_getentitytag_autorest.go | 66 -- .../certificate/method_listbyservice.go | 129 +++ .../method_listbyservice_autorest.go | 230 ----- .../certificate/method_refreshsecret.go | 52 + .../method_refreshsecret_autorest.go | 69 -- .../apimanagement/2022-08-01/client.go | 949 ++++++++++++------ .../2022-08-01/contenttype/client.go | 22 +- .../contenttype/method_createorupdate.go | 85 ++ .../method_createorupdate_autorest.go | 98 -- .../2022-08-01/contenttype/method_delete.go | 76 ++ .../contenttype/method_delete_autorest.go | 95 -- .../2022-08-01/contenttype/method_get.go | 51 + .../contenttype/method_get_autorest.go | 68 -- .../contenttype/method_listbyservice.go | 89 ++ .../method_listbyservice_autorest.go | 186 ---- .../contenttypecontentitem/client.go | 22 +- .../method_contentitemcreateorupdate.go | 85 ++ ...thod_contentitemcreateorupdate_autorest.go | 98 -- .../method_contentitemdelete.go | 76 ++ .../method_contentitemdelete_autorest.go | 95 -- .../method_contentitemget.go | 51 + .../method_contentitemget_autorest.go | 68 -- .../method_contentitemgetentitytag.go | 46 + ...method_contentitemgetentitytag_autorest.go | 66 -- .../method_contentitemlistbyservice.go | 89 ++ ...ethod_contentitemlistbyservice_autorest.go | 186 ---- .../2022-08-01/delegationsettings/client.go | 22 +- .../method_createorupdate.go | 84 ++ .../method_createorupdate_autorest.go | 99 -- .../delegationsettings/method_get.go | 52 + .../delegationsettings/method_get_autorest.go | 69 -- .../delegationsettings/method_getentitytag.go | 47 + .../method_getentitytag_autorest.go | 67 -- .../delegationsettings/method_listsecrets.go | 52 + .../method_listsecrets_autorest.go | 69 -- .../delegationsettings/method_update.go | 79 ++ .../method_update_autorest.go | 97 -- .../2022-08-01/deletedservice/client.go | 22 +- .../deletedservice/method_getbyname.go | 51 + .../method_getbyname_autorest.go | 68 -- .../method_listbysubscription.go | 90 ++ .../method_listbysubscription_autorest.go | 187 ---- .../2022-08-01/deletedservice/method_purge.go | 71 ++ .../deletedservice/method_purge_autorest.go | 78 -- .../2022-08-01/diagnostic/client.go | 22 +- .../2022-08-01/diagnostic/constants.go | 84 +- .../diagnostic/method_createorupdate.go | 85 ++ .../method_createorupdate_autorest.go | 98 -- .../2022-08-01/diagnostic/method_delete.go | 76 ++ .../diagnostic/method_delete_autorest.go | 95 -- .../2022-08-01/diagnostic/method_get.go | 51 + .../diagnostic/method_get_autorest.go | 68 -- .../diagnostic/method_getentitytag.go | 46 + .../method_getentitytag_autorest.go | 66 -- .../diagnostic/method_listbyservice.go | 125 +++ .../method_listbyservice_autorest.go | 225 ----- .../2022-08-01/diagnostic/method_update.go | 84 ++ .../diagnostic/method_update_autorest.go | 98 -- .../documentationresource/client.go | 22 +- .../method_createorupdate.go | 85 ++ .../method_createorupdate_autorest.go | 98 -- .../documentationresource/method_delete.go | 76 ++ .../method_delete_autorest.go | 95 -- .../documentationresource/method_get.go | 51 + .../method_get_autorest.go | 68 -- .../method_getentitytag.go | 46 + .../method_getentitytag_autorest.go | 66 -- .../method_listbyservice.go | 125 +++ .../method_listbyservice_autorest.go | 225 ----- .../documentationresource/method_update.go | 84 ++ .../method_update_autorest.go | 98 -- .../2022-08-01/emailtemplate/client.go | 22 +- .../emailtemplate/method_listbyservice.go | 125 +++ .../method_listbyservice_autorest.go | 225 ----- .../2022-08-01/emailtemplates/client.go | 22 +- .../2022-08-01/emailtemplates/constants.go | 19 +- .../method_emailtemplatecreateorupdate.go | 85 ++ ...od_emailtemplatecreateorupdate_autorest.go | 98 -- .../method_emailtemplatedelete.go | 76 ++ .../method_emailtemplatedelete_autorest.go | 95 -- .../emailtemplates/method_emailtemplateget.go | 51 + .../method_emailtemplateget_autorest.go | 68 -- .../method_emailtemplategetentitytag.go | 46 + ...thod_emailtemplategetentitytag_autorest.go | 66 -- .../method_emailtemplateupdate.go | 84 ++ .../method_emailtemplateupdate_autorest.go | 98 -- .../2022-08-01/gateway/client.go | 22 +- .../gateway/method_createorupdate.go | 85 ++ .../gateway/method_createorupdate_autorest.go | 98 -- .../2022-08-01/gateway/method_delete.go | 76 ++ .../gateway/method_delete_autorest.go | 95 -- .../2022-08-01/gateway/method_get.go | 51 + .../2022-08-01/gateway/method_get_autorest.go | 68 -- .../2022-08-01/gateway/method_getentitytag.go | 46 + .../gateway/method_getentitytag_autorest.go | 66 -- .../gateway/method_listbyservice.go | 125 +++ .../gateway/method_listbyservice_autorest.go | 225 ----- .../2022-08-01/gateway/method_update.go | 84 ++ .../gateway/method_update_autorest.go | 98 -- .../2022-08-01/gatewayapi/client.go | 22 +- .../2022-08-01/gatewayapi/constants.go | 71 +- .../gatewayapi/method_createorupdate.go | 56 ++ .../method_createorupdate_autorest.go | 69 -- .../2022-08-01/gatewayapi/method_delete.go | 47 + .../gatewayapi/method_delete_autorest.go | 66 -- .../gatewayapi/method_getentitytag.go | 46 + .../method_getentitytag_autorest.go | 66 -- .../gatewayapi/method_listbyservice.go | 125 +++ .../method_listbyservice_autorest.go | 225 ----- .../gatewaycertificateauthority/client.go | 22 +- .../method_createorupdate.go | 85 ++ .../method_createorupdate_autorest.go | 98 -- .../method_delete.go | 76 ++ .../method_delete_autorest.go | 95 -- .../gatewaycertificateauthority/method_get.go | 51 + .../method_get_autorest.go | 68 -- .../method_getentitytag.go | 46 + .../method_getentitytag_autorest.go | 66 -- .../method_listbyservice.go | 125 +++ .../method_listbyservice_autorest.go | 225 ----- .../2022-08-01/gatewaygeneratetoken/client.go | 22 +- .../gatewaygeneratetoken/constants.go | 19 +- .../method_gatewaygeneratetoken.go | 56 ++ .../method_gatewaygeneratetoken_autorest.go | 70 -- .../gatewayhostnameconfiguration/client.go | 22 +- .../method_createorupdate.go | 85 ++ .../method_createorupdate_autorest.go | 98 -- .../method_delete.go | 76 ++ .../method_delete_autorest.go | 95 -- .../method_get.go | 51 + .../method_get_autorest.go | 68 -- .../method_getentitytag.go | 46 + .../method_getentitytag_autorest.go | 66 -- .../method_listbyservice.go | 125 +++ .../method_listbyservice_autorest.go | 225 ----- .../2022-08-01/gatewaylistkeys/client.go | 22 +- .../gatewaylistkeys/method_gatewaylistkeys.go | 52 + .../method_gatewaylistkeys_autorest.go | 69 -- .../2022-08-01/gatewayregeneratekey/client.go | 22 +- .../gatewayregeneratekey/constants.go | 19 +- .../method_gatewayregeneratekey.go | 51 + .../method_gatewayregeneratekey_autorest.go | 68 -- .../2022-08-01/graphqlapiresolver/client.go | 22 +- .../method_createorupdate.go | 85 ++ .../method_createorupdate_autorest.go | 98 -- .../graphqlapiresolver/method_delete.go | 76 ++ .../method_delete_autorest.go | 95 -- .../graphqlapiresolver/method_get.go | 51 + .../graphqlapiresolver/method_get_autorest.go | 68 -- .../graphqlapiresolver/method_getentitytag.go | 46 + .../method_getentitytag_autorest.go | 66 -- .../graphqlapiresolver/method_listbyapi.go | 125 +++ .../method_listbyapi_autorest.go | 225 ----- .../graphqlapiresolver/method_update.go | 84 ++ .../method_update_autorest.go | 98 -- .../graphqlapiresolverpolicy/client.go | 22 +- .../graphqlapiresolverpolicy/constants.go | 32 +- .../method_createorupdate.go | 85 ++ .../method_createorupdate_autorest.go | 99 -- .../graphqlapiresolverpolicy/method_delete.go | 76 ++ .../method_delete_autorest.go | 96 -- .../graphqlapiresolverpolicy/method_get.go | 80 ++ .../method_get_autorest.go | 98 -- .../method_getentitytag.go | 47 + .../method_getentitytag_autorest.go | 67 -- .../method_listbyresolver.go | 89 ++ .../method_listbyresolver_autorest.go | 186 ---- .../apimanagement/2022-08-01/group/client.go | 22 +- .../2022-08-01/group/constants.go | 19 +- .../2022-08-01/group/method_createorupdate.go | 85 ++ .../group/method_createorupdate_autorest.go | 98 -- .../2022-08-01/group/method_delete.go | 76 ++ .../group/method_delete_autorest.go | 95 -- .../2022-08-01/group/method_get.go | 51 + .../2022-08-01/group/method_get_autorest.go | 68 -- .../2022-08-01/group/method_getentitytag.go | 46 + .../group/method_getentitytag_autorest.go | 66 -- .../2022-08-01/group/method_listbyservice.go | 125 +++ .../group/method_listbyservice_autorest.go | 225 ----- .../2022-08-01/group/method_update.go | 84 ++ .../group/method_update_autorest.go | 98 -- .../2022-08-01/groupuser/client.go | 22 +- .../2022-08-01/groupuser/constants.go | 32 +- .../groupuser/method_checkentityexists.go | 46 + .../method_checkentityexists_autorest.go | 66 -- .../2022-08-01/groupuser/method_create.go | 52 + .../groupuser/method_create_autorest.go | 68 -- .../2022-08-01/groupuser/method_delete.go | 47 + .../groupuser/method_delete_autorest.go | 66 -- .../2022-08-01/groupuser/method_list.go | 125 +++ .../groupuser/method_list_autorest.go | 225 ----- .../2022-08-01/identityprovider/client.go | 22 +- .../2022-08-01/identityprovider/constants.go | 19 +- .../identityprovider/method_createorupdate.go | 85 ++ .../method_createorupdate_autorest.go | 98 -- .../identityprovider/method_delete.go | 76 ++ .../method_delete_autorest.go | 95 -- .../2022-08-01/identityprovider/method_get.go | 51 + .../identityprovider/method_get_autorest.go | 68 -- .../identityprovider/method_getentitytag.go | 46 + .../method_getentitytag_autorest.go | 66 -- .../identityprovider/method_listbyservice.go | 89 ++ .../method_listbyservice_autorest.go | 186 ---- .../identityprovider/method_listsecrets.go | 52 + .../method_listsecrets_autorest.go | 69 -- .../identityprovider/method_update.go | 84 ++ .../method_update_autorest.go | 98 -- .../apimanagement/2022-08-01/issue/client.go | 22 +- .../2022-08-01/issue/constants.go | 19 +- .../2022-08-01/issue/method_get.go | 51 + .../2022-08-01/issue/method_get_autorest.go | 68 -- .../2022-08-01/issue/method_listbyservice.go | 125 +++ .../issue/method_listbyservice_autorest.go | 225 ----- .../apimanagement/2022-08-01/logger/client.go | 22 +- .../2022-08-01/logger/constants.go | 19 +- .../logger/method_createorupdate.go | 85 ++ .../logger/method_createorupdate_autorest.go | 98 -- .../2022-08-01/logger/method_delete.go | 76 ++ .../logger/method_delete_autorest.go | 95 -- .../2022-08-01/logger/method_get.go | 51 + .../2022-08-01/logger/method_get_autorest.go | 68 -- .../2022-08-01/logger/method_getentitytag.go | 46 + .../logger/method_getentitytag_autorest.go | 66 -- .../2022-08-01/logger/method_listbyservice.go | 125 +++ .../logger/method_listbyservice_autorest.go | 225 ----- .../2022-08-01/logger/method_update.go | 84 ++ .../logger/method_update_autorest.go | 98 -- .../2022-08-01/namedvalue/client.go | 22 +- .../namedvalue/method_createorupdate.go | 103 ++ .../method_createorupdate_autorest.go | 108 -- .../2022-08-01/namedvalue/method_delete.go | 76 ++ .../namedvalue/method_delete_autorest.go | 95 -- .../2022-08-01/namedvalue/method_get.go | 51 + .../namedvalue/method_get_autorest.go | 68 -- .../namedvalue/method_getentitytag.go | 46 + .../method_getentitytag_autorest.go | 66 -- .../namedvalue/method_listbyservice.go | 129 +++ .../method_listbyservice_autorest.go | 230 ----- .../2022-08-01/namedvalue/method_listvalue.go | 52 + .../namedvalue/method_listvalue_autorest.go | 69 -- .../namedvalue/method_refreshsecret.go | 70 ++ .../method_refreshsecret_autorest.go | 78 -- .../2022-08-01/namedvalue/method_update.go | 102 ++ .../namedvalue/method_update_autorest.go | 108 -- .../2022-08-01/networkstatus/client.go | 22 +- .../2022-08-01/networkstatus/constants.go | 19 +- .../networkstatus/method_listbylocation.go | 52 + .../method_listbylocation_autorest.go | 69 -- .../networkstatus/method_listbyservice.go | 52 + .../method_listbyservice_autorest.go | 69 -- .../2022-08-01/notification/client.go | 22 +- .../2022-08-01/notification/constants.go | 19 +- .../notification/method_createorupdate.go | 80 ++ .../method_createorupdate_autorest.go | 97 -- .../2022-08-01/notification/method_get.go | 51 + .../notification/method_get_autorest.go | 68 -- .../notification/method_listbyservice.go | 121 +++ .../method_listbyservice_autorest.go | 220 ---- .../notificationrecipientemail/client.go | 22 +- .../notificationrecipientemail/constants.go | 19 +- .../method_checkentityexists.go | 46 + .../method_checkentityexists_autorest.go | 66 -- .../method_createorupdate.go | 52 + .../method_createorupdate_autorest.go | 68 -- .../method_delete.go | 47 + .../method_delete_autorest.go | 66 -- .../method_listbynotification.go | 52 + .../method_listbynotification_autorest.go | 69 -- .../notificationrecipientuser/client.go | 22 +- .../notificationrecipientuser/constants.go | 19 +- .../method_checkentityexists.go | 46 + .../method_checkentityexists_autorest.go | 66 -- .../method_createorupdate.go | 52 + .../method_createorupdate_autorest.go | 68 -- .../method_delete.go | 47 + .../method_delete_autorest.go | 66 -- .../method_listbynotification.go | 52 + .../method_listbynotification_autorest.go | 69 -- .../openidconnectprovider/client.go | 22 +- .../method_createorupdate.go | 85 ++ .../method_createorupdate_autorest.go | 98 -- .../openidconnectprovider/method_delete.go | 76 ++ .../method_delete_autorest.go | 95 -- .../openidconnectprovider/method_get.go | 51 + .../method_get_autorest.go | 68 -- .../method_getentitytag.go | 46 + .../method_getentitytag_autorest.go | 66 -- .../method_listbyservice.go | 125 +++ .../method_listbyservice_autorest.go | 225 ----- .../method_listsecrets.go | 52 + .../method_listsecrets_autorest.go | 69 -- .../openidconnectprovider/method_update.go | 84 ++ .../method_update_autorest.go | 98 -- .../client.go | 22 +- .../method_listbyservice.go | 52 + .../method_listbyservice_autorest.go | 69 -- .../performconnectivitycheck/client.go | 22 +- .../performconnectivitycheck/constants.go | 97 +- .../performconnectivitycheck/method_async.go | 74 ++ .../method_async_autorest.go | 79 -- .../apimanagement/2022-08-01/policy/client.go | 22 +- .../2022-08-01/policy/constants.go | 32 +- .../policy/method_createorupdate.go | 85 ++ .../policy/method_createorupdate_autorest.go | 99 -- .../2022-08-01/policy/method_delete.go | 76 ++ .../policy/method_delete_autorest.go | 96 -- .../2022-08-01/policy/method_get.go | 80 ++ .../2022-08-01/policy/method_get_autorest.go | 98 -- .../2022-08-01/policy/method_getentitytag.go | 47 + .../policy/method_getentitytag_autorest.go | 67 -- .../2022-08-01/policy/method_listbyservice.go | 52 + .../policy/method_listbyservice_autorest.go | 69 -- .../2022-08-01/policydescription/client.go | 22 +- .../2022-08-01/policydescription/constants.go | 19 +- .../policydescription/method_listbyservice.go | 80 ++ .../method_listbyservice_autorest.go | 98 -- .../2022-08-01/policyfragment/client.go | 22 +- .../2022-08-01/policyfragment/constants.go | 19 +- .../policyfragment/method_createorupdate.go | 103 ++ .../method_createorupdate_autorest.go | 108 -- .../policyfragment/method_delete.go | 76 ++ .../policyfragment/method_delete_autorest.go | 95 -- .../2022-08-01/policyfragment/method_get.go | 80 ++ .../policyfragment/method_get_autorest.go | 97 -- .../policyfragment/method_getentitytag.go | 46 + .../method_getentitytag_autorest.go | 66 -- .../policyfragment/method_listbyservice.go | 92 ++ .../method_listbyservice_autorest.go | 113 --- .../policyfragment/method_listreferences.go | 84 ++ .../method_listreferences_autorest.go | 103 -- .../2022-08-01/portalconfig/client.go | 22 +- .../2022-08-01/portalconfig/constants.go | 19 +- .../portalconfig/method_createorupdate.go | 84 ++ .../method_createorupdate_autorest.go | 98 -- .../2022-08-01/portalconfig/method_get.go | 51 + .../portalconfig/method_get_autorest.go | 68 -- .../portalconfig/method_getentitytag.go | 46 + .../method_getentitytag_autorest.go | 66 -- .../portalconfig/method_listbyservice.go | 52 + .../method_listbyservice_autorest.go | 69 -- .../2022-08-01/portalconfig/method_update.go | 84 ++ .../portalconfig/method_update_autorest.go | 98 -- .../2022-08-01/portalrevision/client.go | 22 +- .../2022-08-01/portalrevision/constants.go | 19 +- .../portalrevision/method_createorupdate.go | 74 ++ .../method_createorupdate_autorest.go | 79 -- .../2022-08-01/portalrevision/method_get.go | 51 + .../portalrevision/method_get_autorest.go | 68 -- .../portalrevision/method_getentitytag.go | 46 + .../method_getentitytag_autorest.go | 66 -- .../portalrevision/method_listbyservice.go | 125 +++ .../method_listbyservice_autorest.go | 225 ----- .../portalrevision/method_update.go | 102 ++ .../portalrevision/method_update_autorest.go | 108 -- .../2022-08-01/portalsettings/client.go | 22 +- .../portalsettings/method_listbyservice.go | 52 + .../method_listbyservice_autorest.go | 69 -- .../privateendpointconnections/client.go | 22 +- .../privateendpointconnections/constants.go | 32 +- ...privateendpointconnectioncreateorupdate.go | 74 ++ ...dpointconnectioncreateorupdate_autorest.go | 79 -- .../method_privateendpointconnectiondelete.go | 71 ++ ...rivateendpointconnectiondelete_autorest.go | 78 -- ...thod_privateendpointconnectiongetbyname.go | 51 + ...ateendpointconnectiongetbyname_autorest.go | 68 -- ...ndpointconnectiongetprivatelinkresource.go | 51 + ...nnectiongetprivatelinkresource_autorest.go | 68 -- ..._privateendpointconnectionlistbyservice.go | 52 + ...ndpointconnectionlistbyservice_autorest.go | 69 -- ...pointconnectionlistprivatelinkresources.go | 52 + ...ectionlistprivatelinkresources_autorest.go | 69 -- .../2022-08-01/product/client.go | 22 +- .../2022-08-01/product/constants.go | 19 +- .../product/method_createorupdate.go | 85 ++ .../product/method_createorupdate_autorest.go | 98 -- .../2022-08-01/product/method_delete.go | 79 ++ .../product/method_delete_autorest.go | 100 -- .../2022-08-01/product/method_get.go | 51 + .../2022-08-01/product/method_get_autorest.go | 68 -- .../2022-08-01/product/method_getentitytag.go | 46 + .../product/method_getentitytag_autorest.go | 66 -- .../product/method_listbyservice.go | 133 +++ .../product/method_listbyservice_autorest.go | 235 ----- .../2022-08-01/product/method_update.go | 84 ++ .../product/method_update_autorest.go | 98 -- .../2022-08-01/productapi/client.go | 22 +- .../2022-08-01/productapi/constants.go | 58 +- .../productapi/method_checkentityexists.go | 46 + .../method_checkentityexists_autorest.go | 66 -- .../productapi/method_createorupdate.go | 52 + .../method_createorupdate_autorest.go | 68 -- .../2022-08-01/productapi/method_delete.go | 47 + .../productapi/method_delete_autorest.go | 66 -- .../productapi/method_listbyproduct.go | 125 +++ .../method_listbyproduct_autorest.go | 225 ----- .../2022-08-01/productgroup/client.go | 22 +- .../2022-08-01/productgroup/constants.go | 19 +- .../productgroup/method_checkentityexists.go | 46 + .../method_checkentityexists_autorest.go | 66 -- .../productgroup/method_createorupdate.go | 52 + .../method_createorupdate_autorest.go | 68 -- .../2022-08-01/productgroup/method_delete.go | 47 + .../productgroup/method_delete_autorest.go | 66 -- .../productgroup/method_listbyproduct.go | 125 +++ .../method_listbyproduct_autorest.go | 225 ----- .../2022-08-01/productpolicy/client.go | 22 +- .../2022-08-01/productpolicy/constants.go | 32 +- .../productpolicy/method_createorupdate.go | 85 ++ .../method_createorupdate_autorest.go | 99 -- .../2022-08-01/productpolicy/method_delete.go | 76 ++ .../productpolicy/method_delete_autorest.go | 96 -- .../2022-08-01/productpolicy/method_get.go | 80 ++ .../productpolicy/method_get_autorest.go | 98 -- .../productpolicy/method_getentitytag.go | 47 + .../method_getentitytag_autorest.go | 67 -- .../productpolicy/method_listbyproduct.go | 52 + .../method_listbyproduct_autorest.go | 69 -- .../2022-08-01/productsbytag/client.go | 22 +- .../2022-08-01/productsbytag/constants.go | 58 +- .../productsbytag/method_productlistbytags.go | 129 +++ .../method_productlistbytags_autorest.go | 230 ----- .../2022-08-01/productsubscription/client.go | 22 +- .../productsubscription/constants.go | 19 +- .../productsubscription/method_list.go | 125 +++ .../method_list_autorest.go | 225 ----- .../2022-08-01/producttag/client.go | 22 +- .../producttag/method_tagassigntoproduct.go | 52 + .../method_tagassigntoproduct_autorest.go | 68 -- .../producttag/method_tagdetachfromproduct.go | 47 + .../method_tagdetachfromproduct_autorest.go | 66 -- .../producttag/method_taggetbyproduct.go | 51 + .../method_taggetbyproduct_autorest.go | 68 -- .../method_taggetentitystatebyproduct.go | 46 + ...hod_taggetentitystatebyproduct_autorest.go | 66 -- .../producttag/method_taglistbyproduct.go | 125 +++ .../method_taglistbyproduct_autorest.go | 225 ----- .../2022-08-01/productwiki/client.go | 22 +- .../productwiki/method_createorupdate.go | 85 ++ .../method_createorupdate_autorest.go | 99 -- .../2022-08-01/productwiki/method_delete.go | 76 ++ .../productwiki/method_delete_autorest.go | 96 -- .../2022-08-01/productwiki/method_get.go | 52 + .../productwiki/method_get_autorest.go | 69 -- .../productwiki/method_getentitytag.go | 47 + .../method_getentitytag_autorest.go | 67 -- .../2022-08-01/productwiki/method_list.go | 125 +++ .../productwiki/method_list_autorest.go | 225 ----- .../2022-08-01/productwiki/method_update.go | 84 ++ .../productwiki/method_update_autorest.go | 99 -- .../2022-08-01/quotabycounterkeys/client.go | 22 +- .../method_listbyservice.go | 51 + .../method_listbyservice_autorest.go | 68 -- .../quotabycounterkeys/method_update.go | 55 + .../method_update_autorest.go | 69 -- .../2022-08-01/quotabyperiodkeys/client.go | 22 +- .../quotabyperiodkeys/method_get.go | 51 + .../quotabyperiodkeys/method_get_autorest.go | 68 -- .../quotabyperiodkeys/method_update.go | 55 + .../method_update_autorest.go | 69 -- .../apimanagement/2022-08-01/region/client.go | 22 +- .../2022-08-01/region/method_listbyservice.go | 89 ++ .../region/method_listbyservice_autorest.go | 186 ---- .../2022-08-01/reports/client.go | 22 +- .../2022-08-01/reports/method_listbyapi.go | 129 +++ .../reports/method_listbyapi_autorest.go | 230 ----- .../2022-08-01/reports/method_listbygeo.go | 125 +++ .../reports/method_listbygeo_autorest.go | 225 ----- .../reports/method_listbyoperation.go | 129 +++ .../method_listbyoperation_autorest.go | 230 ----- .../reports/method_listbyproduct.go | 129 +++ .../reports/method_listbyproduct_autorest.go | 230 ----- .../reports/method_listbyrequest.go | 88 ++ .../reports/method_listbyrequest_autorest.go | 108 -- .../reports/method_listbysubscription.go | 129 +++ .../method_listbysubscription_autorest.go | 230 ----- .../2022-08-01/reports/method_listbytime.go | 133 +++ .../reports/method_listbytime_autorest.go | 235 ----- .../2022-08-01/reports/method_listbyuser.go | 129 +++ .../reports/method_listbyuser_autorest.go | 230 ----- .../apimanagement/2022-08-01/schema/client.go | 22 +- .../2022-08-01/schema/constants.go | 19 +- .../method_globalschemacreateorupdate.go | 103 ++ ...hod_globalschemacreateorupdate_autorest.go | 108 -- .../schema/method_globalschemadelete.go | 76 ++ .../method_globalschemadelete_autorest.go | 95 -- .../schema/method_globalschemaget.go | 51 + .../schema/method_globalschemaget_autorest.go | 68 -- .../schema/method_globalschemagetentitytag.go | 46 + ...ethod_globalschemagetentitytag_autorest.go | 66 -- .../method_globalschemalistbyservice.go | 125 +++ ...thod_globalschemalistbyservice_autorest.go | 225 ----- .../2022-08-01/signinsettings/client.go | 22 +- .../signinsettings/method_createorupdate.go | 84 ++ .../method_createorupdate_autorest.go | 99 -- .../2022-08-01/signinsettings/method_get.go | 52 + .../signinsettings/method_get_autorest.go | 69 -- .../signinsettings/method_getentitytag.go | 47 + .../method_getentitytag_autorest.go | 67 -- .../signinsettings/method_update.go | 79 ++ .../signinsettings/method_update_autorest.go | 97 -- .../2022-08-01/signupsettings/client.go | 22 +- .../signupsettings/method_createorupdate.go | 84 ++ .../method_createorupdate_autorest.go | 99 -- .../2022-08-01/signupsettings/method_get.go | 52 + .../signupsettings/method_get_autorest.go | 69 -- .../signupsettings/method_getentitytag.go | 47 + .../method_getentitytag_autorest.go | 67 -- .../signupsettings/method_update.go | 79 ++ .../signupsettings/method_update_autorest.go | 97 -- .../apimanagement/2022-08-01/skus/client.go | 22 +- .../2022-08-01/skus/constants.go | 45 +- .../skus/method_apimanagementskuslist.go | 90 ++ .../method_apimanagementskuslist_autorest.go | 187 ---- .../2022-08-01/subscription/client.go | 22 +- .../2022-08-01/subscription/constants.go | 32 +- .../subscription/method_createorupdate.go | 92 ++ .../method_createorupdate_autorest.go | 108 -- .../2022-08-01/subscription/method_delete.go | 76 ++ .../subscription/method_delete_autorest.go | 95 -- .../2022-08-01/subscription/method_get.go | 51 + .../subscription/method_get_autorest.go | 68 -- .../subscription/method_getentitytag.go | 46 + .../method_getentitytag_autorest.go | 66 -- .../2022-08-01/subscription/method_list.go | 125 +++ .../subscription/method_list_autorest.go | 225 ----- .../subscription/method_listsecrets.go | 52 + .../method_listsecrets_autorest.go | 69 -- .../method_regenerateprimarykey.go | 47 + .../method_regenerateprimarykey_autorest.go | 67 -- .../method_regeneratesecondarykey.go | 47 + .../method_regeneratesecondarykey_autorest.go | 67 -- .../2022-08-01/subscription/method_update.go | 91 ++ .../subscription/method_update_autorest.go | 108 -- .../method_usersubscriptionget.go | 51 + .../method_usersubscriptionget_autorest.go | 68 -- .../apimanagement/2022-08-01/tag/client.go | 22 +- .../2022-08-01/tag/method_createorupdate.go | 85 ++ .../tag/method_createorupdate_autorest.go | 98 -- .../2022-08-01/tag/method_delete.go | 76 ++ .../2022-08-01/tag/method_delete_autorest.go | 95 -- .../2022-08-01/tag/method_get.go | 51 + .../2022-08-01/tag/method_get_autorest.go | 68 -- .../2022-08-01/tag/method_getentitystate.go | 46 + .../tag/method_getentitystate_autorest.go | 66 -- .../2022-08-01/tag/method_listbyservice.go | 129 +++ .../tag/method_listbyservice_autorest.go | 230 ----- .../2022-08-01/tag/method_update.go | 84 ++ .../2022-08-01/tag/method_update_autorest.go | 98 -- .../2022-08-01/tagresource/client.go | 22 +- .../2022-08-01/tagresource/constants.go | 58 +- .../tagresource/method_listbyservice.go | 125 +++ .../method_listbyservice_autorest.go | 225 ----- .../2022-08-01/tenantaccess/client.go | 22 +- .../2022-08-01/tenantaccess/constants.go | 19 +- .../2022-08-01/tenantaccess/method_create.go | 84 ++ .../tenantaccess/method_create_autorest.go | 98 -- .../2022-08-01/tenantaccess/method_get.go | 51 + .../tenantaccess/method_get_autorest.go | 68 -- .../tenantaccess/method_getentitytag.go | 46 + .../method_getentitytag_autorest.go | 66 -- .../tenantaccess/method_listbyservice.go | 117 +++ .../method_listbyservice_autorest.go | 215 ---- .../tenantaccess/method_listsecrets.go | 52 + .../method_listsecrets_autorest.go | 69 -- .../method_regenerateprimarykey.go | 47 + .../method_regenerateprimarykey_autorest.go | 67 -- .../method_regeneratesecondarykey.go | 47 + .../method_regeneratesecondarykey_autorest.go | 67 -- .../2022-08-01/tenantaccess/method_update.go | 84 ++ .../tenantaccess/method_update_autorest.go | 98 -- .../2022-08-01/tenantaccessgit/client.go | 22 +- .../2022-08-01/tenantaccessgit/constants.go | 19 +- .../method_regenerateprimarykey.go | 47 + .../method_regenerateprimarykey_autorest.go | 67 -- .../method_regeneratesecondarykey.go | 47 + .../method_regeneratesecondarykey_autorest.go | 67 -- .../2022-08-01/tenantconfiguration/client.go | 22 +- .../tenantconfiguration/constants.go | 19 +- .../tenantconfiguration/method_deploy.go | 74 ++ .../method_deploy_autorest.go | 79 -- .../tenantconfiguration/method_save.go | 74 ++ .../method_save_autorest.go | 79 -- .../tenantconfiguration/method_validate.go | 74 ++ .../method_validate_autorest.go | 79 -- .../tenantconfigurationsyncstate/client.go | 22 +- .../method_tenantconfigurationgetsyncstate.go | 52 + ...enantconfigurationgetsyncstate_autorest.go | 69 -- .../2022-08-01/tenantsettings/client.go | 22 +- .../2022-08-01/tenantsettings/method_get.go | 52 + .../tenantsettings/method_get_autorest.go | 69 -- .../tenantsettings/method_listbyservice.go | 117 +++ .../method_listbyservice_autorest.go | 215 ---- .../apimanagement/2022-08-01/user/client.go | 22 +- .../2022-08-01/user/constants.go | 58 +- .../2022-08-01/user/method_createorupdate.go | 88 ++ .../user/method_createorupdate_autorest.go | 103 -- .../2022-08-01/user/method_delete.go | 87 ++ .../2022-08-01/user/method_delete_autorest.go | 110 -- .../2022-08-01/user/method_get.go | 51 + .../2022-08-01/user/method_get_autorest.go | 68 -- .../2022-08-01/user/method_getentitytag.go | 46 + .../user/method_getentitytag_autorest.go | 66 -- .../2022-08-01/user/method_listbyservice.go | 129 +++ .../user/method_listbyservice_autorest.go | 230 ----- .../2022-08-01/user/method_update.go | 84 ++ .../2022-08-01/user/method_update_autorest.go | 98 -- .../userconfirmationpasswordsend/client.go | 22 +- .../userconfirmationpasswordsend/constants.go | 19 +- .../method_userconfirmationpasswordsend.go | 75 ++ ...d_userconfirmationpasswordsend_autorest.go | 96 -- .../2022-08-01/usergroup/client.go | 22 +- .../2022-08-01/usergroup/constants.go | 19 +- .../2022-08-01/usergroup/method_list.go | 125 +++ .../usergroup/method_list_autorest.go | 225 ----- .../2022-08-01/useridentity/client.go | 22 +- .../useridentity/method_useridentitieslist.go | 89 ++ .../method_useridentitieslist_autorest.go | 186 ---- .../apimanagement/2022-08-01/users/client.go | 22 +- .../users/method_usergeneratessourl.go | 52 + .../method_usergeneratessourl_autorest.go | 69 -- .../2022-08-01/usersubscription/client.go | 22 +- .../2022-08-01/usersubscription/constants.go | 19 +- .../usersubscription/method_list.go | 125 +++ .../usersubscription/method_list_autorest.go | 225 ----- .../2022-08-01/usertoken/client.go | 22 +- .../2022-08-01/usertoken/constants.go | 19 +- .../method_usergetsharedaccesstoken.go | 56 ++ ...ethod_usergetsharedaccesstoken_autorest.go | 70 -- ...frontendipconfigurationpropertiesformat.go | 1 - ...frontendipconfigurationpropertiesformat.go | 1 - 1776 files changed, 63080 insertions(+), 81214 deletions(-) create mode 100644 resource-manager/apimanagement/2021-08-01/api/method_createorupdate.go delete mode 100644 resource-manager/apimanagement/2021-08-01/api/method_createorupdate_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/api/method_delete.go delete mode 100644 resource-manager/apimanagement/2021-08-01/api/method_delete_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/api/method_get.go delete mode 100644 resource-manager/apimanagement/2021-08-01/api/method_get_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/api/method_getentitytag.go delete mode 100644 resource-manager/apimanagement/2021-08-01/api/method_getentitytag_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/api/method_listbyservice.go delete mode 100644 resource-manager/apimanagement/2021-08-01/api/method_listbyservice_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/api/method_update.go delete mode 100644 resource-manager/apimanagement/2021-08-01/api/method_update_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/apidiagnostic/method_createorupdate.go delete mode 100644 resource-manager/apimanagement/2021-08-01/apidiagnostic/method_createorupdate_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/apidiagnostic/method_delete.go delete mode 100644 resource-manager/apimanagement/2021-08-01/apidiagnostic/method_delete_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/apidiagnostic/method_get.go delete mode 100644 resource-manager/apimanagement/2021-08-01/apidiagnostic/method_get_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/apidiagnostic/method_getentitytag.go delete mode 100644 resource-manager/apimanagement/2021-08-01/apidiagnostic/method_getentitytag_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/apidiagnostic/method_listbyservice.go delete mode 100644 resource-manager/apimanagement/2021-08-01/apidiagnostic/method_listbyservice_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/apidiagnostic/method_update.go delete mode 100644 resource-manager/apimanagement/2021-08-01/apidiagnostic/method_update_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/apiissue/method_createorupdate.go delete mode 100644 resource-manager/apimanagement/2021-08-01/apiissue/method_createorupdate_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/apiissue/method_delete.go delete mode 100644 resource-manager/apimanagement/2021-08-01/apiissue/method_delete_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/apiissue/method_get.go delete mode 100644 resource-manager/apimanagement/2021-08-01/apiissue/method_get_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/apiissue/method_getentitytag.go delete mode 100644 resource-manager/apimanagement/2021-08-01/apiissue/method_getentitytag_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/apiissue/method_listbyservice.go delete mode 100644 resource-manager/apimanagement/2021-08-01/apiissue/method_listbyservice_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/apiissue/method_update.go delete mode 100644 resource-manager/apimanagement/2021-08-01/apiissue/method_update_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/apiissueattachment/method_createorupdate.go delete mode 100644 resource-manager/apimanagement/2021-08-01/apiissueattachment/method_createorupdate_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/apiissueattachment/method_delete.go delete mode 100644 resource-manager/apimanagement/2021-08-01/apiissueattachment/method_delete_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/apiissueattachment/method_get.go delete mode 100644 resource-manager/apimanagement/2021-08-01/apiissueattachment/method_get_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/apiissueattachment/method_getentitytag.go delete mode 100644 resource-manager/apimanagement/2021-08-01/apiissueattachment/method_getentitytag_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/apiissueattachment/method_listbyservice.go delete mode 100644 resource-manager/apimanagement/2021-08-01/apiissueattachment/method_listbyservice_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/apiissuecomment/method_createorupdate.go delete mode 100644 resource-manager/apimanagement/2021-08-01/apiissuecomment/method_createorupdate_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/apiissuecomment/method_delete.go delete mode 100644 resource-manager/apimanagement/2021-08-01/apiissuecomment/method_delete_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/apiissuecomment/method_get.go delete mode 100644 resource-manager/apimanagement/2021-08-01/apiissuecomment/method_get_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/apiissuecomment/method_getentitytag.go delete mode 100644 resource-manager/apimanagement/2021-08-01/apiissuecomment/method_getentitytag_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/apiissuecomment/method_listbyservice.go delete mode 100644 resource-manager/apimanagement/2021-08-01/apiissuecomment/method_listbyservice_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/apimanagementservice/method_applynetworkconfigurationupdates.go delete mode 100644 resource-manager/apimanagement/2021-08-01/apimanagementservice/method_applynetworkconfigurationupdates_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/apimanagementservice/method_backup.go delete mode 100644 resource-manager/apimanagement/2021-08-01/apimanagementservice/method_backup_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/apimanagementservice/method_checknameavailability.go delete mode 100644 resource-manager/apimanagement/2021-08-01/apimanagementservice/method_checknameavailability_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/apimanagementservice/method_createorupdate.go delete mode 100644 resource-manager/apimanagement/2021-08-01/apimanagementservice/method_createorupdate_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/apimanagementservice/method_delete.go delete mode 100644 resource-manager/apimanagement/2021-08-01/apimanagementservice/method_delete_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/apimanagementservice/method_get.go delete mode 100644 resource-manager/apimanagement/2021-08-01/apimanagementservice/method_get_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/apimanagementservice/method_getdomainownershipidentifier.go delete mode 100644 resource-manager/apimanagement/2021-08-01/apimanagementservice/method_getdomainownershipidentifier_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/apimanagementservice/method_getssotoken.go delete mode 100644 resource-manager/apimanagement/2021-08-01/apimanagementservice/method_getssotoken_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/apimanagementservice/method_list.go delete mode 100644 resource-manager/apimanagement/2021-08-01/apimanagementservice/method_list_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/apimanagementservice/method_listbyresourcegroup.go delete mode 100644 resource-manager/apimanagement/2021-08-01/apimanagementservice/method_listbyresourcegroup_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/apimanagementservice/method_restore.go delete mode 100644 resource-manager/apimanagement/2021-08-01/apimanagementservice/method_restore_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/apimanagementservice/method_update.go delete mode 100644 resource-manager/apimanagement/2021-08-01/apimanagementservice/method_update_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/apimanagementserviceskus/method_listavailableserviceskus.go delete mode 100644 resource-manager/apimanagement/2021-08-01/apimanagementserviceskus/method_listavailableserviceskus_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/apioperation/method_createorupdate.go delete mode 100644 resource-manager/apimanagement/2021-08-01/apioperation/method_createorupdate_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/apioperation/method_delete.go delete mode 100644 resource-manager/apimanagement/2021-08-01/apioperation/method_delete_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/apioperation/method_get.go delete mode 100644 resource-manager/apimanagement/2021-08-01/apioperation/method_get_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/apioperation/method_getentitytag.go delete mode 100644 resource-manager/apimanagement/2021-08-01/apioperation/method_getentitytag_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/apioperation/method_listbyapi.go delete mode 100644 resource-manager/apimanagement/2021-08-01/apioperation/method_listbyapi_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/apioperation/method_update.go delete mode 100644 resource-manager/apimanagement/2021-08-01/apioperation/method_update_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/apioperationpolicy/method_createorupdate.go delete mode 100644 resource-manager/apimanagement/2021-08-01/apioperationpolicy/method_createorupdate_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/apioperationpolicy/method_delete.go delete mode 100644 resource-manager/apimanagement/2021-08-01/apioperationpolicy/method_delete_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/apioperationpolicy/method_get.go delete mode 100644 resource-manager/apimanagement/2021-08-01/apioperationpolicy/method_get_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/apioperationpolicy/method_getentitytag.go delete mode 100644 resource-manager/apimanagement/2021-08-01/apioperationpolicy/method_getentitytag_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/apioperationpolicy/method_listbyoperation.go delete mode 100644 resource-manager/apimanagement/2021-08-01/apioperationpolicy/method_listbyoperation_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/apioperationsbytag/method_operationlistbytags.go delete mode 100644 resource-manager/apimanagement/2021-08-01/apioperationsbytag/method_operationlistbytags_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/apioperationtag/method_tagassigntooperation.go delete mode 100644 resource-manager/apimanagement/2021-08-01/apioperationtag/method_tagassigntooperation_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/apioperationtag/method_tagdetachfromoperation.go delete mode 100644 resource-manager/apimanagement/2021-08-01/apioperationtag/method_tagdetachfromoperation_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/apioperationtag/method_taggetbyoperation.go delete mode 100644 resource-manager/apimanagement/2021-08-01/apioperationtag/method_taggetbyoperation_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/apioperationtag/method_taggetentitystatebyoperation.go delete mode 100644 resource-manager/apimanagement/2021-08-01/apioperationtag/method_taggetentitystatebyoperation_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/apioperationtag/method_taglistbyoperation.go delete mode 100644 resource-manager/apimanagement/2021-08-01/apioperationtag/method_taglistbyoperation_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/apipolicy/method_createorupdate.go delete mode 100644 resource-manager/apimanagement/2021-08-01/apipolicy/method_createorupdate_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/apipolicy/method_delete.go delete mode 100644 resource-manager/apimanagement/2021-08-01/apipolicy/method_delete_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/apipolicy/method_get.go delete mode 100644 resource-manager/apimanagement/2021-08-01/apipolicy/method_get_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/apipolicy/method_getentitytag.go delete mode 100644 resource-manager/apimanagement/2021-08-01/apipolicy/method_getentitytag_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/apipolicy/method_listbyapi.go delete mode 100644 resource-manager/apimanagement/2021-08-01/apipolicy/method_listbyapi_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/apiproduct/method_listbyapis.go delete mode 100644 resource-manager/apimanagement/2021-08-01/apiproduct/method_listbyapis_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/apirelease/method_createorupdate.go delete mode 100644 resource-manager/apimanagement/2021-08-01/apirelease/method_createorupdate_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/apirelease/method_delete.go delete mode 100644 resource-manager/apimanagement/2021-08-01/apirelease/method_delete_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/apirelease/method_get.go delete mode 100644 resource-manager/apimanagement/2021-08-01/apirelease/method_get_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/apirelease/method_getentitytag.go delete mode 100644 resource-manager/apimanagement/2021-08-01/apirelease/method_getentitytag_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/apirelease/method_listbyservice.go delete mode 100644 resource-manager/apimanagement/2021-08-01/apirelease/method_listbyservice_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/apirelease/method_update.go delete mode 100644 resource-manager/apimanagement/2021-08-01/apirelease/method_update_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/apirevision/method_listbyservice.go delete mode 100644 resource-manager/apimanagement/2021-08-01/apirevision/method_listbyservice_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/apisbytag/method_apilistbytags.go delete mode 100644 resource-manager/apimanagement/2021-08-01/apisbytag/method_apilistbytags_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/apischema/method_createorupdate.go delete mode 100644 resource-manager/apimanagement/2021-08-01/apischema/method_createorupdate_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/apischema/method_delete.go delete mode 100644 resource-manager/apimanagement/2021-08-01/apischema/method_delete_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/apischema/method_get.go delete mode 100644 resource-manager/apimanagement/2021-08-01/apischema/method_get_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/apischema/method_getentitytag.go delete mode 100644 resource-manager/apimanagement/2021-08-01/apischema/method_getentitytag_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/apischema/method_listbyapi.go delete mode 100644 resource-manager/apimanagement/2021-08-01/apischema/method_listbyapi_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/apitag/method_tagassigntoapi.go delete mode 100644 resource-manager/apimanagement/2021-08-01/apitag/method_tagassigntoapi_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/apitag/method_tagdetachfromapi.go delete mode 100644 resource-manager/apimanagement/2021-08-01/apitag/method_tagdetachfromapi_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/apitag/method_taggetbyapi.go delete mode 100644 resource-manager/apimanagement/2021-08-01/apitag/method_taggetbyapi_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/apitag/method_taggetentitystatebyapi.go delete mode 100644 resource-manager/apimanagement/2021-08-01/apitag/method_taggetentitystatebyapi_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/apitag/method_taglistbyapi.go delete mode 100644 resource-manager/apimanagement/2021-08-01/apitag/method_taglistbyapi_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/apitagdescription/method_createorupdate.go delete mode 100644 resource-manager/apimanagement/2021-08-01/apitagdescription/method_createorupdate_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/apitagdescription/method_delete.go delete mode 100644 resource-manager/apimanagement/2021-08-01/apitagdescription/method_delete_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/apitagdescription/method_get.go delete mode 100644 resource-manager/apimanagement/2021-08-01/apitagdescription/method_get_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/apitagdescription/method_getentitytag.go delete mode 100644 resource-manager/apimanagement/2021-08-01/apitagdescription/method_getentitytag_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/apitagdescription/method_listbyservice.go delete mode 100644 resource-manager/apimanagement/2021-08-01/apitagdescription/method_listbyservice_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/apiversionset/method_createorupdate.go delete mode 100644 resource-manager/apimanagement/2021-08-01/apiversionset/method_createorupdate_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/apiversionset/method_get.go delete mode 100644 resource-manager/apimanagement/2021-08-01/apiversionset/method_get_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/apiversionset/method_getentitytag.go delete mode 100644 resource-manager/apimanagement/2021-08-01/apiversionset/method_getentitytag_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/apiversionset/method_listbyservice.go delete mode 100644 resource-manager/apimanagement/2021-08-01/apiversionset/method_listbyservice_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/apiversionset/method_update.go delete mode 100644 resource-manager/apimanagement/2021-08-01/apiversionset/method_update_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/apiversionsets/method_apiversionsetdelete.go delete mode 100644 resource-manager/apimanagement/2021-08-01/apiversionsets/method_apiversionsetdelete_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/authorizationserver/method_createorupdate.go delete mode 100644 resource-manager/apimanagement/2021-08-01/authorizationserver/method_createorupdate_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/authorizationserver/method_delete.go delete mode 100644 resource-manager/apimanagement/2021-08-01/authorizationserver/method_delete_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/authorizationserver/method_get.go delete mode 100644 resource-manager/apimanagement/2021-08-01/authorizationserver/method_get_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/authorizationserver/method_getentitytag.go delete mode 100644 resource-manager/apimanagement/2021-08-01/authorizationserver/method_getentitytag_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/authorizationserver/method_listbyservice.go delete mode 100644 resource-manager/apimanagement/2021-08-01/authorizationserver/method_listbyservice_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/authorizationserver/method_listsecrets.go delete mode 100644 resource-manager/apimanagement/2021-08-01/authorizationserver/method_listsecrets_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/authorizationserver/method_update.go delete mode 100644 resource-manager/apimanagement/2021-08-01/authorizationserver/method_update_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/backend/method_createorupdate.go delete mode 100644 resource-manager/apimanagement/2021-08-01/backend/method_createorupdate_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/backend/method_delete.go delete mode 100644 resource-manager/apimanagement/2021-08-01/backend/method_delete_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/backend/method_get.go delete mode 100644 resource-manager/apimanagement/2021-08-01/backend/method_get_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/backend/method_getentitytag.go delete mode 100644 resource-manager/apimanagement/2021-08-01/backend/method_getentitytag_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/backend/method_listbyservice.go delete mode 100644 resource-manager/apimanagement/2021-08-01/backend/method_listbyservice_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/backend/method_update.go delete mode 100644 resource-manager/apimanagement/2021-08-01/backend/method_update_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/backendreconnect/method_backendreconnect.go delete mode 100644 resource-manager/apimanagement/2021-08-01/backendreconnect/method_backendreconnect_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/cache/method_createorupdate.go delete mode 100644 resource-manager/apimanagement/2021-08-01/cache/method_createorupdate_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/cache/method_delete.go delete mode 100644 resource-manager/apimanagement/2021-08-01/cache/method_delete_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/cache/method_get.go delete mode 100644 resource-manager/apimanagement/2021-08-01/cache/method_get_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/cache/method_getentitytag.go delete mode 100644 resource-manager/apimanagement/2021-08-01/cache/method_getentitytag_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/cache/method_listbyservice.go delete mode 100644 resource-manager/apimanagement/2021-08-01/cache/method_listbyservice_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/cache/method_update.go delete mode 100644 resource-manager/apimanagement/2021-08-01/cache/method_update_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/certificate/method_createorupdate.go delete mode 100644 resource-manager/apimanagement/2021-08-01/certificate/method_createorupdate_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/certificate/method_delete.go delete mode 100644 resource-manager/apimanagement/2021-08-01/certificate/method_delete_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/certificate/method_get.go delete mode 100644 resource-manager/apimanagement/2021-08-01/certificate/method_get_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/certificate/method_getentitytag.go delete mode 100644 resource-manager/apimanagement/2021-08-01/certificate/method_getentitytag_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/certificate/method_listbyservice.go delete mode 100644 resource-manager/apimanagement/2021-08-01/certificate/method_listbyservice_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/certificate/method_refreshsecret.go delete mode 100644 resource-manager/apimanagement/2021-08-01/certificate/method_refreshsecret_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/contenttype/method_createorupdate.go delete mode 100644 resource-manager/apimanagement/2021-08-01/contenttype/method_createorupdate_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/contenttype/method_delete.go delete mode 100644 resource-manager/apimanagement/2021-08-01/contenttype/method_delete_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/contenttype/method_get.go delete mode 100644 resource-manager/apimanagement/2021-08-01/contenttype/method_get_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/contenttype/method_listbyservice.go delete mode 100644 resource-manager/apimanagement/2021-08-01/contenttype/method_listbyservice_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/contenttypecontentitem/method_contentitemcreateorupdate.go delete mode 100644 resource-manager/apimanagement/2021-08-01/contenttypecontentitem/method_contentitemcreateorupdate_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/contenttypecontentitem/method_contentitemdelete.go delete mode 100644 resource-manager/apimanagement/2021-08-01/contenttypecontentitem/method_contentitemdelete_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/contenttypecontentitem/method_contentitemget.go delete mode 100644 resource-manager/apimanagement/2021-08-01/contenttypecontentitem/method_contentitemget_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/contenttypecontentitem/method_contentitemgetentitytag.go delete mode 100644 resource-manager/apimanagement/2021-08-01/contenttypecontentitem/method_contentitemgetentitytag_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/contenttypecontentitem/method_contentitemlistbyservice.go delete mode 100644 resource-manager/apimanagement/2021-08-01/contenttypecontentitem/method_contentitemlistbyservice_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/delegationsettings/method_createorupdate.go delete mode 100644 resource-manager/apimanagement/2021-08-01/delegationsettings/method_createorupdate_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/delegationsettings/method_get.go delete mode 100644 resource-manager/apimanagement/2021-08-01/delegationsettings/method_get_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/delegationsettings/method_getentitytag.go delete mode 100644 resource-manager/apimanagement/2021-08-01/delegationsettings/method_getentitytag_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/delegationsettings/method_listsecrets.go delete mode 100644 resource-manager/apimanagement/2021-08-01/delegationsettings/method_listsecrets_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/delegationsettings/method_update.go delete mode 100644 resource-manager/apimanagement/2021-08-01/delegationsettings/method_update_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/deletedservice/method_getbyname.go delete mode 100644 resource-manager/apimanagement/2021-08-01/deletedservice/method_getbyname_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/deletedservice/method_listbysubscription.go delete mode 100644 resource-manager/apimanagement/2021-08-01/deletedservice/method_listbysubscription_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/deletedservice/method_purge.go delete mode 100644 resource-manager/apimanagement/2021-08-01/deletedservice/method_purge_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/diagnostic/method_createorupdate.go delete mode 100644 resource-manager/apimanagement/2021-08-01/diagnostic/method_createorupdate_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/diagnostic/method_delete.go delete mode 100644 resource-manager/apimanagement/2021-08-01/diagnostic/method_delete_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/diagnostic/method_get.go delete mode 100644 resource-manager/apimanagement/2021-08-01/diagnostic/method_get_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/diagnostic/method_getentitytag.go delete mode 100644 resource-manager/apimanagement/2021-08-01/diagnostic/method_getentitytag_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/diagnostic/method_listbyservice.go delete mode 100644 resource-manager/apimanagement/2021-08-01/diagnostic/method_listbyservice_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/diagnostic/method_update.go delete mode 100644 resource-manager/apimanagement/2021-08-01/diagnostic/method_update_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/emailtemplate/method_listbyservice.go delete mode 100644 resource-manager/apimanagement/2021-08-01/emailtemplate/method_listbyservice_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/emailtemplates/method_emailtemplatecreateorupdate.go delete mode 100644 resource-manager/apimanagement/2021-08-01/emailtemplates/method_emailtemplatecreateorupdate_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/emailtemplates/method_emailtemplatedelete.go delete mode 100644 resource-manager/apimanagement/2021-08-01/emailtemplates/method_emailtemplatedelete_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/emailtemplates/method_emailtemplateget.go delete mode 100644 resource-manager/apimanagement/2021-08-01/emailtemplates/method_emailtemplateget_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/emailtemplates/method_emailtemplategetentitytag.go delete mode 100644 resource-manager/apimanagement/2021-08-01/emailtemplates/method_emailtemplategetentitytag_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/emailtemplates/method_emailtemplateupdate.go delete mode 100644 resource-manager/apimanagement/2021-08-01/emailtemplates/method_emailtemplateupdate_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/gateway/method_createorupdate.go delete mode 100644 resource-manager/apimanagement/2021-08-01/gateway/method_createorupdate_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/gateway/method_delete.go delete mode 100644 resource-manager/apimanagement/2021-08-01/gateway/method_delete_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/gateway/method_get.go delete mode 100644 resource-manager/apimanagement/2021-08-01/gateway/method_get_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/gateway/method_getentitytag.go delete mode 100644 resource-manager/apimanagement/2021-08-01/gateway/method_getentitytag_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/gateway/method_listbyservice.go delete mode 100644 resource-manager/apimanagement/2021-08-01/gateway/method_listbyservice_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/gateway/method_update.go delete mode 100644 resource-manager/apimanagement/2021-08-01/gateway/method_update_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/gatewayapi/method_createorupdate.go delete mode 100644 resource-manager/apimanagement/2021-08-01/gatewayapi/method_createorupdate_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/gatewayapi/method_delete.go delete mode 100644 resource-manager/apimanagement/2021-08-01/gatewayapi/method_delete_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/gatewayapi/method_getentitytag.go delete mode 100644 resource-manager/apimanagement/2021-08-01/gatewayapi/method_getentitytag_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/gatewayapi/method_listbyservice.go delete mode 100644 resource-manager/apimanagement/2021-08-01/gatewayapi/method_listbyservice_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/gatewaycertificateauthority/method_createorupdate.go delete mode 100644 resource-manager/apimanagement/2021-08-01/gatewaycertificateauthority/method_createorupdate_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/gatewaycertificateauthority/method_delete.go delete mode 100644 resource-manager/apimanagement/2021-08-01/gatewaycertificateauthority/method_delete_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/gatewaycertificateauthority/method_get.go delete mode 100644 resource-manager/apimanagement/2021-08-01/gatewaycertificateauthority/method_get_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/gatewaycertificateauthority/method_getentitytag.go delete mode 100644 resource-manager/apimanagement/2021-08-01/gatewaycertificateauthority/method_getentitytag_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/gatewaycertificateauthority/method_listbyservice.go delete mode 100644 resource-manager/apimanagement/2021-08-01/gatewaycertificateauthority/method_listbyservice_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/gatewaygeneratetoken/method_gatewaygeneratetoken.go delete mode 100644 resource-manager/apimanagement/2021-08-01/gatewaygeneratetoken/method_gatewaygeneratetoken_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/gatewayhostnameconfiguration/method_createorupdate.go delete mode 100644 resource-manager/apimanagement/2021-08-01/gatewayhostnameconfiguration/method_createorupdate_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/gatewayhostnameconfiguration/method_delete.go delete mode 100644 resource-manager/apimanagement/2021-08-01/gatewayhostnameconfiguration/method_delete_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/gatewayhostnameconfiguration/method_get.go delete mode 100644 resource-manager/apimanagement/2021-08-01/gatewayhostnameconfiguration/method_get_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/gatewayhostnameconfiguration/method_getentitytag.go delete mode 100644 resource-manager/apimanagement/2021-08-01/gatewayhostnameconfiguration/method_getentitytag_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/gatewayhostnameconfiguration/method_listbyservice.go delete mode 100644 resource-manager/apimanagement/2021-08-01/gatewayhostnameconfiguration/method_listbyservice_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/gatewaylistkeys/method_gatewaylistkeys.go delete mode 100644 resource-manager/apimanagement/2021-08-01/gatewaylistkeys/method_gatewaylistkeys_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/gatewayregeneratekey/method_gatewayregeneratekey.go delete mode 100644 resource-manager/apimanagement/2021-08-01/gatewayregeneratekey/method_gatewayregeneratekey_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/group/method_createorupdate.go delete mode 100644 resource-manager/apimanagement/2021-08-01/group/method_createorupdate_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/group/method_delete.go delete mode 100644 resource-manager/apimanagement/2021-08-01/group/method_delete_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/group/method_get.go delete mode 100644 resource-manager/apimanagement/2021-08-01/group/method_get_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/group/method_getentitytag.go delete mode 100644 resource-manager/apimanagement/2021-08-01/group/method_getentitytag_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/group/method_listbyservice.go delete mode 100644 resource-manager/apimanagement/2021-08-01/group/method_listbyservice_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/group/method_update.go delete mode 100644 resource-manager/apimanagement/2021-08-01/group/method_update_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/groupuser/method_checkentityexists.go delete mode 100644 resource-manager/apimanagement/2021-08-01/groupuser/method_checkentityexists_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/groupuser/method_create.go delete mode 100644 resource-manager/apimanagement/2021-08-01/groupuser/method_create_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/groupuser/method_delete.go delete mode 100644 resource-manager/apimanagement/2021-08-01/groupuser/method_delete_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/groupuser/method_list.go delete mode 100644 resource-manager/apimanagement/2021-08-01/groupuser/method_list_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/identityprovider/method_createorupdate.go delete mode 100644 resource-manager/apimanagement/2021-08-01/identityprovider/method_createorupdate_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/identityprovider/method_delete.go delete mode 100644 resource-manager/apimanagement/2021-08-01/identityprovider/method_delete_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/identityprovider/method_get.go delete mode 100644 resource-manager/apimanagement/2021-08-01/identityprovider/method_get_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/identityprovider/method_getentitytag.go delete mode 100644 resource-manager/apimanagement/2021-08-01/identityprovider/method_getentitytag_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/identityprovider/method_listbyservice.go delete mode 100644 resource-manager/apimanagement/2021-08-01/identityprovider/method_listbyservice_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/identityprovider/method_listsecrets.go delete mode 100644 resource-manager/apimanagement/2021-08-01/identityprovider/method_listsecrets_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/identityprovider/method_update.go delete mode 100644 resource-manager/apimanagement/2021-08-01/identityprovider/method_update_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/issue/method_get.go delete mode 100644 resource-manager/apimanagement/2021-08-01/issue/method_get_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/issue/method_listbyservice.go delete mode 100644 resource-manager/apimanagement/2021-08-01/issue/method_listbyservice_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/logger/method_createorupdate.go delete mode 100644 resource-manager/apimanagement/2021-08-01/logger/method_createorupdate_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/logger/method_delete.go delete mode 100644 resource-manager/apimanagement/2021-08-01/logger/method_delete_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/logger/method_get.go delete mode 100644 resource-manager/apimanagement/2021-08-01/logger/method_get_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/logger/method_getentitytag.go delete mode 100644 resource-manager/apimanagement/2021-08-01/logger/method_getentitytag_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/logger/method_listbyservice.go delete mode 100644 resource-manager/apimanagement/2021-08-01/logger/method_listbyservice_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/logger/method_update.go delete mode 100644 resource-manager/apimanagement/2021-08-01/logger/method_update_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/namedvalue/method_createorupdate.go delete mode 100644 resource-manager/apimanagement/2021-08-01/namedvalue/method_createorupdate_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/namedvalue/method_delete.go delete mode 100644 resource-manager/apimanagement/2021-08-01/namedvalue/method_delete_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/namedvalue/method_get.go delete mode 100644 resource-manager/apimanagement/2021-08-01/namedvalue/method_get_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/namedvalue/method_getentitytag.go delete mode 100644 resource-manager/apimanagement/2021-08-01/namedvalue/method_getentitytag_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/namedvalue/method_listbyservice.go delete mode 100644 resource-manager/apimanagement/2021-08-01/namedvalue/method_listbyservice_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/namedvalue/method_listvalue.go delete mode 100644 resource-manager/apimanagement/2021-08-01/namedvalue/method_listvalue_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/namedvalue/method_refreshsecret.go delete mode 100644 resource-manager/apimanagement/2021-08-01/namedvalue/method_refreshsecret_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/namedvalue/method_update.go delete mode 100644 resource-manager/apimanagement/2021-08-01/namedvalue/method_update_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/networkstatus/method_listbylocation.go delete mode 100644 resource-manager/apimanagement/2021-08-01/networkstatus/method_listbylocation_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/networkstatus/method_listbyservice.go delete mode 100644 resource-manager/apimanagement/2021-08-01/networkstatus/method_listbyservice_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/notification/method_createorupdate.go delete mode 100644 resource-manager/apimanagement/2021-08-01/notification/method_createorupdate_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/notification/method_get.go delete mode 100644 resource-manager/apimanagement/2021-08-01/notification/method_get_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/notification/method_listbyservice.go delete mode 100644 resource-manager/apimanagement/2021-08-01/notification/method_listbyservice_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/notificationrecipientemail/method_checkentityexists.go delete mode 100644 resource-manager/apimanagement/2021-08-01/notificationrecipientemail/method_checkentityexists_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/notificationrecipientemail/method_createorupdate.go delete mode 100644 resource-manager/apimanagement/2021-08-01/notificationrecipientemail/method_createorupdate_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/notificationrecipientemail/method_delete.go delete mode 100644 resource-manager/apimanagement/2021-08-01/notificationrecipientemail/method_delete_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/notificationrecipientemail/method_listbynotification.go delete mode 100644 resource-manager/apimanagement/2021-08-01/notificationrecipientemail/method_listbynotification_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/notificationrecipientuser/method_checkentityexists.go delete mode 100644 resource-manager/apimanagement/2021-08-01/notificationrecipientuser/method_checkentityexists_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/notificationrecipientuser/method_createorupdate.go delete mode 100644 resource-manager/apimanagement/2021-08-01/notificationrecipientuser/method_createorupdate_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/notificationrecipientuser/method_delete.go delete mode 100644 resource-manager/apimanagement/2021-08-01/notificationrecipientuser/method_delete_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/notificationrecipientuser/method_listbynotification.go delete mode 100644 resource-manager/apimanagement/2021-08-01/notificationrecipientuser/method_listbynotification_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/openidconnectprovider/method_createorupdate.go delete mode 100644 resource-manager/apimanagement/2021-08-01/openidconnectprovider/method_createorupdate_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/openidconnectprovider/method_delete.go delete mode 100644 resource-manager/apimanagement/2021-08-01/openidconnectprovider/method_delete_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/openidconnectprovider/method_get.go delete mode 100644 resource-manager/apimanagement/2021-08-01/openidconnectprovider/method_get_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/openidconnectprovider/method_getentitytag.go delete mode 100644 resource-manager/apimanagement/2021-08-01/openidconnectprovider/method_getentitytag_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/openidconnectprovider/method_listbyservice.go delete mode 100644 resource-manager/apimanagement/2021-08-01/openidconnectprovider/method_listbyservice_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/openidconnectprovider/method_listsecrets.go delete mode 100644 resource-manager/apimanagement/2021-08-01/openidconnectprovider/method_listsecrets_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/openidconnectprovider/method_update.go delete mode 100644 resource-manager/apimanagement/2021-08-01/openidconnectprovider/method_update_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/outboundnetworkdependenciesendpoints/method_listbyservice.go delete mode 100644 resource-manager/apimanagement/2021-08-01/outboundnetworkdependenciesendpoints/method_listbyservice_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/performconnectivitycheck/method_async.go delete mode 100644 resource-manager/apimanagement/2021-08-01/performconnectivitycheck/method_async_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/policy/method_createorupdate.go delete mode 100644 resource-manager/apimanagement/2021-08-01/policy/method_createorupdate_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/policy/method_delete.go delete mode 100644 resource-manager/apimanagement/2021-08-01/policy/method_delete_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/policy/method_get.go delete mode 100644 resource-manager/apimanagement/2021-08-01/policy/method_get_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/policy/method_getentitytag.go delete mode 100644 resource-manager/apimanagement/2021-08-01/policy/method_getentitytag_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/policy/method_listbyservice.go delete mode 100644 resource-manager/apimanagement/2021-08-01/policy/method_listbyservice_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/policydescription/method_listbyservice.go delete mode 100644 resource-manager/apimanagement/2021-08-01/policydescription/method_listbyservice_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/portalrevision/method_createorupdate.go delete mode 100644 resource-manager/apimanagement/2021-08-01/portalrevision/method_createorupdate_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/portalrevision/method_get.go delete mode 100644 resource-manager/apimanagement/2021-08-01/portalrevision/method_get_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/portalrevision/method_getentitytag.go delete mode 100644 resource-manager/apimanagement/2021-08-01/portalrevision/method_getentitytag_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/portalrevision/method_listbyservice.go delete mode 100644 resource-manager/apimanagement/2021-08-01/portalrevision/method_listbyservice_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/portalrevision/method_update.go delete mode 100644 resource-manager/apimanagement/2021-08-01/portalrevision/method_update_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/portalsettings/method_listbyservice.go delete mode 100644 resource-manager/apimanagement/2021-08-01/portalsettings/method_listbyservice_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/privateendpointconnections/method_privateendpointconnectioncreateorupdate.go delete mode 100644 resource-manager/apimanagement/2021-08-01/privateendpointconnections/method_privateendpointconnectioncreateorupdate_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/privateendpointconnections/method_privateendpointconnectiondelete.go delete mode 100644 resource-manager/apimanagement/2021-08-01/privateendpointconnections/method_privateendpointconnectiondelete_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/privateendpointconnections/method_privateendpointconnectiongetbyname.go delete mode 100644 resource-manager/apimanagement/2021-08-01/privateendpointconnections/method_privateendpointconnectiongetbyname_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/privateendpointconnections/method_privateendpointconnectiongetprivatelinkresource.go delete mode 100644 resource-manager/apimanagement/2021-08-01/privateendpointconnections/method_privateendpointconnectiongetprivatelinkresource_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/privateendpointconnections/method_privateendpointconnectionlistbyservice.go delete mode 100644 resource-manager/apimanagement/2021-08-01/privateendpointconnections/method_privateendpointconnectionlistbyservice_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/privateendpointconnections/method_privateendpointconnectionlistprivatelinkresources.go delete mode 100644 resource-manager/apimanagement/2021-08-01/privateendpointconnections/method_privateendpointconnectionlistprivatelinkresources_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/product/method_createorupdate.go delete mode 100644 resource-manager/apimanagement/2021-08-01/product/method_createorupdate_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/product/method_delete.go delete mode 100644 resource-manager/apimanagement/2021-08-01/product/method_delete_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/product/method_get.go delete mode 100644 resource-manager/apimanagement/2021-08-01/product/method_get_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/product/method_getentitytag.go delete mode 100644 resource-manager/apimanagement/2021-08-01/product/method_getentitytag_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/product/method_listbyservice.go delete mode 100644 resource-manager/apimanagement/2021-08-01/product/method_listbyservice_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/product/method_update.go delete mode 100644 resource-manager/apimanagement/2021-08-01/product/method_update_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/productapi/method_checkentityexists.go delete mode 100644 resource-manager/apimanagement/2021-08-01/productapi/method_checkentityexists_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/productapi/method_createorupdate.go delete mode 100644 resource-manager/apimanagement/2021-08-01/productapi/method_createorupdate_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/productapi/method_delete.go delete mode 100644 resource-manager/apimanagement/2021-08-01/productapi/method_delete_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/productapi/method_listbyproduct.go delete mode 100644 resource-manager/apimanagement/2021-08-01/productapi/method_listbyproduct_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/productgroup/method_checkentityexists.go delete mode 100644 resource-manager/apimanagement/2021-08-01/productgroup/method_checkentityexists_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/productgroup/method_createorupdate.go delete mode 100644 resource-manager/apimanagement/2021-08-01/productgroup/method_createorupdate_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/productgroup/method_delete.go delete mode 100644 resource-manager/apimanagement/2021-08-01/productgroup/method_delete_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/productgroup/method_listbyproduct.go delete mode 100644 resource-manager/apimanagement/2021-08-01/productgroup/method_listbyproduct_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/productpolicy/method_createorupdate.go delete mode 100644 resource-manager/apimanagement/2021-08-01/productpolicy/method_createorupdate_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/productpolicy/method_delete.go delete mode 100644 resource-manager/apimanagement/2021-08-01/productpolicy/method_delete_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/productpolicy/method_get.go delete mode 100644 resource-manager/apimanagement/2021-08-01/productpolicy/method_get_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/productpolicy/method_getentitytag.go delete mode 100644 resource-manager/apimanagement/2021-08-01/productpolicy/method_getentitytag_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/productpolicy/method_listbyproduct.go delete mode 100644 resource-manager/apimanagement/2021-08-01/productpolicy/method_listbyproduct_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/productsbytag/method_productlistbytags.go delete mode 100644 resource-manager/apimanagement/2021-08-01/productsbytag/method_productlistbytags_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/productsubscription/method_list.go delete mode 100644 resource-manager/apimanagement/2021-08-01/productsubscription/method_list_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/producttag/method_tagassigntoproduct.go delete mode 100644 resource-manager/apimanagement/2021-08-01/producttag/method_tagassigntoproduct_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/producttag/method_tagdetachfromproduct.go delete mode 100644 resource-manager/apimanagement/2021-08-01/producttag/method_tagdetachfromproduct_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/producttag/method_taggetbyproduct.go delete mode 100644 resource-manager/apimanagement/2021-08-01/producttag/method_taggetbyproduct_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/producttag/method_taggetentitystatebyproduct.go delete mode 100644 resource-manager/apimanagement/2021-08-01/producttag/method_taggetentitystatebyproduct_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/producttag/method_taglistbyproduct.go delete mode 100644 resource-manager/apimanagement/2021-08-01/producttag/method_taglistbyproduct_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/quotabycounterkeys/method_listbyservice.go delete mode 100644 resource-manager/apimanagement/2021-08-01/quotabycounterkeys/method_listbyservice_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/quotabycounterkeys/method_update.go delete mode 100644 resource-manager/apimanagement/2021-08-01/quotabycounterkeys/method_update_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/quotabyperiodkeys/method_get.go delete mode 100644 resource-manager/apimanagement/2021-08-01/quotabyperiodkeys/method_get_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/quotabyperiodkeys/method_update.go delete mode 100644 resource-manager/apimanagement/2021-08-01/quotabyperiodkeys/method_update_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/region/method_listbyservice.go delete mode 100644 resource-manager/apimanagement/2021-08-01/region/method_listbyservice_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/reports/method_listbyapi.go delete mode 100644 resource-manager/apimanagement/2021-08-01/reports/method_listbyapi_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/reports/method_listbygeo.go delete mode 100644 resource-manager/apimanagement/2021-08-01/reports/method_listbygeo_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/reports/method_listbyoperation.go delete mode 100644 resource-manager/apimanagement/2021-08-01/reports/method_listbyoperation_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/reports/method_listbyproduct.go delete mode 100644 resource-manager/apimanagement/2021-08-01/reports/method_listbyproduct_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/reports/method_listbyrequest.go delete mode 100644 resource-manager/apimanagement/2021-08-01/reports/method_listbyrequest_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/reports/method_listbysubscription.go delete mode 100644 resource-manager/apimanagement/2021-08-01/reports/method_listbysubscription_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/reports/method_listbytime.go delete mode 100644 resource-manager/apimanagement/2021-08-01/reports/method_listbytime_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/reports/method_listbyuser.go delete mode 100644 resource-manager/apimanagement/2021-08-01/reports/method_listbyuser_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/schema/method_globalschemacreateorupdate.go delete mode 100644 resource-manager/apimanagement/2021-08-01/schema/method_globalschemacreateorupdate_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/schema/method_globalschemadelete.go delete mode 100644 resource-manager/apimanagement/2021-08-01/schema/method_globalschemadelete_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/schema/method_globalschemaget.go delete mode 100644 resource-manager/apimanagement/2021-08-01/schema/method_globalschemaget_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/schema/method_globalschemagetentitytag.go delete mode 100644 resource-manager/apimanagement/2021-08-01/schema/method_globalschemagetentitytag_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/schema/method_globalschemalistbyservice.go delete mode 100644 resource-manager/apimanagement/2021-08-01/schema/method_globalschemalistbyservice_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/signinsettings/method_createorupdate.go delete mode 100644 resource-manager/apimanagement/2021-08-01/signinsettings/method_createorupdate_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/signinsettings/method_get.go delete mode 100644 resource-manager/apimanagement/2021-08-01/signinsettings/method_get_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/signinsettings/method_getentitytag.go delete mode 100644 resource-manager/apimanagement/2021-08-01/signinsettings/method_getentitytag_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/signinsettings/method_update.go delete mode 100644 resource-manager/apimanagement/2021-08-01/signinsettings/method_update_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/signupsettings/method_createorupdate.go delete mode 100644 resource-manager/apimanagement/2021-08-01/signupsettings/method_createorupdate_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/signupsettings/method_get.go delete mode 100644 resource-manager/apimanagement/2021-08-01/signupsettings/method_get_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/signupsettings/method_getentitytag.go delete mode 100644 resource-manager/apimanagement/2021-08-01/signupsettings/method_getentitytag_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/signupsettings/method_update.go delete mode 100644 resource-manager/apimanagement/2021-08-01/signupsettings/method_update_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/skus/method_apimanagementskuslist.go delete mode 100644 resource-manager/apimanagement/2021-08-01/skus/method_apimanagementskuslist_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/subscription/method_createorupdate.go delete mode 100644 resource-manager/apimanagement/2021-08-01/subscription/method_createorupdate_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/subscription/method_delete.go delete mode 100644 resource-manager/apimanagement/2021-08-01/subscription/method_delete_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/subscription/method_get.go delete mode 100644 resource-manager/apimanagement/2021-08-01/subscription/method_get_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/subscription/method_getentitytag.go delete mode 100644 resource-manager/apimanagement/2021-08-01/subscription/method_getentitytag_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/subscription/method_list.go delete mode 100644 resource-manager/apimanagement/2021-08-01/subscription/method_list_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/subscription/method_listsecrets.go delete mode 100644 resource-manager/apimanagement/2021-08-01/subscription/method_listsecrets_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/subscription/method_regenerateprimarykey.go delete mode 100644 resource-manager/apimanagement/2021-08-01/subscription/method_regenerateprimarykey_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/subscription/method_regeneratesecondarykey.go delete mode 100644 resource-manager/apimanagement/2021-08-01/subscription/method_regeneratesecondarykey_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/subscription/method_update.go delete mode 100644 resource-manager/apimanagement/2021-08-01/subscription/method_update_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/subscription/method_usersubscriptionget.go delete mode 100644 resource-manager/apimanagement/2021-08-01/subscription/method_usersubscriptionget_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/tag/method_createorupdate.go delete mode 100644 resource-manager/apimanagement/2021-08-01/tag/method_createorupdate_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/tag/method_delete.go delete mode 100644 resource-manager/apimanagement/2021-08-01/tag/method_delete_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/tag/method_get.go delete mode 100644 resource-manager/apimanagement/2021-08-01/tag/method_get_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/tag/method_getentitystate.go delete mode 100644 resource-manager/apimanagement/2021-08-01/tag/method_getentitystate_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/tag/method_listbyservice.go delete mode 100644 resource-manager/apimanagement/2021-08-01/tag/method_listbyservice_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/tag/method_update.go delete mode 100644 resource-manager/apimanagement/2021-08-01/tag/method_update_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/tagresource/method_listbyservice.go delete mode 100644 resource-manager/apimanagement/2021-08-01/tagresource/method_listbyservice_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/tenantaccess/method_create.go delete mode 100644 resource-manager/apimanagement/2021-08-01/tenantaccess/method_create_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/tenantaccess/method_get.go delete mode 100644 resource-manager/apimanagement/2021-08-01/tenantaccess/method_get_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/tenantaccess/method_getentitytag.go delete mode 100644 resource-manager/apimanagement/2021-08-01/tenantaccess/method_getentitytag_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/tenantaccess/method_listbyservice.go delete mode 100644 resource-manager/apimanagement/2021-08-01/tenantaccess/method_listbyservice_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/tenantaccess/method_listsecrets.go delete mode 100644 resource-manager/apimanagement/2021-08-01/tenantaccess/method_listsecrets_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/tenantaccess/method_regenerateprimarykey.go delete mode 100644 resource-manager/apimanagement/2021-08-01/tenantaccess/method_regenerateprimarykey_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/tenantaccess/method_regeneratesecondarykey.go delete mode 100644 resource-manager/apimanagement/2021-08-01/tenantaccess/method_regeneratesecondarykey_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/tenantaccess/method_update.go delete mode 100644 resource-manager/apimanagement/2021-08-01/tenantaccess/method_update_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/tenantaccessgit/method_regenerateprimarykey.go delete mode 100644 resource-manager/apimanagement/2021-08-01/tenantaccessgit/method_regenerateprimarykey_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/tenantaccessgit/method_regeneratesecondarykey.go delete mode 100644 resource-manager/apimanagement/2021-08-01/tenantaccessgit/method_regeneratesecondarykey_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/tenantconfiguration/method_deploy.go delete mode 100644 resource-manager/apimanagement/2021-08-01/tenantconfiguration/method_deploy_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/tenantconfiguration/method_save.go delete mode 100644 resource-manager/apimanagement/2021-08-01/tenantconfiguration/method_save_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/tenantconfiguration/method_validate.go delete mode 100644 resource-manager/apimanagement/2021-08-01/tenantconfiguration/method_validate_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/tenantconfigurationsyncstate/method_tenantconfigurationgetsyncstate.go delete mode 100644 resource-manager/apimanagement/2021-08-01/tenantconfigurationsyncstate/method_tenantconfigurationgetsyncstate_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/tenantsettings/method_get.go delete mode 100644 resource-manager/apimanagement/2021-08-01/tenantsettings/method_get_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/tenantsettings/method_listbyservice.go delete mode 100644 resource-manager/apimanagement/2021-08-01/tenantsettings/method_listbyservice_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/user/method_createorupdate.go delete mode 100644 resource-manager/apimanagement/2021-08-01/user/method_createorupdate_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/user/method_delete.go delete mode 100644 resource-manager/apimanagement/2021-08-01/user/method_delete_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/user/method_get.go delete mode 100644 resource-manager/apimanagement/2021-08-01/user/method_get_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/user/method_getentitytag.go delete mode 100644 resource-manager/apimanagement/2021-08-01/user/method_getentitytag_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/user/method_listbyservice.go delete mode 100644 resource-manager/apimanagement/2021-08-01/user/method_listbyservice_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/user/method_update.go delete mode 100644 resource-manager/apimanagement/2021-08-01/user/method_update_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/userconfirmationpasswordsend/method_userconfirmationpasswordsend.go delete mode 100644 resource-manager/apimanagement/2021-08-01/userconfirmationpasswordsend/method_userconfirmationpasswordsend_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/usergroup/method_list.go delete mode 100644 resource-manager/apimanagement/2021-08-01/usergroup/method_list_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/useridentity/method_useridentitieslist.go delete mode 100644 resource-manager/apimanagement/2021-08-01/useridentity/method_useridentitieslist_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/users/method_usergeneratessourl.go delete mode 100644 resource-manager/apimanagement/2021-08-01/users/method_usergeneratessourl_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/usersubscription/method_list.go delete mode 100644 resource-manager/apimanagement/2021-08-01/usersubscription/method_list_autorest.go create mode 100644 resource-manager/apimanagement/2021-08-01/usertoken/method_usergetsharedaccesstoken.go delete mode 100644 resource-manager/apimanagement/2021-08-01/usertoken/method_usergetsharedaccesstoken_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/api/method_createorupdate.go delete mode 100644 resource-manager/apimanagement/2022-08-01/api/method_createorupdate_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/api/method_delete.go delete mode 100644 resource-manager/apimanagement/2022-08-01/api/method_delete_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/api/method_get.go delete mode 100644 resource-manager/apimanagement/2022-08-01/api/method_get_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/api/method_getentitytag.go delete mode 100644 resource-manager/apimanagement/2022-08-01/api/method_getentitytag_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/api/method_listbyservice.go delete mode 100644 resource-manager/apimanagement/2022-08-01/api/method_listbyservice_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/api/method_update.go delete mode 100644 resource-manager/apimanagement/2022-08-01/api/method_update_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/apidiagnostic/method_createorupdate.go delete mode 100644 resource-manager/apimanagement/2022-08-01/apidiagnostic/method_createorupdate_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/apidiagnostic/method_delete.go delete mode 100644 resource-manager/apimanagement/2022-08-01/apidiagnostic/method_delete_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/apidiagnostic/method_get.go delete mode 100644 resource-manager/apimanagement/2022-08-01/apidiagnostic/method_get_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/apidiagnostic/method_getentitytag.go delete mode 100644 resource-manager/apimanagement/2022-08-01/apidiagnostic/method_getentitytag_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/apidiagnostic/method_listbyservice.go delete mode 100644 resource-manager/apimanagement/2022-08-01/apidiagnostic/method_listbyservice_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/apidiagnostic/method_update.go delete mode 100644 resource-manager/apimanagement/2022-08-01/apidiagnostic/method_update_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/apiissue/method_createorupdate.go delete mode 100644 resource-manager/apimanagement/2022-08-01/apiissue/method_createorupdate_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/apiissue/method_delete.go delete mode 100644 resource-manager/apimanagement/2022-08-01/apiissue/method_delete_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/apiissue/method_get.go delete mode 100644 resource-manager/apimanagement/2022-08-01/apiissue/method_get_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/apiissue/method_getentitytag.go delete mode 100644 resource-manager/apimanagement/2022-08-01/apiissue/method_getentitytag_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/apiissue/method_listbyservice.go delete mode 100644 resource-manager/apimanagement/2022-08-01/apiissue/method_listbyservice_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/apiissue/method_update.go delete mode 100644 resource-manager/apimanagement/2022-08-01/apiissue/method_update_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/apiissueattachment/method_createorupdate.go delete mode 100644 resource-manager/apimanagement/2022-08-01/apiissueattachment/method_createorupdate_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/apiissueattachment/method_delete.go delete mode 100644 resource-manager/apimanagement/2022-08-01/apiissueattachment/method_delete_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/apiissueattachment/method_get.go delete mode 100644 resource-manager/apimanagement/2022-08-01/apiissueattachment/method_get_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/apiissueattachment/method_getentitytag.go delete mode 100644 resource-manager/apimanagement/2022-08-01/apiissueattachment/method_getentitytag_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/apiissueattachment/method_listbyservice.go delete mode 100644 resource-manager/apimanagement/2022-08-01/apiissueattachment/method_listbyservice_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/apiissuecomment/method_createorupdate.go delete mode 100644 resource-manager/apimanagement/2022-08-01/apiissuecomment/method_createorupdate_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/apiissuecomment/method_delete.go delete mode 100644 resource-manager/apimanagement/2022-08-01/apiissuecomment/method_delete_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/apiissuecomment/method_get.go delete mode 100644 resource-manager/apimanagement/2022-08-01/apiissuecomment/method_get_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/apiissuecomment/method_getentitytag.go delete mode 100644 resource-manager/apimanagement/2022-08-01/apiissuecomment/method_getentitytag_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/apiissuecomment/method_listbyservice.go delete mode 100644 resource-manager/apimanagement/2022-08-01/apiissuecomment/method_listbyservice_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/apimanagementservice/method_applynetworkconfigurationupdates.go delete mode 100644 resource-manager/apimanagement/2022-08-01/apimanagementservice/method_applynetworkconfigurationupdates_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/apimanagementservice/method_backup.go delete mode 100644 resource-manager/apimanagement/2022-08-01/apimanagementservice/method_backup_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/apimanagementservice/method_checknameavailability.go delete mode 100644 resource-manager/apimanagement/2022-08-01/apimanagementservice/method_checknameavailability_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/apimanagementservice/method_createorupdate.go delete mode 100644 resource-manager/apimanagement/2022-08-01/apimanagementservice/method_createorupdate_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/apimanagementservice/method_delete.go delete mode 100644 resource-manager/apimanagement/2022-08-01/apimanagementservice/method_delete_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/apimanagementservice/method_get.go delete mode 100644 resource-manager/apimanagement/2022-08-01/apimanagementservice/method_get_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/apimanagementservice/method_getdomainownershipidentifier.go delete mode 100644 resource-manager/apimanagement/2022-08-01/apimanagementservice/method_getdomainownershipidentifier_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/apimanagementservice/method_getssotoken.go delete mode 100644 resource-manager/apimanagement/2022-08-01/apimanagementservice/method_getssotoken_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/apimanagementservice/method_list.go delete mode 100644 resource-manager/apimanagement/2022-08-01/apimanagementservice/method_list_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/apimanagementservice/method_listbyresourcegroup.go delete mode 100644 resource-manager/apimanagement/2022-08-01/apimanagementservice/method_listbyresourcegroup_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/apimanagementservice/method_migratetostv2.go delete mode 100644 resource-manager/apimanagement/2022-08-01/apimanagementservice/method_migratetostv2_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/apimanagementservice/method_restore.go delete mode 100644 resource-manager/apimanagement/2022-08-01/apimanagementservice/method_restore_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/apimanagementservice/method_update.go delete mode 100644 resource-manager/apimanagement/2022-08-01/apimanagementservice/method_update_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/apimanagementserviceskus/method_listavailableserviceskus.go delete mode 100644 resource-manager/apimanagement/2022-08-01/apimanagementserviceskus/method_listavailableserviceskus_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/apioperation/method_createorupdate.go delete mode 100644 resource-manager/apimanagement/2022-08-01/apioperation/method_createorupdate_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/apioperation/method_delete.go delete mode 100644 resource-manager/apimanagement/2022-08-01/apioperation/method_delete_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/apioperation/method_get.go delete mode 100644 resource-manager/apimanagement/2022-08-01/apioperation/method_get_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/apioperation/method_getentitytag.go delete mode 100644 resource-manager/apimanagement/2022-08-01/apioperation/method_getentitytag_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/apioperation/method_listbyapi.go delete mode 100644 resource-manager/apimanagement/2022-08-01/apioperation/method_listbyapi_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/apioperation/method_update.go delete mode 100644 resource-manager/apimanagement/2022-08-01/apioperation/method_update_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/apioperationpolicy/method_createorupdate.go delete mode 100644 resource-manager/apimanagement/2022-08-01/apioperationpolicy/method_createorupdate_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/apioperationpolicy/method_delete.go delete mode 100644 resource-manager/apimanagement/2022-08-01/apioperationpolicy/method_delete_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/apioperationpolicy/method_get.go delete mode 100644 resource-manager/apimanagement/2022-08-01/apioperationpolicy/method_get_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/apioperationpolicy/method_getentitytag.go delete mode 100644 resource-manager/apimanagement/2022-08-01/apioperationpolicy/method_getentitytag_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/apioperationpolicy/method_listbyoperation.go delete mode 100644 resource-manager/apimanagement/2022-08-01/apioperationpolicy/method_listbyoperation_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/apioperationsbytag/method_operationlistbytags.go delete mode 100644 resource-manager/apimanagement/2022-08-01/apioperationsbytag/method_operationlistbytags_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/apioperationtag/method_tagassigntooperation.go delete mode 100644 resource-manager/apimanagement/2022-08-01/apioperationtag/method_tagassigntooperation_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/apioperationtag/method_tagdetachfromoperation.go delete mode 100644 resource-manager/apimanagement/2022-08-01/apioperationtag/method_tagdetachfromoperation_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/apioperationtag/method_taggetbyoperation.go delete mode 100644 resource-manager/apimanagement/2022-08-01/apioperationtag/method_taggetbyoperation_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/apioperationtag/method_taggetentitystatebyoperation.go delete mode 100644 resource-manager/apimanagement/2022-08-01/apioperationtag/method_taggetentitystatebyoperation_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/apioperationtag/method_taglistbyoperation.go delete mode 100644 resource-manager/apimanagement/2022-08-01/apioperationtag/method_taglistbyoperation_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/apipolicy/method_createorupdate.go delete mode 100644 resource-manager/apimanagement/2022-08-01/apipolicy/method_createorupdate_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/apipolicy/method_delete.go delete mode 100644 resource-manager/apimanagement/2022-08-01/apipolicy/method_delete_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/apipolicy/method_get.go delete mode 100644 resource-manager/apimanagement/2022-08-01/apipolicy/method_get_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/apipolicy/method_getentitytag.go delete mode 100644 resource-manager/apimanagement/2022-08-01/apipolicy/method_getentitytag_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/apipolicy/method_listbyapi.go delete mode 100644 resource-manager/apimanagement/2022-08-01/apipolicy/method_listbyapi_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/apiproduct/method_listbyapis.go delete mode 100644 resource-manager/apimanagement/2022-08-01/apiproduct/method_listbyapis_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/apirelease/method_createorupdate.go delete mode 100644 resource-manager/apimanagement/2022-08-01/apirelease/method_createorupdate_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/apirelease/method_delete.go delete mode 100644 resource-manager/apimanagement/2022-08-01/apirelease/method_delete_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/apirelease/method_get.go delete mode 100644 resource-manager/apimanagement/2022-08-01/apirelease/method_get_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/apirelease/method_getentitytag.go delete mode 100644 resource-manager/apimanagement/2022-08-01/apirelease/method_getentitytag_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/apirelease/method_listbyservice.go delete mode 100644 resource-manager/apimanagement/2022-08-01/apirelease/method_listbyservice_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/apirelease/method_update.go delete mode 100644 resource-manager/apimanagement/2022-08-01/apirelease/method_update_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/apirevision/method_listbyservice.go delete mode 100644 resource-manager/apimanagement/2022-08-01/apirevision/method_listbyservice_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/apisbytag/method_apilistbytags.go delete mode 100644 resource-manager/apimanagement/2022-08-01/apisbytag/method_apilistbytags_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/apischema/method_createorupdate.go delete mode 100644 resource-manager/apimanagement/2022-08-01/apischema/method_createorupdate_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/apischema/method_delete.go delete mode 100644 resource-manager/apimanagement/2022-08-01/apischema/method_delete_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/apischema/method_get.go delete mode 100644 resource-manager/apimanagement/2022-08-01/apischema/method_get_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/apischema/method_getentitytag.go delete mode 100644 resource-manager/apimanagement/2022-08-01/apischema/method_getentitytag_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/apischema/method_listbyapi.go delete mode 100644 resource-manager/apimanagement/2022-08-01/apischema/method_listbyapi_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/apitag/method_tagassigntoapi.go delete mode 100644 resource-manager/apimanagement/2022-08-01/apitag/method_tagassigntoapi_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/apitag/method_tagdetachfromapi.go delete mode 100644 resource-manager/apimanagement/2022-08-01/apitag/method_tagdetachfromapi_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/apitag/method_taggetbyapi.go delete mode 100644 resource-manager/apimanagement/2022-08-01/apitag/method_taggetbyapi_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/apitag/method_taggetentitystatebyapi.go delete mode 100644 resource-manager/apimanagement/2022-08-01/apitag/method_taggetentitystatebyapi_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/apitag/method_taglistbyapi.go delete mode 100644 resource-manager/apimanagement/2022-08-01/apitag/method_taglistbyapi_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/apitagdescription/method_createorupdate.go delete mode 100644 resource-manager/apimanagement/2022-08-01/apitagdescription/method_createorupdate_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/apitagdescription/method_delete.go delete mode 100644 resource-manager/apimanagement/2022-08-01/apitagdescription/method_delete_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/apitagdescription/method_get.go delete mode 100644 resource-manager/apimanagement/2022-08-01/apitagdescription/method_get_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/apitagdescription/method_getentitytag.go delete mode 100644 resource-manager/apimanagement/2022-08-01/apitagdescription/method_getentitytag_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/apitagdescription/method_listbyservice.go delete mode 100644 resource-manager/apimanagement/2022-08-01/apitagdescription/method_listbyservice_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/apiversionset/method_createorupdate.go delete mode 100644 resource-manager/apimanagement/2022-08-01/apiversionset/method_createorupdate_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/apiversionset/method_get.go delete mode 100644 resource-manager/apimanagement/2022-08-01/apiversionset/method_get_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/apiversionset/method_getentitytag.go delete mode 100644 resource-manager/apimanagement/2022-08-01/apiversionset/method_getentitytag_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/apiversionset/method_listbyservice.go delete mode 100644 resource-manager/apimanagement/2022-08-01/apiversionset/method_listbyservice_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/apiversionset/method_update.go delete mode 100644 resource-manager/apimanagement/2022-08-01/apiversionset/method_update_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/apiversionsets/method_apiversionsetdelete.go delete mode 100644 resource-manager/apimanagement/2022-08-01/apiversionsets/method_apiversionsetdelete_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/apiwiki/method_createorupdate.go delete mode 100644 resource-manager/apimanagement/2022-08-01/apiwiki/method_createorupdate_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/apiwiki/method_delete.go delete mode 100644 resource-manager/apimanagement/2022-08-01/apiwiki/method_delete_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/apiwiki/method_get.go delete mode 100644 resource-manager/apimanagement/2022-08-01/apiwiki/method_get_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/apiwiki/method_getentitytag.go delete mode 100644 resource-manager/apimanagement/2022-08-01/apiwiki/method_getentitytag_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/apiwiki/method_list.go delete mode 100644 resource-manager/apimanagement/2022-08-01/apiwiki/method_list_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/apiwiki/method_update.go delete mode 100644 resource-manager/apimanagement/2022-08-01/apiwiki/method_update_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/authorization/method_createorupdate.go delete mode 100644 resource-manager/apimanagement/2022-08-01/authorization/method_createorupdate_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/authorization/method_delete.go delete mode 100644 resource-manager/apimanagement/2022-08-01/authorization/method_delete_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/authorization/method_get.go delete mode 100644 resource-manager/apimanagement/2022-08-01/authorization/method_get_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/authorizationaccesspolicy/method_createorupdate.go delete mode 100644 resource-manager/apimanagement/2022-08-01/authorizationaccesspolicy/method_createorupdate_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/authorizationaccesspolicy/method_delete.go delete mode 100644 resource-manager/apimanagement/2022-08-01/authorizationaccesspolicy/method_delete_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/authorizationaccesspolicy/method_get.go delete mode 100644 resource-manager/apimanagement/2022-08-01/authorizationaccesspolicy/method_get_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/authorizationaccesspolicy/method_listbyauthorization.go delete mode 100644 resource-manager/apimanagement/2022-08-01/authorizationaccesspolicy/method_listbyauthorization_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/authorizationconfirmconsentcode/method_authorizationconfirmconsentcode.go delete mode 100644 resource-manager/apimanagement/2022-08-01/authorizationconfirmconsentcode/method_authorizationconfirmconsentcode_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/authorizationloginlinks/method_post.go delete mode 100644 resource-manager/apimanagement/2022-08-01/authorizationloginlinks/method_post_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/authorizationprovider/method_createorupdate.go delete mode 100644 resource-manager/apimanagement/2022-08-01/authorizationprovider/method_createorupdate_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/authorizationprovider/method_delete.go delete mode 100644 resource-manager/apimanagement/2022-08-01/authorizationprovider/method_delete_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/authorizationprovider/method_get.go delete mode 100644 resource-manager/apimanagement/2022-08-01/authorizationprovider/method_get_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/authorizationprovider/method_listbyservice.go delete mode 100644 resource-manager/apimanagement/2022-08-01/authorizationprovider/method_listbyservice_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/authorizations/method_authorizationlistbyauthorizationprovider.go delete mode 100644 resource-manager/apimanagement/2022-08-01/authorizations/method_authorizationlistbyauthorizationprovider_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/authorizationserver/method_createorupdate.go delete mode 100644 resource-manager/apimanagement/2022-08-01/authorizationserver/method_createorupdate_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/authorizationserver/method_delete.go delete mode 100644 resource-manager/apimanagement/2022-08-01/authorizationserver/method_delete_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/authorizationserver/method_get.go delete mode 100644 resource-manager/apimanagement/2022-08-01/authorizationserver/method_get_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/authorizationserver/method_getentitytag.go delete mode 100644 resource-manager/apimanagement/2022-08-01/authorizationserver/method_getentitytag_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/authorizationserver/method_listbyservice.go delete mode 100644 resource-manager/apimanagement/2022-08-01/authorizationserver/method_listbyservice_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/authorizationserver/method_listsecrets.go delete mode 100644 resource-manager/apimanagement/2022-08-01/authorizationserver/method_listsecrets_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/authorizationserver/method_update.go delete mode 100644 resource-manager/apimanagement/2022-08-01/authorizationserver/method_update_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/backend/method_createorupdate.go delete mode 100644 resource-manager/apimanagement/2022-08-01/backend/method_createorupdate_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/backend/method_delete.go delete mode 100644 resource-manager/apimanagement/2022-08-01/backend/method_delete_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/backend/method_get.go delete mode 100644 resource-manager/apimanagement/2022-08-01/backend/method_get_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/backend/method_getentitytag.go delete mode 100644 resource-manager/apimanagement/2022-08-01/backend/method_getentitytag_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/backend/method_listbyservice.go delete mode 100644 resource-manager/apimanagement/2022-08-01/backend/method_listbyservice_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/backend/method_update.go delete mode 100644 resource-manager/apimanagement/2022-08-01/backend/method_update_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/backendreconnect/method_backendreconnect.go delete mode 100644 resource-manager/apimanagement/2022-08-01/backendreconnect/method_backendreconnect_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/cache/method_createorupdate.go delete mode 100644 resource-manager/apimanagement/2022-08-01/cache/method_createorupdate_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/cache/method_delete.go delete mode 100644 resource-manager/apimanagement/2022-08-01/cache/method_delete_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/cache/method_get.go delete mode 100644 resource-manager/apimanagement/2022-08-01/cache/method_get_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/cache/method_getentitytag.go delete mode 100644 resource-manager/apimanagement/2022-08-01/cache/method_getentitytag_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/cache/method_listbyservice.go delete mode 100644 resource-manager/apimanagement/2022-08-01/cache/method_listbyservice_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/cache/method_update.go delete mode 100644 resource-manager/apimanagement/2022-08-01/cache/method_update_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/certificate/method_createorupdate.go delete mode 100644 resource-manager/apimanagement/2022-08-01/certificate/method_createorupdate_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/certificate/method_delete.go delete mode 100644 resource-manager/apimanagement/2022-08-01/certificate/method_delete_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/certificate/method_get.go delete mode 100644 resource-manager/apimanagement/2022-08-01/certificate/method_get_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/certificate/method_getentitytag.go delete mode 100644 resource-manager/apimanagement/2022-08-01/certificate/method_getentitytag_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/certificate/method_listbyservice.go delete mode 100644 resource-manager/apimanagement/2022-08-01/certificate/method_listbyservice_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/certificate/method_refreshsecret.go delete mode 100644 resource-manager/apimanagement/2022-08-01/certificate/method_refreshsecret_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/contenttype/method_createorupdate.go delete mode 100644 resource-manager/apimanagement/2022-08-01/contenttype/method_createorupdate_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/contenttype/method_delete.go delete mode 100644 resource-manager/apimanagement/2022-08-01/contenttype/method_delete_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/contenttype/method_get.go delete mode 100644 resource-manager/apimanagement/2022-08-01/contenttype/method_get_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/contenttype/method_listbyservice.go delete mode 100644 resource-manager/apimanagement/2022-08-01/contenttype/method_listbyservice_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/contenttypecontentitem/method_contentitemcreateorupdate.go delete mode 100644 resource-manager/apimanagement/2022-08-01/contenttypecontentitem/method_contentitemcreateorupdate_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/contenttypecontentitem/method_contentitemdelete.go delete mode 100644 resource-manager/apimanagement/2022-08-01/contenttypecontentitem/method_contentitemdelete_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/contenttypecontentitem/method_contentitemget.go delete mode 100644 resource-manager/apimanagement/2022-08-01/contenttypecontentitem/method_contentitemget_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/contenttypecontentitem/method_contentitemgetentitytag.go delete mode 100644 resource-manager/apimanagement/2022-08-01/contenttypecontentitem/method_contentitemgetentitytag_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/contenttypecontentitem/method_contentitemlistbyservice.go delete mode 100644 resource-manager/apimanagement/2022-08-01/contenttypecontentitem/method_contentitemlistbyservice_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/delegationsettings/method_createorupdate.go delete mode 100644 resource-manager/apimanagement/2022-08-01/delegationsettings/method_createorupdate_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/delegationsettings/method_get.go delete mode 100644 resource-manager/apimanagement/2022-08-01/delegationsettings/method_get_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/delegationsettings/method_getentitytag.go delete mode 100644 resource-manager/apimanagement/2022-08-01/delegationsettings/method_getentitytag_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/delegationsettings/method_listsecrets.go delete mode 100644 resource-manager/apimanagement/2022-08-01/delegationsettings/method_listsecrets_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/delegationsettings/method_update.go delete mode 100644 resource-manager/apimanagement/2022-08-01/delegationsettings/method_update_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/deletedservice/method_getbyname.go delete mode 100644 resource-manager/apimanagement/2022-08-01/deletedservice/method_getbyname_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/deletedservice/method_listbysubscription.go delete mode 100644 resource-manager/apimanagement/2022-08-01/deletedservice/method_listbysubscription_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/deletedservice/method_purge.go delete mode 100644 resource-manager/apimanagement/2022-08-01/deletedservice/method_purge_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/diagnostic/method_createorupdate.go delete mode 100644 resource-manager/apimanagement/2022-08-01/diagnostic/method_createorupdate_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/diagnostic/method_delete.go delete mode 100644 resource-manager/apimanagement/2022-08-01/diagnostic/method_delete_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/diagnostic/method_get.go delete mode 100644 resource-manager/apimanagement/2022-08-01/diagnostic/method_get_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/diagnostic/method_getentitytag.go delete mode 100644 resource-manager/apimanagement/2022-08-01/diagnostic/method_getentitytag_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/diagnostic/method_listbyservice.go delete mode 100644 resource-manager/apimanagement/2022-08-01/diagnostic/method_listbyservice_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/diagnostic/method_update.go delete mode 100644 resource-manager/apimanagement/2022-08-01/diagnostic/method_update_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/documentationresource/method_createorupdate.go delete mode 100644 resource-manager/apimanagement/2022-08-01/documentationresource/method_createorupdate_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/documentationresource/method_delete.go delete mode 100644 resource-manager/apimanagement/2022-08-01/documentationresource/method_delete_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/documentationresource/method_get.go delete mode 100644 resource-manager/apimanagement/2022-08-01/documentationresource/method_get_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/documentationresource/method_getentitytag.go delete mode 100644 resource-manager/apimanagement/2022-08-01/documentationresource/method_getentitytag_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/documentationresource/method_listbyservice.go delete mode 100644 resource-manager/apimanagement/2022-08-01/documentationresource/method_listbyservice_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/documentationresource/method_update.go delete mode 100644 resource-manager/apimanagement/2022-08-01/documentationresource/method_update_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/emailtemplate/method_listbyservice.go delete mode 100644 resource-manager/apimanagement/2022-08-01/emailtemplate/method_listbyservice_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/emailtemplates/method_emailtemplatecreateorupdate.go delete mode 100644 resource-manager/apimanagement/2022-08-01/emailtemplates/method_emailtemplatecreateorupdate_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/emailtemplates/method_emailtemplatedelete.go delete mode 100644 resource-manager/apimanagement/2022-08-01/emailtemplates/method_emailtemplatedelete_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/emailtemplates/method_emailtemplateget.go delete mode 100644 resource-manager/apimanagement/2022-08-01/emailtemplates/method_emailtemplateget_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/emailtemplates/method_emailtemplategetentitytag.go delete mode 100644 resource-manager/apimanagement/2022-08-01/emailtemplates/method_emailtemplategetentitytag_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/emailtemplates/method_emailtemplateupdate.go delete mode 100644 resource-manager/apimanagement/2022-08-01/emailtemplates/method_emailtemplateupdate_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/gateway/method_createorupdate.go delete mode 100644 resource-manager/apimanagement/2022-08-01/gateway/method_createorupdate_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/gateway/method_delete.go delete mode 100644 resource-manager/apimanagement/2022-08-01/gateway/method_delete_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/gateway/method_get.go delete mode 100644 resource-manager/apimanagement/2022-08-01/gateway/method_get_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/gateway/method_getentitytag.go delete mode 100644 resource-manager/apimanagement/2022-08-01/gateway/method_getentitytag_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/gateway/method_listbyservice.go delete mode 100644 resource-manager/apimanagement/2022-08-01/gateway/method_listbyservice_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/gateway/method_update.go delete mode 100644 resource-manager/apimanagement/2022-08-01/gateway/method_update_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/gatewayapi/method_createorupdate.go delete mode 100644 resource-manager/apimanagement/2022-08-01/gatewayapi/method_createorupdate_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/gatewayapi/method_delete.go delete mode 100644 resource-manager/apimanagement/2022-08-01/gatewayapi/method_delete_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/gatewayapi/method_getentitytag.go delete mode 100644 resource-manager/apimanagement/2022-08-01/gatewayapi/method_getentitytag_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/gatewayapi/method_listbyservice.go delete mode 100644 resource-manager/apimanagement/2022-08-01/gatewayapi/method_listbyservice_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/gatewaycertificateauthority/method_createorupdate.go delete mode 100644 resource-manager/apimanagement/2022-08-01/gatewaycertificateauthority/method_createorupdate_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/gatewaycertificateauthority/method_delete.go delete mode 100644 resource-manager/apimanagement/2022-08-01/gatewaycertificateauthority/method_delete_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/gatewaycertificateauthority/method_get.go delete mode 100644 resource-manager/apimanagement/2022-08-01/gatewaycertificateauthority/method_get_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/gatewaycertificateauthority/method_getentitytag.go delete mode 100644 resource-manager/apimanagement/2022-08-01/gatewaycertificateauthority/method_getentitytag_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/gatewaycertificateauthority/method_listbyservice.go delete mode 100644 resource-manager/apimanagement/2022-08-01/gatewaycertificateauthority/method_listbyservice_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/gatewaygeneratetoken/method_gatewaygeneratetoken.go delete mode 100644 resource-manager/apimanagement/2022-08-01/gatewaygeneratetoken/method_gatewaygeneratetoken_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/gatewayhostnameconfiguration/method_createorupdate.go delete mode 100644 resource-manager/apimanagement/2022-08-01/gatewayhostnameconfiguration/method_createorupdate_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/gatewayhostnameconfiguration/method_delete.go delete mode 100644 resource-manager/apimanagement/2022-08-01/gatewayhostnameconfiguration/method_delete_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/gatewayhostnameconfiguration/method_get.go delete mode 100644 resource-manager/apimanagement/2022-08-01/gatewayhostnameconfiguration/method_get_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/gatewayhostnameconfiguration/method_getentitytag.go delete mode 100644 resource-manager/apimanagement/2022-08-01/gatewayhostnameconfiguration/method_getentitytag_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/gatewayhostnameconfiguration/method_listbyservice.go delete mode 100644 resource-manager/apimanagement/2022-08-01/gatewayhostnameconfiguration/method_listbyservice_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/gatewaylistkeys/method_gatewaylistkeys.go delete mode 100644 resource-manager/apimanagement/2022-08-01/gatewaylistkeys/method_gatewaylistkeys_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/gatewayregeneratekey/method_gatewayregeneratekey.go delete mode 100644 resource-manager/apimanagement/2022-08-01/gatewayregeneratekey/method_gatewayregeneratekey_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/graphqlapiresolver/method_createorupdate.go delete mode 100644 resource-manager/apimanagement/2022-08-01/graphqlapiresolver/method_createorupdate_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/graphqlapiresolver/method_delete.go delete mode 100644 resource-manager/apimanagement/2022-08-01/graphqlapiresolver/method_delete_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/graphqlapiresolver/method_get.go delete mode 100644 resource-manager/apimanagement/2022-08-01/graphqlapiresolver/method_get_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/graphqlapiresolver/method_getentitytag.go delete mode 100644 resource-manager/apimanagement/2022-08-01/graphqlapiresolver/method_getentitytag_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/graphqlapiresolver/method_listbyapi.go delete mode 100644 resource-manager/apimanagement/2022-08-01/graphqlapiresolver/method_listbyapi_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/graphqlapiresolver/method_update.go delete mode 100644 resource-manager/apimanagement/2022-08-01/graphqlapiresolver/method_update_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/graphqlapiresolverpolicy/method_createorupdate.go delete mode 100644 resource-manager/apimanagement/2022-08-01/graphqlapiresolverpolicy/method_createorupdate_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/graphqlapiresolverpolicy/method_delete.go delete mode 100644 resource-manager/apimanagement/2022-08-01/graphqlapiresolverpolicy/method_delete_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/graphqlapiresolverpolicy/method_get.go delete mode 100644 resource-manager/apimanagement/2022-08-01/graphqlapiresolverpolicy/method_get_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/graphqlapiresolverpolicy/method_getentitytag.go delete mode 100644 resource-manager/apimanagement/2022-08-01/graphqlapiresolverpolicy/method_getentitytag_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/graphqlapiresolverpolicy/method_listbyresolver.go delete mode 100644 resource-manager/apimanagement/2022-08-01/graphqlapiresolverpolicy/method_listbyresolver_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/group/method_createorupdate.go delete mode 100644 resource-manager/apimanagement/2022-08-01/group/method_createorupdate_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/group/method_delete.go delete mode 100644 resource-manager/apimanagement/2022-08-01/group/method_delete_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/group/method_get.go delete mode 100644 resource-manager/apimanagement/2022-08-01/group/method_get_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/group/method_getentitytag.go delete mode 100644 resource-manager/apimanagement/2022-08-01/group/method_getentitytag_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/group/method_listbyservice.go delete mode 100644 resource-manager/apimanagement/2022-08-01/group/method_listbyservice_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/group/method_update.go delete mode 100644 resource-manager/apimanagement/2022-08-01/group/method_update_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/groupuser/method_checkentityexists.go delete mode 100644 resource-manager/apimanagement/2022-08-01/groupuser/method_checkentityexists_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/groupuser/method_create.go delete mode 100644 resource-manager/apimanagement/2022-08-01/groupuser/method_create_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/groupuser/method_delete.go delete mode 100644 resource-manager/apimanagement/2022-08-01/groupuser/method_delete_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/groupuser/method_list.go delete mode 100644 resource-manager/apimanagement/2022-08-01/groupuser/method_list_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/identityprovider/method_createorupdate.go delete mode 100644 resource-manager/apimanagement/2022-08-01/identityprovider/method_createorupdate_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/identityprovider/method_delete.go delete mode 100644 resource-manager/apimanagement/2022-08-01/identityprovider/method_delete_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/identityprovider/method_get.go delete mode 100644 resource-manager/apimanagement/2022-08-01/identityprovider/method_get_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/identityprovider/method_getentitytag.go delete mode 100644 resource-manager/apimanagement/2022-08-01/identityprovider/method_getentitytag_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/identityprovider/method_listbyservice.go delete mode 100644 resource-manager/apimanagement/2022-08-01/identityprovider/method_listbyservice_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/identityprovider/method_listsecrets.go delete mode 100644 resource-manager/apimanagement/2022-08-01/identityprovider/method_listsecrets_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/identityprovider/method_update.go delete mode 100644 resource-manager/apimanagement/2022-08-01/identityprovider/method_update_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/issue/method_get.go delete mode 100644 resource-manager/apimanagement/2022-08-01/issue/method_get_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/issue/method_listbyservice.go delete mode 100644 resource-manager/apimanagement/2022-08-01/issue/method_listbyservice_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/logger/method_createorupdate.go delete mode 100644 resource-manager/apimanagement/2022-08-01/logger/method_createorupdate_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/logger/method_delete.go delete mode 100644 resource-manager/apimanagement/2022-08-01/logger/method_delete_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/logger/method_get.go delete mode 100644 resource-manager/apimanagement/2022-08-01/logger/method_get_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/logger/method_getentitytag.go delete mode 100644 resource-manager/apimanagement/2022-08-01/logger/method_getentitytag_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/logger/method_listbyservice.go delete mode 100644 resource-manager/apimanagement/2022-08-01/logger/method_listbyservice_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/logger/method_update.go delete mode 100644 resource-manager/apimanagement/2022-08-01/logger/method_update_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/namedvalue/method_createorupdate.go delete mode 100644 resource-manager/apimanagement/2022-08-01/namedvalue/method_createorupdate_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/namedvalue/method_delete.go delete mode 100644 resource-manager/apimanagement/2022-08-01/namedvalue/method_delete_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/namedvalue/method_get.go delete mode 100644 resource-manager/apimanagement/2022-08-01/namedvalue/method_get_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/namedvalue/method_getentitytag.go delete mode 100644 resource-manager/apimanagement/2022-08-01/namedvalue/method_getentitytag_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/namedvalue/method_listbyservice.go delete mode 100644 resource-manager/apimanagement/2022-08-01/namedvalue/method_listbyservice_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/namedvalue/method_listvalue.go delete mode 100644 resource-manager/apimanagement/2022-08-01/namedvalue/method_listvalue_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/namedvalue/method_refreshsecret.go delete mode 100644 resource-manager/apimanagement/2022-08-01/namedvalue/method_refreshsecret_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/namedvalue/method_update.go delete mode 100644 resource-manager/apimanagement/2022-08-01/namedvalue/method_update_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/networkstatus/method_listbylocation.go delete mode 100644 resource-manager/apimanagement/2022-08-01/networkstatus/method_listbylocation_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/networkstatus/method_listbyservice.go delete mode 100644 resource-manager/apimanagement/2022-08-01/networkstatus/method_listbyservice_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/notification/method_createorupdate.go delete mode 100644 resource-manager/apimanagement/2022-08-01/notification/method_createorupdate_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/notification/method_get.go delete mode 100644 resource-manager/apimanagement/2022-08-01/notification/method_get_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/notification/method_listbyservice.go delete mode 100644 resource-manager/apimanagement/2022-08-01/notification/method_listbyservice_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/notificationrecipientemail/method_checkentityexists.go delete mode 100644 resource-manager/apimanagement/2022-08-01/notificationrecipientemail/method_checkentityexists_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/notificationrecipientemail/method_createorupdate.go delete mode 100644 resource-manager/apimanagement/2022-08-01/notificationrecipientemail/method_createorupdate_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/notificationrecipientemail/method_delete.go delete mode 100644 resource-manager/apimanagement/2022-08-01/notificationrecipientemail/method_delete_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/notificationrecipientemail/method_listbynotification.go delete mode 100644 resource-manager/apimanagement/2022-08-01/notificationrecipientemail/method_listbynotification_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/notificationrecipientuser/method_checkentityexists.go delete mode 100644 resource-manager/apimanagement/2022-08-01/notificationrecipientuser/method_checkentityexists_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/notificationrecipientuser/method_createorupdate.go delete mode 100644 resource-manager/apimanagement/2022-08-01/notificationrecipientuser/method_createorupdate_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/notificationrecipientuser/method_delete.go delete mode 100644 resource-manager/apimanagement/2022-08-01/notificationrecipientuser/method_delete_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/notificationrecipientuser/method_listbynotification.go delete mode 100644 resource-manager/apimanagement/2022-08-01/notificationrecipientuser/method_listbynotification_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/openidconnectprovider/method_createorupdate.go delete mode 100644 resource-manager/apimanagement/2022-08-01/openidconnectprovider/method_createorupdate_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/openidconnectprovider/method_delete.go delete mode 100644 resource-manager/apimanagement/2022-08-01/openidconnectprovider/method_delete_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/openidconnectprovider/method_get.go delete mode 100644 resource-manager/apimanagement/2022-08-01/openidconnectprovider/method_get_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/openidconnectprovider/method_getentitytag.go delete mode 100644 resource-manager/apimanagement/2022-08-01/openidconnectprovider/method_getentitytag_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/openidconnectprovider/method_listbyservice.go delete mode 100644 resource-manager/apimanagement/2022-08-01/openidconnectprovider/method_listbyservice_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/openidconnectprovider/method_listsecrets.go delete mode 100644 resource-manager/apimanagement/2022-08-01/openidconnectprovider/method_listsecrets_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/openidconnectprovider/method_update.go delete mode 100644 resource-manager/apimanagement/2022-08-01/openidconnectprovider/method_update_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/outboundnetworkdependenciesendpoints/method_listbyservice.go delete mode 100644 resource-manager/apimanagement/2022-08-01/outboundnetworkdependenciesendpoints/method_listbyservice_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/performconnectivitycheck/method_async.go delete mode 100644 resource-manager/apimanagement/2022-08-01/performconnectivitycheck/method_async_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/policy/method_createorupdate.go delete mode 100644 resource-manager/apimanagement/2022-08-01/policy/method_createorupdate_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/policy/method_delete.go delete mode 100644 resource-manager/apimanagement/2022-08-01/policy/method_delete_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/policy/method_get.go delete mode 100644 resource-manager/apimanagement/2022-08-01/policy/method_get_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/policy/method_getentitytag.go delete mode 100644 resource-manager/apimanagement/2022-08-01/policy/method_getentitytag_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/policy/method_listbyservice.go delete mode 100644 resource-manager/apimanagement/2022-08-01/policy/method_listbyservice_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/policydescription/method_listbyservice.go delete mode 100644 resource-manager/apimanagement/2022-08-01/policydescription/method_listbyservice_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/policyfragment/method_createorupdate.go delete mode 100644 resource-manager/apimanagement/2022-08-01/policyfragment/method_createorupdate_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/policyfragment/method_delete.go delete mode 100644 resource-manager/apimanagement/2022-08-01/policyfragment/method_delete_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/policyfragment/method_get.go delete mode 100644 resource-manager/apimanagement/2022-08-01/policyfragment/method_get_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/policyfragment/method_getentitytag.go delete mode 100644 resource-manager/apimanagement/2022-08-01/policyfragment/method_getentitytag_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/policyfragment/method_listbyservice.go delete mode 100644 resource-manager/apimanagement/2022-08-01/policyfragment/method_listbyservice_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/policyfragment/method_listreferences.go delete mode 100644 resource-manager/apimanagement/2022-08-01/policyfragment/method_listreferences_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/portalconfig/method_createorupdate.go delete mode 100644 resource-manager/apimanagement/2022-08-01/portalconfig/method_createorupdate_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/portalconfig/method_get.go delete mode 100644 resource-manager/apimanagement/2022-08-01/portalconfig/method_get_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/portalconfig/method_getentitytag.go delete mode 100644 resource-manager/apimanagement/2022-08-01/portalconfig/method_getentitytag_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/portalconfig/method_listbyservice.go delete mode 100644 resource-manager/apimanagement/2022-08-01/portalconfig/method_listbyservice_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/portalconfig/method_update.go delete mode 100644 resource-manager/apimanagement/2022-08-01/portalconfig/method_update_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/portalrevision/method_createorupdate.go delete mode 100644 resource-manager/apimanagement/2022-08-01/portalrevision/method_createorupdate_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/portalrevision/method_get.go delete mode 100644 resource-manager/apimanagement/2022-08-01/portalrevision/method_get_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/portalrevision/method_getentitytag.go delete mode 100644 resource-manager/apimanagement/2022-08-01/portalrevision/method_getentitytag_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/portalrevision/method_listbyservice.go delete mode 100644 resource-manager/apimanagement/2022-08-01/portalrevision/method_listbyservice_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/portalrevision/method_update.go delete mode 100644 resource-manager/apimanagement/2022-08-01/portalrevision/method_update_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/portalsettings/method_listbyservice.go delete mode 100644 resource-manager/apimanagement/2022-08-01/portalsettings/method_listbyservice_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/privateendpointconnections/method_privateendpointconnectioncreateorupdate.go delete mode 100644 resource-manager/apimanagement/2022-08-01/privateendpointconnections/method_privateendpointconnectioncreateorupdate_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/privateendpointconnections/method_privateendpointconnectiondelete.go delete mode 100644 resource-manager/apimanagement/2022-08-01/privateendpointconnections/method_privateendpointconnectiondelete_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/privateendpointconnections/method_privateendpointconnectiongetbyname.go delete mode 100644 resource-manager/apimanagement/2022-08-01/privateendpointconnections/method_privateendpointconnectiongetbyname_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/privateendpointconnections/method_privateendpointconnectiongetprivatelinkresource.go delete mode 100644 resource-manager/apimanagement/2022-08-01/privateendpointconnections/method_privateendpointconnectiongetprivatelinkresource_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/privateendpointconnections/method_privateendpointconnectionlistbyservice.go delete mode 100644 resource-manager/apimanagement/2022-08-01/privateendpointconnections/method_privateendpointconnectionlistbyservice_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/privateendpointconnections/method_privateendpointconnectionlistprivatelinkresources.go delete mode 100644 resource-manager/apimanagement/2022-08-01/privateendpointconnections/method_privateendpointconnectionlistprivatelinkresources_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/product/method_createorupdate.go delete mode 100644 resource-manager/apimanagement/2022-08-01/product/method_createorupdate_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/product/method_delete.go delete mode 100644 resource-manager/apimanagement/2022-08-01/product/method_delete_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/product/method_get.go delete mode 100644 resource-manager/apimanagement/2022-08-01/product/method_get_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/product/method_getentitytag.go delete mode 100644 resource-manager/apimanagement/2022-08-01/product/method_getentitytag_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/product/method_listbyservice.go delete mode 100644 resource-manager/apimanagement/2022-08-01/product/method_listbyservice_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/product/method_update.go delete mode 100644 resource-manager/apimanagement/2022-08-01/product/method_update_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/productapi/method_checkentityexists.go delete mode 100644 resource-manager/apimanagement/2022-08-01/productapi/method_checkentityexists_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/productapi/method_createorupdate.go delete mode 100644 resource-manager/apimanagement/2022-08-01/productapi/method_createorupdate_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/productapi/method_delete.go delete mode 100644 resource-manager/apimanagement/2022-08-01/productapi/method_delete_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/productapi/method_listbyproduct.go delete mode 100644 resource-manager/apimanagement/2022-08-01/productapi/method_listbyproduct_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/productgroup/method_checkentityexists.go delete mode 100644 resource-manager/apimanagement/2022-08-01/productgroup/method_checkentityexists_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/productgroup/method_createorupdate.go delete mode 100644 resource-manager/apimanagement/2022-08-01/productgroup/method_createorupdate_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/productgroup/method_delete.go delete mode 100644 resource-manager/apimanagement/2022-08-01/productgroup/method_delete_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/productgroup/method_listbyproduct.go delete mode 100644 resource-manager/apimanagement/2022-08-01/productgroup/method_listbyproduct_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/productpolicy/method_createorupdate.go delete mode 100644 resource-manager/apimanagement/2022-08-01/productpolicy/method_createorupdate_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/productpolicy/method_delete.go delete mode 100644 resource-manager/apimanagement/2022-08-01/productpolicy/method_delete_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/productpolicy/method_get.go delete mode 100644 resource-manager/apimanagement/2022-08-01/productpolicy/method_get_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/productpolicy/method_getentitytag.go delete mode 100644 resource-manager/apimanagement/2022-08-01/productpolicy/method_getentitytag_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/productpolicy/method_listbyproduct.go delete mode 100644 resource-manager/apimanagement/2022-08-01/productpolicy/method_listbyproduct_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/productsbytag/method_productlistbytags.go delete mode 100644 resource-manager/apimanagement/2022-08-01/productsbytag/method_productlistbytags_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/productsubscription/method_list.go delete mode 100644 resource-manager/apimanagement/2022-08-01/productsubscription/method_list_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/producttag/method_tagassigntoproduct.go delete mode 100644 resource-manager/apimanagement/2022-08-01/producttag/method_tagassigntoproduct_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/producttag/method_tagdetachfromproduct.go delete mode 100644 resource-manager/apimanagement/2022-08-01/producttag/method_tagdetachfromproduct_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/producttag/method_taggetbyproduct.go delete mode 100644 resource-manager/apimanagement/2022-08-01/producttag/method_taggetbyproduct_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/producttag/method_taggetentitystatebyproduct.go delete mode 100644 resource-manager/apimanagement/2022-08-01/producttag/method_taggetentitystatebyproduct_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/producttag/method_taglistbyproduct.go delete mode 100644 resource-manager/apimanagement/2022-08-01/producttag/method_taglistbyproduct_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/productwiki/method_createorupdate.go delete mode 100644 resource-manager/apimanagement/2022-08-01/productwiki/method_createorupdate_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/productwiki/method_delete.go delete mode 100644 resource-manager/apimanagement/2022-08-01/productwiki/method_delete_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/productwiki/method_get.go delete mode 100644 resource-manager/apimanagement/2022-08-01/productwiki/method_get_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/productwiki/method_getentitytag.go delete mode 100644 resource-manager/apimanagement/2022-08-01/productwiki/method_getentitytag_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/productwiki/method_list.go delete mode 100644 resource-manager/apimanagement/2022-08-01/productwiki/method_list_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/productwiki/method_update.go delete mode 100644 resource-manager/apimanagement/2022-08-01/productwiki/method_update_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/quotabycounterkeys/method_listbyservice.go delete mode 100644 resource-manager/apimanagement/2022-08-01/quotabycounterkeys/method_listbyservice_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/quotabycounterkeys/method_update.go delete mode 100644 resource-manager/apimanagement/2022-08-01/quotabycounterkeys/method_update_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/quotabyperiodkeys/method_get.go delete mode 100644 resource-manager/apimanagement/2022-08-01/quotabyperiodkeys/method_get_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/quotabyperiodkeys/method_update.go delete mode 100644 resource-manager/apimanagement/2022-08-01/quotabyperiodkeys/method_update_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/region/method_listbyservice.go delete mode 100644 resource-manager/apimanagement/2022-08-01/region/method_listbyservice_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/reports/method_listbyapi.go delete mode 100644 resource-manager/apimanagement/2022-08-01/reports/method_listbyapi_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/reports/method_listbygeo.go delete mode 100644 resource-manager/apimanagement/2022-08-01/reports/method_listbygeo_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/reports/method_listbyoperation.go delete mode 100644 resource-manager/apimanagement/2022-08-01/reports/method_listbyoperation_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/reports/method_listbyproduct.go delete mode 100644 resource-manager/apimanagement/2022-08-01/reports/method_listbyproduct_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/reports/method_listbyrequest.go delete mode 100644 resource-manager/apimanagement/2022-08-01/reports/method_listbyrequest_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/reports/method_listbysubscription.go delete mode 100644 resource-manager/apimanagement/2022-08-01/reports/method_listbysubscription_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/reports/method_listbytime.go delete mode 100644 resource-manager/apimanagement/2022-08-01/reports/method_listbytime_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/reports/method_listbyuser.go delete mode 100644 resource-manager/apimanagement/2022-08-01/reports/method_listbyuser_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/schema/method_globalschemacreateorupdate.go delete mode 100644 resource-manager/apimanagement/2022-08-01/schema/method_globalschemacreateorupdate_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/schema/method_globalschemadelete.go delete mode 100644 resource-manager/apimanagement/2022-08-01/schema/method_globalschemadelete_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/schema/method_globalschemaget.go delete mode 100644 resource-manager/apimanagement/2022-08-01/schema/method_globalschemaget_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/schema/method_globalschemagetentitytag.go delete mode 100644 resource-manager/apimanagement/2022-08-01/schema/method_globalschemagetentitytag_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/schema/method_globalschemalistbyservice.go delete mode 100644 resource-manager/apimanagement/2022-08-01/schema/method_globalschemalistbyservice_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/signinsettings/method_createorupdate.go delete mode 100644 resource-manager/apimanagement/2022-08-01/signinsettings/method_createorupdate_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/signinsettings/method_get.go delete mode 100644 resource-manager/apimanagement/2022-08-01/signinsettings/method_get_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/signinsettings/method_getentitytag.go delete mode 100644 resource-manager/apimanagement/2022-08-01/signinsettings/method_getentitytag_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/signinsettings/method_update.go delete mode 100644 resource-manager/apimanagement/2022-08-01/signinsettings/method_update_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/signupsettings/method_createorupdate.go delete mode 100644 resource-manager/apimanagement/2022-08-01/signupsettings/method_createorupdate_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/signupsettings/method_get.go delete mode 100644 resource-manager/apimanagement/2022-08-01/signupsettings/method_get_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/signupsettings/method_getentitytag.go delete mode 100644 resource-manager/apimanagement/2022-08-01/signupsettings/method_getentitytag_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/signupsettings/method_update.go delete mode 100644 resource-manager/apimanagement/2022-08-01/signupsettings/method_update_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/skus/method_apimanagementskuslist.go delete mode 100644 resource-manager/apimanagement/2022-08-01/skus/method_apimanagementskuslist_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/subscription/method_createorupdate.go delete mode 100644 resource-manager/apimanagement/2022-08-01/subscription/method_createorupdate_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/subscription/method_delete.go delete mode 100644 resource-manager/apimanagement/2022-08-01/subscription/method_delete_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/subscription/method_get.go delete mode 100644 resource-manager/apimanagement/2022-08-01/subscription/method_get_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/subscription/method_getentitytag.go delete mode 100644 resource-manager/apimanagement/2022-08-01/subscription/method_getentitytag_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/subscription/method_list.go delete mode 100644 resource-manager/apimanagement/2022-08-01/subscription/method_list_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/subscription/method_listsecrets.go delete mode 100644 resource-manager/apimanagement/2022-08-01/subscription/method_listsecrets_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/subscription/method_regenerateprimarykey.go delete mode 100644 resource-manager/apimanagement/2022-08-01/subscription/method_regenerateprimarykey_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/subscription/method_regeneratesecondarykey.go delete mode 100644 resource-manager/apimanagement/2022-08-01/subscription/method_regeneratesecondarykey_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/subscription/method_update.go delete mode 100644 resource-manager/apimanagement/2022-08-01/subscription/method_update_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/subscription/method_usersubscriptionget.go delete mode 100644 resource-manager/apimanagement/2022-08-01/subscription/method_usersubscriptionget_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/tag/method_createorupdate.go delete mode 100644 resource-manager/apimanagement/2022-08-01/tag/method_createorupdate_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/tag/method_delete.go delete mode 100644 resource-manager/apimanagement/2022-08-01/tag/method_delete_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/tag/method_get.go delete mode 100644 resource-manager/apimanagement/2022-08-01/tag/method_get_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/tag/method_getentitystate.go delete mode 100644 resource-manager/apimanagement/2022-08-01/tag/method_getentitystate_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/tag/method_listbyservice.go delete mode 100644 resource-manager/apimanagement/2022-08-01/tag/method_listbyservice_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/tag/method_update.go delete mode 100644 resource-manager/apimanagement/2022-08-01/tag/method_update_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/tagresource/method_listbyservice.go delete mode 100644 resource-manager/apimanagement/2022-08-01/tagresource/method_listbyservice_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/tenantaccess/method_create.go delete mode 100644 resource-manager/apimanagement/2022-08-01/tenantaccess/method_create_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/tenantaccess/method_get.go delete mode 100644 resource-manager/apimanagement/2022-08-01/tenantaccess/method_get_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/tenantaccess/method_getentitytag.go delete mode 100644 resource-manager/apimanagement/2022-08-01/tenantaccess/method_getentitytag_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/tenantaccess/method_listbyservice.go delete mode 100644 resource-manager/apimanagement/2022-08-01/tenantaccess/method_listbyservice_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/tenantaccess/method_listsecrets.go delete mode 100644 resource-manager/apimanagement/2022-08-01/tenantaccess/method_listsecrets_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/tenantaccess/method_regenerateprimarykey.go delete mode 100644 resource-manager/apimanagement/2022-08-01/tenantaccess/method_regenerateprimarykey_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/tenantaccess/method_regeneratesecondarykey.go delete mode 100644 resource-manager/apimanagement/2022-08-01/tenantaccess/method_regeneratesecondarykey_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/tenantaccess/method_update.go delete mode 100644 resource-manager/apimanagement/2022-08-01/tenantaccess/method_update_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/tenantaccessgit/method_regenerateprimarykey.go delete mode 100644 resource-manager/apimanagement/2022-08-01/tenantaccessgit/method_regenerateprimarykey_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/tenantaccessgit/method_regeneratesecondarykey.go delete mode 100644 resource-manager/apimanagement/2022-08-01/tenantaccessgit/method_regeneratesecondarykey_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/tenantconfiguration/method_deploy.go delete mode 100644 resource-manager/apimanagement/2022-08-01/tenantconfiguration/method_deploy_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/tenantconfiguration/method_save.go delete mode 100644 resource-manager/apimanagement/2022-08-01/tenantconfiguration/method_save_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/tenantconfiguration/method_validate.go delete mode 100644 resource-manager/apimanagement/2022-08-01/tenantconfiguration/method_validate_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/tenantconfigurationsyncstate/method_tenantconfigurationgetsyncstate.go delete mode 100644 resource-manager/apimanagement/2022-08-01/tenantconfigurationsyncstate/method_tenantconfigurationgetsyncstate_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/tenantsettings/method_get.go delete mode 100644 resource-manager/apimanagement/2022-08-01/tenantsettings/method_get_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/tenantsettings/method_listbyservice.go delete mode 100644 resource-manager/apimanagement/2022-08-01/tenantsettings/method_listbyservice_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/user/method_createorupdate.go delete mode 100644 resource-manager/apimanagement/2022-08-01/user/method_createorupdate_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/user/method_delete.go delete mode 100644 resource-manager/apimanagement/2022-08-01/user/method_delete_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/user/method_get.go delete mode 100644 resource-manager/apimanagement/2022-08-01/user/method_get_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/user/method_getentitytag.go delete mode 100644 resource-manager/apimanagement/2022-08-01/user/method_getentitytag_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/user/method_listbyservice.go delete mode 100644 resource-manager/apimanagement/2022-08-01/user/method_listbyservice_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/user/method_update.go delete mode 100644 resource-manager/apimanagement/2022-08-01/user/method_update_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/userconfirmationpasswordsend/method_userconfirmationpasswordsend.go delete mode 100644 resource-manager/apimanagement/2022-08-01/userconfirmationpasswordsend/method_userconfirmationpasswordsend_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/usergroup/method_list.go delete mode 100644 resource-manager/apimanagement/2022-08-01/usergroup/method_list_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/useridentity/method_useridentitieslist.go delete mode 100644 resource-manager/apimanagement/2022-08-01/useridentity/method_useridentitieslist_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/users/method_usergeneratessourl.go delete mode 100644 resource-manager/apimanagement/2022-08-01/users/method_usergeneratessourl_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/usersubscription/method_list.go delete mode 100644 resource-manager/apimanagement/2022-08-01/usersubscription/method_list_autorest.go create mode 100644 resource-manager/apimanagement/2022-08-01/usertoken/method_usergetsharedaccesstoken.go delete mode 100644 resource-manager/apimanagement/2022-08-01/usertoken/method_usergetsharedaccesstoken_autorest.go diff --git a/resource-manager/apimanagement/2021-08-01/api/client.go b/resource-manager/apimanagement/2021-08-01/api/client.go index 6d9c8390b45..577f71cde2a 100644 --- a/resource-manager/apimanagement/2021-08-01/api/client.go +++ b/resource-manager/apimanagement/2021-08-01/api/client.go @@ -1,18 +1,26 @@ package api -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 ApiClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewApiClientWithBaseURI(endpoint string) ApiClient { - return ApiClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewApiClientWithBaseURI(api environments.Api) (*ApiClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "api", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ApiClient: %+v", err) } + + return &ApiClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2021-08-01/api/constants.go b/resource-manager/apimanagement/2021-08-01/api/constants.go index f6a133ddf2b..63b7ebe8c1d 100644 --- a/resource-manager/apimanagement/2021-08-01/api/constants.go +++ b/resource-manager/apimanagement/2021-08-01/api/constants.go @@ -1,6 +1,10 @@ package api -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 PossibleValuesForApiType() []string { } } +func (s *ApiType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseApiType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseApiType(input string) (*ApiType, error) { vals := map[string]ApiType{ "graphql": ApiTypeGraphql, @@ -53,6 +70,19 @@ func PossibleValuesForBearerTokenSendingMethods() []string { } } +func (s *BearerTokenSendingMethods) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseBearerTokenSendingMethods(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseBearerTokenSendingMethods(input string) (*BearerTokenSendingMethods, error) { vals := map[string]BearerTokenSendingMethods{ "authorizationheader": BearerTokenSendingMethodsAuthorizationHeader, @@ -99,6 +129,19 @@ func PossibleValuesForContentFormat() []string { } } +func (s *ContentFormat) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseContentFormat(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseContentFormat(input string) (*ContentFormat, error) { vals := map[string]ContentFormat{ "graphql-link": ContentFormatGraphqlNegativelink, @@ -140,6 +183,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{ "http": ProtocolHTTP, @@ -174,6 +230,19 @@ func PossibleValuesForSoapApiType() []string { } } +func (s *SoapApiType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSoapApiType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseSoapApiType(input string) (*SoapApiType, error) { vals := map[string]SoapApiType{ "graphql": SoapApiTypeGraphql, @@ -206,6 +275,19 @@ func PossibleValuesForVersioningScheme() []string { } } +func (s *VersioningScheme) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseVersioningScheme(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseVersioningScheme(input string) (*VersioningScheme, error) { vals := map[string]VersioningScheme{ "header": VersioningSchemeHeader, diff --git a/resource-manager/apimanagement/2021-08-01/api/method_createorupdate.go b/resource-manager/apimanagement/2021-08-01/api/method_createorupdate.go new file mode 100644 index 00000000000..6906b67a6ba --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/api/method_createorupdate.go @@ -0,0 +1,103 @@ +package api + +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 +} + +type CreateOrUpdateOperationOptions struct { + IfMatch *string +} + +func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { + return CreateOrUpdateOperationOptions{} +} + +func (o CreateOrUpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o CreateOrUpdateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o CreateOrUpdateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// CreateOrUpdate ... +func (c ApiClient) CreateOrUpdate(ctx context.Context, id ApiId, input ApiCreateOrUpdateParameter, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + OptionsObject: options, + } + + 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 ApiClient) CreateOrUpdateThenPoll(ctx context.Context, id ApiId, input ApiCreateOrUpdateParameter, options CreateOrUpdateOperationOptions) error { + result, err := c.CreateOrUpdate(ctx, id, input, options) + 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/apimanagement/2021-08-01/api/method_createorupdate_autorest.go b/resource-manager/apimanagement/2021-08-01/api/method_createorupdate_autorest.go deleted file mode 100644 index cf276d9f58f..00000000000 --- a/resource-manager/apimanagement/2021-08-01/api/method_createorupdate_autorest.go +++ /dev/null @@ -1,108 +0,0 @@ -package api - -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 -} - -type CreateOrUpdateOperationOptions struct { - IfMatch *string -} - -func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { - return CreateOrUpdateOperationOptions{} -} - -func (o CreateOrUpdateOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o CreateOrUpdateOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// CreateOrUpdate ... -func (c ApiClient) CreateOrUpdate(ctx context.Context, id ApiId, input ApiCreateOrUpdateParameter, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdate(ctx, id, input, options) - if err != nil { - err = autorest.NewErrorWithError(err, "api.ApiClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result, err = c.senderForCreateOrUpdate(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "api.ApiClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed -func (c ApiClient) CreateOrUpdateThenPoll(ctx context.Context, id ApiId, input ApiCreateOrUpdateParameter, options CreateOrUpdateOperationOptions) error { - result, err := c.CreateOrUpdate(ctx, id, input, options) - 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 ApiClient) preparerForCreateOrUpdate(ctx context.Context, id ApiId, input ApiCreateOrUpdateParameter, options CreateOrUpdateOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - 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 ApiClient) 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/apimanagement/2021-08-01/api/method_delete.go b/resource-manager/apimanagement/2021-08-01/api/method_delete.go new file mode 100644 index 00000000000..19f24f35d16 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/api/method_delete.go @@ -0,0 +1,79 @@ +package api + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +type DeleteOperationOptions struct { + DeleteRevisions *bool + IfMatch *string +} + +func DefaultDeleteOperationOptions() DeleteOperationOptions { + return DeleteOperationOptions{} +} + +func (o DeleteOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o DeleteOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o DeleteOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.DeleteRevisions != nil { + out.Append("deleteRevisions", fmt.Sprintf("%v", *o.DeleteRevisions)) + } + return &out +} + +// Delete ... +func (c ApiClient) Delete(ctx context.Context, id ApiId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2021-08-01/api/method_delete_autorest.go b/resource-manager/apimanagement/2021-08-01/api/method_delete_autorest.go deleted file mode 100644 index 0971572259e..00000000000 --- a/resource-manager/apimanagement/2021-08-01/api/method_delete_autorest.go +++ /dev/null @@ -1,100 +0,0 @@ -package api - -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 DeleteOperationResponse struct { - HttpResponse *http.Response -} - -type DeleteOperationOptions struct { - DeleteRevisions *bool - IfMatch *string -} - -func DefaultDeleteOperationOptions() DeleteOperationOptions { - return DeleteOperationOptions{} -} - -func (o DeleteOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o DeleteOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.DeleteRevisions != nil { - out["deleteRevisions"] = *o.DeleteRevisions - } - - return out -} - -// Delete ... -func (c ApiClient) Delete(ctx context.Context, id ApiId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { - req, err := c.preparerForDelete(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "api.ApiClient", "Delete", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "api.ApiClient", "Delete", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForDelete(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "api.ApiClient", "Delete", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForDelete prepares the Delete request. -func (c ApiClient) preparerForDelete(ctx context.Context, id ApiId, options DeleteOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForDelete handles the response to the Delete request. The method always -// closes the http.Response Body. -func (c ApiClient) responderForDelete(resp *http.Response) (result DeleteOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2021-08-01/api/method_get.go b/resource-manager/apimanagement/2021-08-01/api/method_get.go new file mode 100644 index 00000000000..f750fb8e0ec --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/api/method_get.go @@ -0,0 +1,51 @@ +package api + +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 *ApiContract +} + +// Get ... +func (c ApiClient) Get(ctx context.Context, id ApiId) (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/apimanagement/2021-08-01/api/method_get_autorest.go b/resource-manager/apimanagement/2021-08-01/api/method_get_autorest.go deleted file mode 100644 index cd4943ce66a..00000000000 --- a/resource-manager/apimanagement/2021-08-01/api/method_get_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package api - -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 *ApiContract -} - -// Get ... -func (c ApiClient) Get(ctx context.Context, id ApiId) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "api.ApiClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "api.ApiClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "api.ApiClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c ApiClient) preparerForGet(ctx context.Context, id ApiId) (*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 ApiClient) 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/apimanagement/2021-08-01/api/method_getentitytag.go b/resource-manager/apimanagement/2021-08-01/api/method_getentitytag.go new file mode 100644 index 00000000000..5d65ab7fc88 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/api/method_getentitytag.go @@ -0,0 +1,46 @@ +package api + +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 GetEntityTagOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// GetEntityTag ... +func (c ApiClient) GetEntityTag(ctx context.Context, id ApiId) (result GetEntityTagOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodHead, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2021-08-01/api/method_getentitytag_autorest.go b/resource-manager/apimanagement/2021-08-01/api/method_getentitytag_autorest.go deleted file mode 100644 index 326d2bb9cdf..00000000000 --- a/resource-manager/apimanagement/2021-08-01/api/method_getentitytag_autorest.go +++ /dev/null @@ -1,66 +0,0 @@ -package api - -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 GetEntityTagOperationResponse struct { - HttpResponse *http.Response -} - -// GetEntityTag ... -func (c ApiClient) GetEntityTag(ctx context.Context, id ApiId) (result GetEntityTagOperationResponse, err error) { - req, err := c.preparerForGetEntityTag(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "api.ApiClient", "GetEntityTag", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "api.ApiClient", "GetEntityTag", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetEntityTag(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "api.ApiClient", "GetEntityTag", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetEntityTag prepares the GetEntityTag request. -func (c ApiClient) preparerForGetEntityTag(ctx context.Context, id ApiId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsHead(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetEntityTag handles the response to the GetEntityTag request. The method always -// closes the http.Response Body. -func (c ApiClient) responderForGetEntityTag(resp *http.Response) (result GetEntityTagOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2021-08-01/api/method_listbyservice.go b/resource-manager/apimanagement/2021-08-01/api/method_listbyservice.go new file mode 100644 index 00000000000..2b6a6ad37f7 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/api/method_listbyservice.go @@ -0,0 +1,133 @@ +package api + +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 ListByServiceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ApiContract +} + +type ListByServiceCompleteResult struct { + Items []ApiContract +} + +type ListByServiceOperationOptions struct { + ExpandApiVersionSet *bool + Filter *string + Skip *int64 + Tags *string + Top *int64 +} + +func DefaultListByServiceOperationOptions() ListByServiceOperationOptions { + return ListByServiceOperationOptions{} +} + +func (o ListByServiceOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListByServiceOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListByServiceOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.ExpandApiVersionSet != nil { + out.Append("expandApiVersionSet", fmt.Sprintf("%v", *o.ExpandApiVersionSet)) + } + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.Skip != nil { + out.Append("$skip", fmt.Sprintf("%v", *o.Skip)) + } + if o.Tags != nil { + out.Append("tags", fmt.Sprintf("%v", *o.Tags)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +// ListByService ... +func (c ApiClient) ListByService(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (result ListByServiceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/apis", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ApiContract `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByServiceComplete retrieves all the results into a single object +func (c ApiClient) ListByServiceComplete(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (ListByServiceCompleteResult, error) { + return c.ListByServiceCompleteMatchingPredicate(ctx, id, options, ApiContractOperationPredicate{}) +} + +// ListByServiceCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ApiClient) ListByServiceCompleteMatchingPredicate(ctx context.Context, id ServiceId, options ListByServiceOperationOptions, predicate ApiContractOperationPredicate) (result ListByServiceCompleteResult, err error) { + items := make([]ApiContract, 0) + + resp, err := c.ListByService(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByServiceCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/apimanagement/2021-08-01/api/method_listbyservice_autorest.go b/resource-manager/apimanagement/2021-08-01/api/method_listbyservice_autorest.go deleted file mode 100644 index 114e7e5afe3..00000000000 --- a/resource-manager/apimanagement/2021-08-01/api/method_listbyservice_autorest.go +++ /dev/null @@ -1,235 +0,0 @@ -package api - -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 ListByServiceOperationResponse struct { - HttpResponse *http.Response - Model *[]ApiContract - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListByServiceOperationResponse, error) -} - -type ListByServiceCompleteResult struct { - Items []ApiContract -} - -func (r ListByServiceOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListByServiceOperationResponse) LoadMore(ctx context.Context) (resp ListByServiceOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -type ListByServiceOperationOptions struct { - ExpandApiVersionSet *bool - Filter *string - Skip *int64 - Tags *string - Top *int64 -} - -func DefaultListByServiceOperationOptions() ListByServiceOperationOptions { - return ListByServiceOperationOptions{} -} - -func (o ListByServiceOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o ListByServiceOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.ExpandApiVersionSet != nil { - out["expandApiVersionSet"] = *o.ExpandApiVersionSet - } - - if o.Filter != nil { - out["$filter"] = *o.Filter - } - - if o.Skip != nil { - out["$skip"] = *o.Skip - } - - if o.Tags != nil { - out["tags"] = *o.Tags - } - - if o.Top != nil { - out["$top"] = *o.Top - } - - return out -} - -// ListByService ... -func (c ApiClient) ListByService(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (resp ListByServiceOperationResponse, err error) { - req, err := c.preparerForListByService(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "api.ApiClient", "ListByService", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "api.ApiClient", "ListByService", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListByService(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "api.ApiClient", "ListByService", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListByService prepares the ListByService request. -func (c ApiClient) preparerForListByService(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/apis", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListByServiceWithNextLink prepares the ListByService request with the given nextLink token. -func (c ApiClient) preparerForListByServiceWithNextLink(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)) -} - -// responderForListByService handles the response to the ListByService request. The method always -// closes the http.Response Body. -func (c ApiClient) responderForListByService(resp *http.Response) (result ListByServiceOperationResponse, err error) { - type page struct { - Values []ApiContract `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 ListByServiceOperationResponse, err error) { - req, err := c.preparerForListByServiceWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "api.ApiClient", "ListByService", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "api.ApiClient", "ListByService", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByService(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "api.ApiClient", "ListByService", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListByServiceComplete retrieves all of the results into a single object -func (c ApiClient) ListByServiceComplete(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (ListByServiceCompleteResult, error) { - return c.ListByServiceCompleteMatchingPredicate(ctx, id, options, ApiContractOperationPredicate{}) -} - -// ListByServiceCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c ApiClient) ListByServiceCompleteMatchingPredicate(ctx context.Context, id ServiceId, options ListByServiceOperationOptions, predicate ApiContractOperationPredicate) (resp ListByServiceCompleteResult, err error) { - items := make([]ApiContract, 0) - - page, err := c.ListByService(ctx, id, options) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListByServiceCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/apimanagement/2021-08-01/api/method_update.go b/resource-manager/apimanagement/2021-08-01/api/method_update.go new file mode 100644 index 00000000000..8b2e6fa4357 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/api/method_update.go @@ -0,0 +1,84 @@ +package api + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ApiContract +} + +type UpdateOperationOptions struct { + IfMatch *string +} + +func DefaultUpdateOperationOptions() UpdateOperationOptions { + return UpdateOperationOptions{} +} + +func (o UpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o UpdateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o UpdateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// Update ... +func (c ApiClient) Update(ctx context.Context, id ApiId, input ApiUpdateContract, options UpdateOperationOptions) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + OptionsObject: options, + } + + 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/apimanagement/2021-08-01/api/method_update_autorest.go b/resource-manager/apimanagement/2021-08-01/api/method_update_autorest.go deleted file mode 100644 index b998809dc0e..00000000000 --- a/resource-manager/apimanagement/2021-08-01/api/method_update_autorest.go +++ /dev/null @@ -1,98 +0,0 @@ -package api - -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 *ApiContract -} - -type UpdateOperationOptions struct { - IfMatch *string -} - -func DefaultUpdateOperationOptions() UpdateOperationOptions { - return UpdateOperationOptions{} -} - -func (o UpdateOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o UpdateOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// Update ... -func (c ApiClient) Update(ctx context.Context, id ApiId, input ApiUpdateContract, options UpdateOperationOptions) (result UpdateOperationResponse, err error) { - req, err := c.preparerForUpdate(ctx, id, input, options) - if err != nil { - err = autorest.NewErrorWithError(err, "api.ApiClient", "Update", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "api.ApiClient", "Update", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "api.ApiClient", "Update", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForUpdate prepares the Update request. -func (c ApiClient) preparerForUpdate(ctx context.Context, id ApiId, input ApiUpdateContract, options UpdateOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPatch(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - 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 ApiClient) 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/apimanagement/2021-08-01/apidiagnostic/client.go b/resource-manager/apimanagement/2021-08-01/apidiagnostic/client.go index 99e83188cc6..beec386c59e 100644 --- a/resource-manager/apimanagement/2021-08-01/apidiagnostic/client.go +++ b/resource-manager/apimanagement/2021-08-01/apidiagnostic/client.go @@ -1,18 +1,26 @@ package apidiagnostic -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 ApiDiagnosticClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewApiDiagnosticClientWithBaseURI(endpoint string) ApiDiagnosticClient { - return ApiDiagnosticClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewApiDiagnosticClientWithBaseURI(api environments.Api) (*ApiDiagnosticClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "apidiagnostic", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ApiDiagnosticClient: %+v", err) } + + return &ApiDiagnosticClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2021-08-01/apidiagnostic/constants.go b/resource-manager/apimanagement/2021-08-01/apidiagnostic/constants.go index 4d80cb551c7..1afde676ffa 100644 --- a/resource-manager/apimanagement/2021-08-01/apidiagnostic/constants.go +++ b/resource-manager/apimanagement/2021-08-01/apidiagnostic/constants.go @@ -1,6 +1,10 @@ package apidiagnostic -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 PossibleValuesForAlwaysLog() []string { } } +func (s *AlwaysLog) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAlwaysLog(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseAlwaysLog(input string) (*AlwaysLog, error) { vals := map[string]AlwaysLog{ "allerrors": AlwaysLogAllErrors, @@ -44,6 +61,19 @@ func PossibleValuesForDataMaskingMode() []string { } } +func (s *DataMaskingMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDataMaskingMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseDataMaskingMode(input string) (*DataMaskingMode, error) { vals := map[string]DataMaskingMode{ "hide": DataMaskingModeHide, @@ -74,6 +104,19 @@ func PossibleValuesForHTTPCorrelationProtocol() []string { } } +func (s *HTTPCorrelationProtocol) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseHTTPCorrelationProtocol(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseHTTPCorrelationProtocol(input string) (*HTTPCorrelationProtocol, error) { vals := map[string]HTTPCorrelationProtocol{ "legacy": HTTPCorrelationProtocolLegacy, @@ -103,6 +146,19 @@ func PossibleValuesForOperationNameFormat() []string { } } +func (s *OperationNameFormat) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseOperationNameFormat(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseOperationNameFormat(input string) (*OperationNameFormat, error) { vals := map[string]OperationNameFormat{ "name": OperationNameFormatName, @@ -129,6 +185,19 @@ func PossibleValuesForSamplingType() []string { } } +func (s *SamplingType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSamplingType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseSamplingType(input string) (*SamplingType, error) { vals := map[string]SamplingType{ "fixed": SamplingTypeFixed, @@ -158,6 +227,19 @@ func PossibleValuesForVerbosity() []string { } } +func (s *Verbosity) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseVerbosity(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseVerbosity(input string) (*Verbosity, error) { vals := map[string]Verbosity{ "error": VerbosityError, diff --git a/resource-manager/apimanagement/2021-08-01/apidiagnostic/method_createorupdate.go b/resource-manager/apimanagement/2021-08-01/apidiagnostic/method_createorupdate.go new file mode 100644 index 00000000000..d50634ca8da --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/apidiagnostic/method_createorupdate.go @@ -0,0 +1,85 @@ +package apidiagnostic + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DiagnosticContract +} + +type CreateOrUpdateOperationOptions struct { + IfMatch *string +} + +func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { + return CreateOrUpdateOperationOptions{} +} + +func (o CreateOrUpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o CreateOrUpdateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o CreateOrUpdateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// CreateOrUpdate ... +func (c ApiDiagnosticClient) CreateOrUpdate(ctx context.Context, id ApiDiagnosticId, input DiagnosticContract, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + OptionsObject: options, + } + + 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/apimanagement/2021-08-01/apidiagnostic/method_createorupdate_autorest.go b/resource-manager/apimanagement/2021-08-01/apidiagnostic/method_createorupdate_autorest.go deleted file mode 100644 index 510d94a82ae..00000000000 --- a/resource-manager/apimanagement/2021-08-01/apidiagnostic/method_createorupdate_autorest.go +++ /dev/null @@ -1,98 +0,0 @@ -package apidiagnostic - -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 *DiagnosticContract -} - -type CreateOrUpdateOperationOptions struct { - IfMatch *string -} - -func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { - return CreateOrUpdateOperationOptions{} -} - -func (o CreateOrUpdateOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o CreateOrUpdateOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// CreateOrUpdate ... -func (c ApiDiagnosticClient) CreateOrUpdate(ctx context.Context, id ApiDiagnosticId, input DiagnosticContract, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdate(ctx, id, input, options) - if err != nil { - err = autorest.NewErrorWithError(err, "apidiagnostic.ApiDiagnosticClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apidiagnostic.ApiDiagnosticClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCreateOrUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apidiagnostic.ApiDiagnosticClient", "CreateOrUpdate", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCreateOrUpdate prepares the CreateOrUpdate request. -func (c ApiDiagnosticClient) preparerForCreateOrUpdate(ctx context.Context, id ApiDiagnosticId, input DiagnosticContract, options CreateOrUpdateOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - 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 ApiDiagnosticClient) responderForCreateOrUpdate(resp *http.Response) (result CreateOrUpdateOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2021-08-01/apidiagnostic/method_delete.go b/resource-manager/apimanagement/2021-08-01/apidiagnostic/method_delete.go new file mode 100644 index 00000000000..0fb3223f00f --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/apidiagnostic/method_delete.go @@ -0,0 +1,76 @@ +package apidiagnostic + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +type DeleteOperationOptions struct { + IfMatch *string +} + +func DefaultDeleteOperationOptions() DeleteOperationOptions { + return DeleteOperationOptions{} +} + +func (o DeleteOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o DeleteOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o DeleteOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// Delete ... +func (c ApiDiagnosticClient) Delete(ctx context.Context, id ApiDiagnosticId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2021-08-01/apidiagnostic/method_delete_autorest.go b/resource-manager/apimanagement/2021-08-01/apidiagnostic/method_delete_autorest.go deleted file mode 100644 index f9098fe95dd..00000000000 --- a/resource-manager/apimanagement/2021-08-01/apidiagnostic/method_delete_autorest.go +++ /dev/null @@ -1,95 +0,0 @@ -package apidiagnostic - -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 DeleteOperationResponse struct { - HttpResponse *http.Response -} - -type DeleteOperationOptions struct { - IfMatch *string -} - -func DefaultDeleteOperationOptions() DeleteOperationOptions { - return DeleteOperationOptions{} -} - -func (o DeleteOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o DeleteOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// Delete ... -func (c ApiDiagnosticClient) Delete(ctx context.Context, id ApiDiagnosticId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { - req, err := c.preparerForDelete(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "apidiagnostic.ApiDiagnosticClient", "Delete", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apidiagnostic.ApiDiagnosticClient", "Delete", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForDelete(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apidiagnostic.ApiDiagnosticClient", "Delete", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForDelete prepares the Delete request. -func (c ApiDiagnosticClient) preparerForDelete(ctx context.Context, id ApiDiagnosticId, options DeleteOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForDelete handles the response to the Delete request. The method always -// closes the http.Response Body. -func (c ApiDiagnosticClient) responderForDelete(resp *http.Response) (result DeleteOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2021-08-01/apidiagnostic/method_get.go b/resource-manager/apimanagement/2021-08-01/apidiagnostic/method_get.go new file mode 100644 index 00000000000..26dffc0cd3e --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/apidiagnostic/method_get.go @@ -0,0 +1,51 @@ +package apidiagnostic + +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 *DiagnosticContract +} + +// Get ... +func (c ApiDiagnosticClient) Get(ctx context.Context, id ApiDiagnosticId) (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/apimanagement/2021-08-01/apidiagnostic/method_get_autorest.go b/resource-manager/apimanagement/2021-08-01/apidiagnostic/method_get_autorest.go deleted file mode 100644 index 5468c122ef0..00000000000 --- a/resource-manager/apimanagement/2021-08-01/apidiagnostic/method_get_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package apidiagnostic - -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 *DiagnosticContract -} - -// Get ... -func (c ApiDiagnosticClient) Get(ctx context.Context, id ApiDiagnosticId) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "apidiagnostic.ApiDiagnosticClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apidiagnostic.ApiDiagnosticClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apidiagnostic.ApiDiagnosticClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c ApiDiagnosticClient) preparerForGet(ctx context.Context, id ApiDiagnosticId) (*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 ApiDiagnosticClient) 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/apimanagement/2021-08-01/apidiagnostic/method_getentitytag.go b/resource-manager/apimanagement/2021-08-01/apidiagnostic/method_getentitytag.go new file mode 100644 index 00000000000..312e0f37414 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/apidiagnostic/method_getentitytag.go @@ -0,0 +1,46 @@ +package apidiagnostic + +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 GetEntityTagOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// GetEntityTag ... +func (c ApiDiagnosticClient) GetEntityTag(ctx context.Context, id ApiDiagnosticId) (result GetEntityTagOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodHead, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2021-08-01/apidiagnostic/method_getentitytag_autorest.go b/resource-manager/apimanagement/2021-08-01/apidiagnostic/method_getentitytag_autorest.go deleted file mode 100644 index 4ad28bdb6d5..00000000000 --- a/resource-manager/apimanagement/2021-08-01/apidiagnostic/method_getentitytag_autorest.go +++ /dev/null @@ -1,66 +0,0 @@ -package apidiagnostic - -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 GetEntityTagOperationResponse struct { - HttpResponse *http.Response -} - -// GetEntityTag ... -func (c ApiDiagnosticClient) GetEntityTag(ctx context.Context, id ApiDiagnosticId) (result GetEntityTagOperationResponse, err error) { - req, err := c.preparerForGetEntityTag(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "apidiagnostic.ApiDiagnosticClient", "GetEntityTag", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apidiagnostic.ApiDiagnosticClient", "GetEntityTag", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetEntityTag(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apidiagnostic.ApiDiagnosticClient", "GetEntityTag", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetEntityTag prepares the GetEntityTag request. -func (c ApiDiagnosticClient) preparerForGetEntityTag(ctx context.Context, id ApiDiagnosticId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsHead(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetEntityTag handles the response to the GetEntityTag request. The method always -// closes the http.Response Body. -func (c ApiDiagnosticClient) responderForGetEntityTag(resp *http.Response) (result GetEntityTagOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2021-08-01/apidiagnostic/method_listbyservice.go b/resource-manager/apimanagement/2021-08-01/apidiagnostic/method_listbyservice.go new file mode 100644 index 00000000000..125ebd65d5f --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/apidiagnostic/method_listbyservice.go @@ -0,0 +1,125 @@ +package apidiagnostic + +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 ListByServiceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]DiagnosticContract +} + +type ListByServiceCompleteResult struct { + Items []DiagnosticContract +} + +type ListByServiceOperationOptions struct { + Filter *string + Skip *int64 + Top *int64 +} + +func DefaultListByServiceOperationOptions() ListByServiceOperationOptions { + return ListByServiceOperationOptions{} +} + +func (o ListByServiceOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListByServiceOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListByServiceOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.Skip != nil { + out.Append("$skip", fmt.Sprintf("%v", *o.Skip)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +// ListByService ... +func (c ApiDiagnosticClient) ListByService(ctx context.Context, id ApiId, options ListByServiceOperationOptions) (result ListByServiceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/diagnostics", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]DiagnosticContract `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByServiceComplete retrieves all the results into a single object +func (c ApiDiagnosticClient) ListByServiceComplete(ctx context.Context, id ApiId, options ListByServiceOperationOptions) (ListByServiceCompleteResult, error) { + return c.ListByServiceCompleteMatchingPredicate(ctx, id, options, DiagnosticContractOperationPredicate{}) +} + +// ListByServiceCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ApiDiagnosticClient) ListByServiceCompleteMatchingPredicate(ctx context.Context, id ApiId, options ListByServiceOperationOptions, predicate DiagnosticContractOperationPredicate) (result ListByServiceCompleteResult, err error) { + items := make([]DiagnosticContract, 0) + + resp, err := c.ListByService(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByServiceCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/apimanagement/2021-08-01/apidiagnostic/method_listbyservice_autorest.go b/resource-manager/apimanagement/2021-08-01/apidiagnostic/method_listbyservice_autorest.go deleted file mode 100644 index c58834cf8bf..00000000000 --- a/resource-manager/apimanagement/2021-08-01/apidiagnostic/method_listbyservice_autorest.go +++ /dev/null @@ -1,225 +0,0 @@ -package apidiagnostic - -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 ListByServiceOperationResponse struct { - HttpResponse *http.Response - Model *[]DiagnosticContract - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListByServiceOperationResponse, error) -} - -type ListByServiceCompleteResult struct { - Items []DiagnosticContract -} - -func (r ListByServiceOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListByServiceOperationResponse) LoadMore(ctx context.Context) (resp ListByServiceOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -type ListByServiceOperationOptions struct { - Filter *string - Skip *int64 - Top *int64 -} - -func DefaultListByServiceOperationOptions() ListByServiceOperationOptions { - return ListByServiceOperationOptions{} -} - -func (o ListByServiceOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o ListByServiceOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Filter != nil { - out["$filter"] = *o.Filter - } - - if o.Skip != nil { - out["$skip"] = *o.Skip - } - - if o.Top != nil { - out["$top"] = *o.Top - } - - return out -} - -// ListByService ... -func (c ApiDiagnosticClient) ListByService(ctx context.Context, id ApiId, options ListByServiceOperationOptions) (resp ListByServiceOperationResponse, err error) { - req, err := c.preparerForListByService(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "apidiagnostic.ApiDiagnosticClient", "ListByService", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apidiagnostic.ApiDiagnosticClient", "ListByService", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListByService(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apidiagnostic.ApiDiagnosticClient", "ListByService", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListByService prepares the ListByService request. -func (c ApiDiagnosticClient) preparerForListByService(ctx context.Context, id ApiId, options ListByServiceOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/diagnostics", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListByServiceWithNextLink prepares the ListByService request with the given nextLink token. -func (c ApiDiagnosticClient) preparerForListByServiceWithNextLink(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)) -} - -// responderForListByService handles the response to the ListByService request. The method always -// closes the http.Response Body. -func (c ApiDiagnosticClient) responderForListByService(resp *http.Response) (result ListByServiceOperationResponse, err error) { - type page struct { - Values []DiagnosticContract `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 ListByServiceOperationResponse, err error) { - req, err := c.preparerForListByServiceWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "apidiagnostic.ApiDiagnosticClient", "ListByService", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apidiagnostic.ApiDiagnosticClient", "ListByService", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByService(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apidiagnostic.ApiDiagnosticClient", "ListByService", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListByServiceComplete retrieves all of the results into a single object -func (c ApiDiagnosticClient) ListByServiceComplete(ctx context.Context, id ApiId, options ListByServiceOperationOptions) (ListByServiceCompleteResult, error) { - return c.ListByServiceCompleteMatchingPredicate(ctx, id, options, DiagnosticContractOperationPredicate{}) -} - -// ListByServiceCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c ApiDiagnosticClient) ListByServiceCompleteMatchingPredicate(ctx context.Context, id ApiId, options ListByServiceOperationOptions, predicate DiagnosticContractOperationPredicate) (resp ListByServiceCompleteResult, err error) { - items := make([]DiagnosticContract, 0) - - page, err := c.ListByService(ctx, id, options) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListByServiceCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/apimanagement/2021-08-01/apidiagnostic/method_update.go b/resource-manager/apimanagement/2021-08-01/apidiagnostic/method_update.go new file mode 100644 index 00000000000..b5341b3da3e --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/apidiagnostic/method_update.go @@ -0,0 +1,84 @@ +package apidiagnostic + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DiagnosticContract +} + +type UpdateOperationOptions struct { + IfMatch *string +} + +func DefaultUpdateOperationOptions() UpdateOperationOptions { + return UpdateOperationOptions{} +} + +func (o UpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o UpdateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o UpdateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// Update ... +func (c ApiDiagnosticClient) Update(ctx context.Context, id ApiDiagnosticId, input DiagnosticContract, options UpdateOperationOptions) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + OptionsObject: options, + } + + 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/apimanagement/2021-08-01/apidiagnostic/method_update_autorest.go b/resource-manager/apimanagement/2021-08-01/apidiagnostic/method_update_autorest.go deleted file mode 100644 index fa90a3f37f8..00000000000 --- a/resource-manager/apimanagement/2021-08-01/apidiagnostic/method_update_autorest.go +++ /dev/null @@ -1,98 +0,0 @@ -package apidiagnostic - -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 *DiagnosticContract -} - -type UpdateOperationOptions struct { - IfMatch *string -} - -func DefaultUpdateOperationOptions() UpdateOperationOptions { - return UpdateOperationOptions{} -} - -func (o UpdateOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o UpdateOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// Update ... -func (c ApiDiagnosticClient) Update(ctx context.Context, id ApiDiagnosticId, input DiagnosticContract, options UpdateOperationOptions) (result UpdateOperationResponse, err error) { - req, err := c.preparerForUpdate(ctx, id, input, options) - if err != nil { - err = autorest.NewErrorWithError(err, "apidiagnostic.ApiDiagnosticClient", "Update", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apidiagnostic.ApiDiagnosticClient", "Update", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apidiagnostic.ApiDiagnosticClient", "Update", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForUpdate prepares the Update request. -func (c ApiDiagnosticClient) preparerForUpdate(ctx context.Context, id ApiDiagnosticId, input DiagnosticContract, options UpdateOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPatch(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - 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 ApiDiagnosticClient) 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/apimanagement/2021-08-01/apiissue/client.go b/resource-manager/apimanagement/2021-08-01/apiissue/client.go index f63c05725de..7402b8d4ab0 100644 --- a/resource-manager/apimanagement/2021-08-01/apiissue/client.go +++ b/resource-manager/apimanagement/2021-08-01/apiissue/client.go @@ -1,18 +1,26 @@ package apiissue -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 ApiIssueClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewApiIssueClientWithBaseURI(endpoint string) ApiIssueClient { - return ApiIssueClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewApiIssueClientWithBaseURI(api environments.Api) (*ApiIssueClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "apiissue", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ApiIssueClient: %+v", err) } + + return &ApiIssueClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2021-08-01/apiissue/constants.go b/resource-manager/apimanagement/2021-08-01/apiissue/constants.go index 63548405b43..16888d5e064 100644 --- a/resource-manager/apimanagement/2021-08-01/apiissue/constants.go +++ b/resource-manager/apimanagement/2021-08-01/apiissue/constants.go @@ -1,6 +1,10 @@ package apiissue -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. @@ -25,6 +29,19 @@ func PossibleValuesForState() []string { } } +func (s *State) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseState(input string) (*State, error) { vals := map[string]State{ "closed": StateClosed, diff --git a/resource-manager/apimanagement/2021-08-01/apiissue/method_createorupdate.go b/resource-manager/apimanagement/2021-08-01/apiissue/method_createorupdate.go new file mode 100644 index 00000000000..10a6a5bca91 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/apiissue/method_createorupdate.go @@ -0,0 +1,85 @@ +package apiissue + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *IssueContract +} + +type CreateOrUpdateOperationOptions struct { + IfMatch *string +} + +func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { + return CreateOrUpdateOperationOptions{} +} + +func (o CreateOrUpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o CreateOrUpdateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o CreateOrUpdateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// CreateOrUpdate ... +func (c ApiIssueClient) CreateOrUpdate(ctx context.Context, id ApiIssueId, input IssueContract, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + OptionsObject: options, + } + + 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/apimanagement/2021-08-01/apiissue/method_createorupdate_autorest.go b/resource-manager/apimanagement/2021-08-01/apiissue/method_createorupdate_autorest.go deleted file mode 100644 index 74810fa4260..00000000000 --- a/resource-manager/apimanagement/2021-08-01/apiissue/method_createorupdate_autorest.go +++ /dev/null @@ -1,98 +0,0 @@ -package apiissue - -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 *IssueContract -} - -type CreateOrUpdateOperationOptions struct { - IfMatch *string -} - -func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { - return CreateOrUpdateOperationOptions{} -} - -func (o CreateOrUpdateOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o CreateOrUpdateOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// CreateOrUpdate ... -func (c ApiIssueClient) CreateOrUpdate(ctx context.Context, id ApiIssueId, input IssueContract, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdate(ctx, id, input, options) - if err != nil { - err = autorest.NewErrorWithError(err, "apiissue.ApiIssueClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apiissue.ApiIssueClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCreateOrUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apiissue.ApiIssueClient", "CreateOrUpdate", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCreateOrUpdate prepares the CreateOrUpdate request. -func (c ApiIssueClient) preparerForCreateOrUpdate(ctx context.Context, id ApiIssueId, input IssueContract, options CreateOrUpdateOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - 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 ApiIssueClient) responderForCreateOrUpdate(resp *http.Response) (result CreateOrUpdateOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2021-08-01/apiissue/method_delete.go b/resource-manager/apimanagement/2021-08-01/apiissue/method_delete.go new file mode 100644 index 00000000000..822eaefefe3 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/apiissue/method_delete.go @@ -0,0 +1,76 @@ +package apiissue + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +type DeleteOperationOptions struct { + IfMatch *string +} + +func DefaultDeleteOperationOptions() DeleteOperationOptions { + return DeleteOperationOptions{} +} + +func (o DeleteOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o DeleteOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o DeleteOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// Delete ... +func (c ApiIssueClient) Delete(ctx context.Context, id ApiIssueId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2021-08-01/apiissue/method_delete_autorest.go b/resource-manager/apimanagement/2021-08-01/apiissue/method_delete_autorest.go deleted file mode 100644 index 77956335e4c..00000000000 --- a/resource-manager/apimanagement/2021-08-01/apiissue/method_delete_autorest.go +++ /dev/null @@ -1,95 +0,0 @@ -package apiissue - -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 DeleteOperationResponse struct { - HttpResponse *http.Response -} - -type DeleteOperationOptions struct { - IfMatch *string -} - -func DefaultDeleteOperationOptions() DeleteOperationOptions { - return DeleteOperationOptions{} -} - -func (o DeleteOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o DeleteOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// Delete ... -func (c ApiIssueClient) Delete(ctx context.Context, id ApiIssueId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { - req, err := c.preparerForDelete(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "apiissue.ApiIssueClient", "Delete", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apiissue.ApiIssueClient", "Delete", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForDelete(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apiissue.ApiIssueClient", "Delete", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForDelete prepares the Delete request. -func (c ApiIssueClient) preparerForDelete(ctx context.Context, id ApiIssueId, options DeleteOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForDelete handles the response to the Delete request. The method always -// closes the http.Response Body. -func (c ApiIssueClient) responderForDelete(resp *http.Response) (result DeleteOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2021-08-01/apiissue/method_get.go b/resource-manager/apimanagement/2021-08-01/apiissue/method_get.go new file mode 100644 index 00000000000..437b0420930 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/apiissue/method_get.go @@ -0,0 +1,80 @@ +package apiissue + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *IssueContract +} + +type GetOperationOptions struct { + ExpandCommentsAttachments *bool +} + +func DefaultGetOperationOptions() GetOperationOptions { + return GetOperationOptions{} +} + +func (o GetOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o GetOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o GetOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.ExpandCommentsAttachments != nil { + out.Append("expandCommentsAttachments", fmt.Sprintf("%v", *o.ExpandCommentsAttachments)) + } + return &out +} + +// Get ... +func (c ApiIssueClient) Get(ctx context.Context, id ApiIssueId, options GetOperationOptions) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + OptionsObject: options, + } + + 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/apimanagement/2021-08-01/apiissue/method_get_autorest.go b/resource-manager/apimanagement/2021-08-01/apiissue/method_get_autorest.go deleted file mode 100644 index 0821e733063..00000000000 --- a/resource-manager/apimanagement/2021-08-01/apiissue/method_get_autorest.go +++ /dev/null @@ -1,97 +0,0 @@ -package apiissue - -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 *IssueContract -} - -type GetOperationOptions struct { - ExpandCommentsAttachments *bool -} - -func DefaultGetOperationOptions() GetOperationOptions { - return GetOperationOptions{} -} - -func (o GetOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o GetOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.ExpandCommentsAttachments != nil { - out["expandCommentsAttachments"] = *o.ExpandCommentsAttachments - } - - return out -} - -// Get ... -func (c ApiIssueClient) Get(ctx context.Context, id ApiIssueId, options GetOperationOptions) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "apiissue.ApiIssueClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apiissue.ApiIssueClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apiissue.ApiIssueClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c ApiIssueClient) preparerForGet(ctx context.Context, id ApiIssueId, options GetOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(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 ApiIssueClient) 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/apimanagement/2021-08-01/apiissue/method_getentitytag.go b/resource-manager/apimanagement/2021-08-01/apiissue/method_getentitytag.go new file mode 100644 index 00000000000..fa22e539b24 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/apiissue/method_getentitytag.go @@ -0,0 +1,46 @@ +package apiissue + +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 GetEntityTagOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// GetEntityTag ... +func (c ApiIssueClient) GetEntityTag(ctx context.Context, id ApiIssueId) (result GetEntityTagOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodHead, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2021-08-01/apiissue/method_getentitytag_autorest.go b/resource-manager/apimanagement/2021-08-01/apiissue/method_getentitytag_autorest.go deleted file mode 100644 index 589dff977e0..00000000000 --- a/resource-manager/apimanagement/2021-08-01/apiissue/method_getentitytag_autorest.go +++ /dev/null @@ -1,66 +0,0 @@ -package apiissue - -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 GetEntityTagOperationResponse struct { - HttpResponse *http.Response -} - -// GetEntityTag ... -func (c ApiIssueClient) GetEntityTag(ctx context.Context, id ApiIssueId) (result GetEntityTagOperationResponse, err error) { - req, err := c.preparerForGetEntityTag(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "apiissue.ApiIssueClient", "GetEntityTag", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apiissue.ApiIssueClient", "GetEntityTag", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetEntityTag(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apiissue.ApiIssueClient", "GetEntityTag", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetEntityTag prepares the GetEntityTag request. -func (c ApiIssueClient) preparerForGetEntityTag(ctx context.Context, id ApiIssueId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsHead(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetEntityTag handles the response to the GetEntityTag request. The method always -// closes the http.Response Body. -func (c ApiIssueClient) responderForGetEntityTag(resp *http.Response) (result GetEntityTagOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2021-08-01/apiissue/method_listbyservice.go b/resource-manager/apimanagement/2021-08-01/apiissue/method_listbyservice.go new file mode 100644 index 00000000000..faa0de569c6 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/apiissue/method_listbyservice.go @@ -0,0 +1,129 @@ +package apiissue + +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 ListByServiceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]IssueContract +} + +type ListByServiceCompleteResult struct { + Items []IssueContract +} + +type ListByServiceOperationOptions struct { + ExpandCommentsAttachments *bool + Filter *string + Skip *int64 + Top *int64 +} + +func DefaultListByServiceOperationOptions() ListByServiceOperationOptions { + return ListByServiceOperationOptions{} +} + +func (o ListByServiceOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListByServiceOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListByServiceOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.ExpandCommentsAttachments != nil { + out.Append("expandCommentsAttachments", fmt.Sprintf("%v", *o.ExpandCommentsAttachments)) + } + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.Skip != nil { + out.Append("$skip", fmt.Sprintf("%v", *o.Skip)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +// ListByService ... +func (c ApiIssueClient) ListByService(ctx context.Context, id ApiId, options ListByServiceOperationOptions) (result ListByServiceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/issues", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]IssueContract `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByServiceComplete retrieves all the results into a single object +func (c ApiIssueClient) ListByServiceComplete(ctx context.Context, id ApiId, options ListByServiceOperationOptions) (ListByServiceCompleteResult, error) { + return c.ListByServiceCompleteMatchingPredicate(ctx, id, options, IssueContractOperationPredicate{}) +} + +// ListByServiceCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ApiIssueClient) ListByServiceCompleteMatchingPredicate(ctx context.Context, id ApiId, options ListByServiceOperationOptions, predicate IssueContractOperationPredicate) (result ListByServiceCompleteResult, err error) { + items := make([]IssueContract, 0) + + resp, err := c.ListByService(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByServiceCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/apimanagement/2021-08-01/apiissue/method_listbyservice_autorest.go b/resource-manager/apimanagement/2021-08-01/apiissue/method_listbyservice_autorest.go deleted file mode 100644 index 48b3a2c6d18..00000000000 --- a/resource-manager/apimanagement/2021-08-01/apiissue/method_listbyservice_autorest.go +++ /dev/null @@ -1,230 +0,0 @@ -package apiissue - -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 ListByServiceOperationResponse struct { - HttpResponse *http.Response - Model *[]IssueContract - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListByServiceOperationResponse, error) -} - -type ListByServiceCompleteResult struct { - Items []IssueContract -} - -func (r ListByServiceOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListByServiceOperationResponse) LoadMore(ctx context.Context) (resp ListByServiceOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -type ListByServiceOperationOptions struct { - ExpandCommentsAttachments *bool - Filter *string - Skip *int64 - Top *int64 -} - -func DefaultListByServiceOperationOptions() ListByServiceOperationOptions { - return ListByServiceOperationOptions{} -} - -func (o ListByServiceOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o ListByServiceOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.ExpandCommentsAttachments != nil { - out["expandCommentsAttachments"] = *o.ExpandCommentsAttachments - } - - if o.Filter != nil { - out["$filter"] = *o.Filter - } - - if o.Skip != nil { - out["$skip"] = *o.Skip - } - - if o.Top != nil { - out["$top"] = *o.Top - } - - return out -} - -// ListByService ... -func (c ApiIssueClient) ListByService(ctx context.Context, id ApiId, options ListByServiceOperationOptions) (resp ListByServiceOperationResponse, err error) { - req, err := c.preparerForListByService(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "apiissue.ApiIssueClient", "ListByService", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apiissue.ApiIssueClient", "ListByService", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListByService(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apiissue.ApiIssueClient", "ListByService", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListByService prepares the ListByService request. -func (c ApiIssueClient) preparerForListByService(ctx context.Context, id ApiId, options ListByServiceOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/issues", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListByServiceWithNextLink prepares the ListByService request with the given nextLink token. -func (c ApiIssueClient) preparerForListByServiceWithNextLink(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)) -} - -// responderForListByService handles the response to the ListByService request. The method always -// closes the http.Response Body. -func (c ApiIssueClient) responderForListByService(resp *http.Response) (result ListByServiceOperationResponse, err error) { - type page struct { - Values []IssueContract `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 ListByServiceOperationResponse, err error) { - req, err := c.preparerForListByServiceWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "apiissue.ApiIssueClient", "ListByService", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apiissue.ApiIssueClient", "ListByService", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByService(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apiissue.ApiIssueClient", "ListByService", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListByServiceComplete retrieves all of the results into a single object -func (c ApiIssueClient) ListByServiceComplete(ctx context.Context, id ApiId, options ListByServiceOperationOptions) (ListByServiceCompleteResult, error) { - return c.ListByServiceCompleteMatchingPredicate(ctx, id, options, IssueContractOperationPredicate{}) -} - -// ListByServiceCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c ApiIssueClient) ListByServiceCompleteMatchingPredicate(ctx context.Context, id ApiId, options ListByServiceOperationOptions, predicate IssueContractOperationPredicate) (resp ListByServiceCompleteResult, err error) { - items := make([]IssueContract, 0) - - page, err := c.ListByService(ctx, id, options) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListByServiceCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/apimanagement/2021-08-01/apiissue/method_update.go b/resource-manager/apimanagement/2021-08-01/apiissue/method_update.go new file mode 100644 index 00000000000..584e3d7d164 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/apiissue/method_update.go @@ -0,0 +1,84 @@ +package apiissue + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *IssueContract +} + +type UpdateOperationOptions struct { + IfMatch *string +} + +func DefaultUpdateOperationOptions() UpdateOperationOptions { + return UpdateOperationOptions{} +} + +func (o UpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o UpdateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o UpdateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// Update ... +func (c ApiIssueClient) Update(ctx context.Context, id ApiIssueId, input IssueUpdateContract, options UpdateOperationOptions) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + OptionsObject: options, + } + + 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/apimanagement/2021-08-01/apiissue/method_update_autorest.go b/resource-manager/apimanagement/2021-08-01/apiissue/method_update_autorest.go deleted file mode 100644 index f2e65e33867..00000000000 --- a/resource-manager/apimanagement/2021-08-01/apiissue/method_update_autorest.go +++ /dev/null @@ -1,98 +0,0 @@ -package apiissue - -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 *IssueContract -} - -type UpdateOperationOptions struct { - IfMatch *string -} - -func DefaultUpdateOperationOptions() UpdateOperationOptions { - return UpdateOperationOptions{} -} - -func (o UpdateOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o UpdateOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// Update ... -func (c ApiIssueClient) Update(ctx context.Context, id ApiIssueId, input IssueUpdateContract, options UpdateOperationOptions) (result UpdateOperationResponse, err error) { - req, err := c.preparerForUpdate(ctx, id, input, options) - if err != nil { - err = autorest.NewErrorWithError(err, "apiissue.ApiIssueClient", "Update", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apiissue.ApiIssueClient", "Update", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apiissue.ApiIssueClient", "Update", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForUpdate prepares the Update request. -func (c ApiIssueClient) preparerForUpdate(ctx context.Context, id ApiIssueId, input IssueUpdateContract, options UpdateOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPatch(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - 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 ApiIssueClient) 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/apimanagement/2021-08-01/apiissueattachment/client.go b/resource-manager/apimanagement/2021-08-01/apiissueattachment/client.go index 603bab63d7c..8defa3dd09b 100644 --- a/resource-manager/apimanagement/2021-08-01/apiissueattachment/client.go +++ b/resource-manager/apimanagement/2021-08-01/apiissueattachment/client.go @@ -1,18 +1,26 @@ package apiissueattachment -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 ApiIssueAttachmentClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewApiIssueAttachmentClientWithBaseURI(endpoint string) ApiIssueAttachmentClient { - return ApiIssueAttachmentClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewApiIssueAttachmentClientWithBaseURI(api environments.Api) (*ApiIssueAttachmentClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "apiissueattachment", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ApiIssueAttachmentClient: %+v", err) } + + return &ApiIssueAttachmentClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2021-08-01/apiissueattachment/method_createorupdate.go b/resource-manager/apimanagement/2021-08-01/apiissueattachment/method_createorupdate.go new file mode 100644 index 00000000000..9b38974fd6c --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/apiissueattachment/method_createorupdate.go @@ -0,0 +1,85 @@ +package apiissueattachment + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *IssueAttachmentContract +} + +type CreateOrUpdateOperationOptions struct { + IfMatch *string +} + +func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { + return CreateOrUpdateOperationOptions{} +} + +func (o CreateOrUpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o CreateOrUpdateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o CreateOrUpdateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// CreateOrUpdate ... +func (c ApiIssueAttachmentClient) CreateOrUpdate(ctx context.Context, id AttachmentId, input IssueAttachmentContract, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + OptionsObject: options, + } + + 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/apimanagement/2021-08-01/apiissueattachment/method_createorupdate_autorest.go b/resource-manager/apimanagement/2021-08-01/apiissueattachment/method_createorupdate_autorest.go deleted file mode 100644 index 0d3c8faed1f..00000000000 --- a/resource-manager/apimanagement/2021-08-01/apiissueattachment/method_createorupdate_autorest.go +++ /dev/null @@ -1,98 +0,0 @@ -package apiissueattachment - -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 *IssueAttachmentContract -} - -type CreateOrUpdateOperationOptions struct { - IfMatch *string -} - -func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { - return CreateOrUpdateOperationOptions{} -} - -func (o CreateOrUpdateOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o CreateOrUpdateOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// CreateOrUpdate ... -func (c ApiIssueAttachmentClient) CreateOrUpdate(ctx context.Context, id AttachmentId, input IssueAttachmentContract, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdate(ctx, id, input, options) - if err != nil { - err = autorest.NewErrorWithError(err, "apiissueattachment.ApiIssueAttachmentClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apiissueattachment.ApiIssueAttachmentClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCreateOrUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apiissueattachment.ApiIssueAttachmentClient", "CreateOrUpdate", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCreateOrUpdate prepares the CreateOrUpdate request. -func (c ApiIssueAttachmentClient) preparerForCreateOrUpdate(ctx context.Context, id AttachmentId, input IssueAttachmentContract, options CreateOrUpdateOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - 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 ApiIssueAttachmentClient) responderForCreateOrUpdate(resp *http.Response) (result CreateOrUpdateOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2021-08-01/apiissueattachment/method_delete.go b/resource-manager/apimanagement/2021-08-01/apiissueattachment/method_delete.go new file mode 100644 index 00000000000..e2c80a156a2 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/apiissueattachment/method_delete.go @@ -0,0 +1,76 @@ +package apiissueattachment + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +type DeleteOperationOptions struct { + IfMatch *string +} + +func DefaultDeleteOperationOptions() DeleteOperationOptions { + return DeleteOperationOptions{} +} + +func (o DeleteOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o DeleteOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o DeleteOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// Delete ... +func (c ApiIssueAttachmentClient) Delete(ctx context.Context, id AttachmentId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2021-08-01/apiissueattachment/method_delete_autorest.go b/resource-manager/apimanagement/2021-08-01/apiissueattachment/method_delete_autorest.go deleted file mode 100644 index 0c1c547304e..00000000000 --- a/resource-manager/apimanagement/2021-08-01/apiissueattachment/method_delete_autorest.go +++ /dev/null @@ -1,95 +0,0 @@ -package apiissueattachment - -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 DeleteOperationResponse struct { - HttpResponse *http.Response -} - -type DeleteOperationOptions struct { - IfMatch *string -} - -func DefaultDeleteOperationOptions() DeleteOperationOptions { - return DeleteOperationOptions{} -} - -func (o DeleteOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o DeleteOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// Delete ... -func (c ApiIssueAttachmentClient) Delete(ctx context.Context, id AttachmentId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { - req, err := c.preparerForDelete(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "apiissueattachment.ApiIssueAttachmentClient", "Delete", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apiissueattachment.ApiIssueAttachmentClient", "Delete", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForDelete(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apiissueattachment.ApiIssueAttachmentClient", "Delete", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForDelete prepares the Delete request. -func (c ApiIssueAttachmentClient) preparerForDelete(ctx context.Context, id AttachmentId, options DeleteOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForDelete handles the response to the Delete request. The method always -// closes the http.Response Body. -func (c ApiIssueAttachmentClient) responderForDelete(resp *http.Response) (result DeleteOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2021-08-01/apiissueattachment/method_get.go b/resource-manager/apimanagement/2021-08-01/apiissueattachment/method_get.go new file mode 100644 index 00000000000..3e35f0e3c03 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/apiissueattachment/method_get.go @@ -0,0 +1,51 @@ +package apiissueattachment + +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 *IssueAttachmentContract +} + +// Get ... +func (c ApiIssueAttachmentClient) Get(ctx context.Context, id AttachmentId) (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/apimanagement/2021-08-01/apiissueattachment/method_get_autorest.go b/resource-manager/apimanagement/2021-08-01/apiissueattachment/method_get_autorest.go deleted file mode 100644 index cf5a5442e8f..00000000000 --- a/resource-manager/apimanagement/2021-08-01/apiissueattachment/method_get_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package apiissueattachment - -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 *IssueAttachmentContract -} - -// Get ... -func (c ApiIssueAttachmentClient) Get(ctx context.Context, id AttachmentId) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "apiissueattachment.ApiIssueAttachmentClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apiissueattachment.ApiIssueAttachmentClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apiissueattachment.ApiIssueAttachmentClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c ApiIssueAttachmentClient) preparerForGet(ctx context.Context, id AttachmentId) (*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 ApiIssueAttachmentClient) 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/apimanagement/2021-08-01/apiissueattachment/method_getentitytag.go b/resource-manager/apimanagement/2021-08-01/apiissueattachment/method_getentitytag.go new file mode 100644 index 00000000000..417b3e0b9bd --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/apiissueattachment/method_getentitytag.go @@ -0,0 +1,46 @@ +package apiissueattachment + +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 GetEntityTagOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// GetEntityTag ... +func (c ApiIssueAttachmentClient) GetEntityTag(ctx context.Context, id AttachmentId) (result GetEntityTagOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodHead, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2021-08-01/apiissueattachment/method_getentitytag_autorest.go b/resource-manager/apimanagement/2021-08-01/apiissueattachment/method_getentitytag_autorest.go deleted file mode 100644 index 24756f5be27..00000000000 --- a/resource-manager/apimanagement/2021-08-01/apiissueattachment/method_getentitytag_autorest.go +++ /dev/null @@ -1,66 +0,0 @@ -package apiissueattachment - -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 GetEntityTagOperationResponse struct { - HttpResponse *http.Response -} - -// GetEntityTag ... -func (c ApiIssueAttachmentClient) GetEntityTag(ctx context.Context, id AttachmentId) (result GetEntityTagOperationResponse, err error) { - req, err := c.preparerForGetEntityTag(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "apiissueattachment.ApiIssueAttachmentClient", "GetEntityTag", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apiissueattachment.ApiIssueAttachmentClient", "GetEntityTag", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetEntityTag(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apiissueattachment.ApiIssueAttachmentClient", "GetEntityTag", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetEntityTag prepares the GetEntityTag request. -func (c ApiIssueAttachmentClient) preparerForGetEntityTag(ctx context.Context, id AttachmentId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsHead(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetEntityTag handles the response to the GetEntityTag request. The method always -// closes the http.Response Body. -func (c ApiIssueAttachmentClient) responderForGetEntityTag(resp *http.Response) (result GetEntityTagOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2021-08-01/apiissueattachment/method_listbyservice.go b/resource-manager/apimanagement/2021-08-01/apiissueattachment/method_listbyservice.go new file mode 100644 index 00000000000..bda7001b3ab --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/apiissueattachment/method_listbyservice.go @@ -0,0 +1,125 @@ +package apiissueattachment + +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 ListByServiceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]IssueAttachmentContract +} + +type ListByServiceCompleteResult struct { + Items []IssueAttachmentContract +} + +type ListByServiceOperationOptions struct { + Filter *string + Skip *int64 + Top *int64 +} + +func DefaultListByServiceOperationOptions() ListByServiceOperationOptions { + return ListByServiceOperationOptions{} +} + +func (o ListByServiceOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListByServiceOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListByServiceOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.Skip != nil { + out.Append("$skip", fmt.Sprintf("%v", *o.Skip)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +// ListByService ... +func (c ApiIssueAttachmentClient) ListByService(ctx context.Context, id ApiIssueId, options ListByServiceOperationOptions) (result ListByServiceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/attachments", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]IssueAttachmentContract `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByServiceComplete retrieves all the results into a single object +func (c ApiIssueAttachmentClient) ListByServiceComplete(ctx context.Context, id ApiIssueId, options ListByServiceOperationOptions) (ListByServiceCompleteResult, error) { + return c.ListByServiceCompleteMatchingPredicate(ctx, id, options, IssueAttachmentContractOperationPredicate{}) +} + +// ListByServiceCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ApiIssueAttachmentClient) ListByServiceCompleteMatchingPredicate(ctx context.Context, id ApiIssueId, options ListByServiceOperationOptions, predicate IssueAttachmentContractOperationPredicate) (result ListByServiceCompleteResult, err error) { + items := make([]IssueAttachmentContract, 0) + + resp, err := c.ListByService(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByServiceCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/apimanagement/2021-08-01/apiissueattachment/method_listbyservice_autorest.go b/resource-manager/apimanagement/2021-08-01/apiissueattachment/method_listbyservice_autorest.go deleted file mode 100644 index 8decbc696ea..00000000000 --- a/resource-manager/apimanagement/2021-08-01/apiissueattachment/method_listbyservice_autorest.go +++ /dev/null @@ -1,225 +0,0 @@ -package apiissueattachment - -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 ListByServiceOperationResponse struct { - HttpResponse *http.Response - Model *[]IssueAttachmentContract - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListByServiceOperationResponse, error) -} - -type ListByServiceCompleteResult struct { - Items []IssueAttachmentContract -} - -func (r ListByServiceOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListByServiceOperationResponse) LoadMore(ctx context.Context) (resp ListByServiceOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -type ListByServiceOperationOptions struct { - Filter *string - Skip *int64 - Top *int64 -} - -func DefaultListByServiceOperationOptions() ListByServiceOperationOptions { - return ListByServiceOperationOptions{} -} - -func (o ListByServiceOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o ListByServiceOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Filter != nil { - out["$filter"] = *o.Filter - } - - if o.Skip != nil { - out["$skip"] = *o.Skip - } - - if o.Top != nil { - out["$top"] = *o.Top - } - - return out -} - -// ListByService ... -func (c ApiIssueAttachmentClient) ListByService(ctx context.Context, id ApiIssueId, options ListByServiceOperationOptions) (resp ListByServiceOperationResponse, err error) { - req, err := c.preparerForListByService(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "apiissueattachment.ApiIssueAttachmentClient", "ListByService", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apiissueattachment.ApiIssueAttachmentClient", "ListByService", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListByService(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apiissueattachment.ApiIssueAttachmentClient", "ListByService", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListByService prepares the ListByService request. -func (c ApiIssueAttachmentClient) preparerForListByService(ctx context.Context, id ApiIssueId, options ListByServiceOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/attachments", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListByServiceWithNextLink prepares the ListByService request with the given nextLink token. -func (c ApiIssueAttachmentClient) preparerForListByServiceWithNextLink(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)) -} - -// responderForListByService handles the response to the ListByService request. The method always -// closes the http.Response Body. -func (c ApiIssueAttachmentClient) responderForListByService(resp *http.Response) (result ListByServiceOperationResponse, err error) { - type page struct { - Values []IssueAttachmentContract `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 ListByServiceOperationResponse, err error) { - req, err := c.preparerForListByServiceWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "apiissueattachment.ApiIssueAttachmentClient", "ListByService", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apiissueattachment.ApiIssueAttachmentClient", "ListByService", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByService(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apiissueattachment.ApiIssueAttachmentClient", "ListByService", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListByServiceComplete retrieves all of the results into a single object -func (c ApiIssueAttachmentClient) ListByServiceComplete(ctx context.Context, id ApiIssueId, options ListByServiceOperationOptions) (ListByServiceCompleteResult, error) { - return c.ListByServiceCompleteMatchingPredicate(ctx, id, options, IssueAttachmentContractOperationPredicate{}) -} - -// ListByServiceCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c ApiIssueAttachmentClient) ListByServiceCompleteMatchingPredicate(ctx context.Context, id ApiIssueId, options ListByServiceOperationOptions, predicate IssueAttachmentContractOperationPredicate) (resp ListByServiceCompleteResult, err error) { - items := make([]IssueAttachmentContract, 0) - - page, err := c.ListByService(ctx, id, options) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListByServiceCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/apimanagement/2021-08-01/apiissuecomment/client.go b/resource-manager/apimanagement/2021-08-01/apiissuecomment/client.go index c2d875d616a..0628382d8fb 100644 --- a/resource-manager/apimanagement/2021-08-01/apiissuecomment/client.go +++ b/resource-manager/apimanagement/2021-08-01/apiissuecomment/client.go @@ -1,18 +1,26 @@ package apiissuecomment -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 ApiIssueCommentClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewApiIssueCommentClientWithBaseURI(endpoint string) ApiIssueCommentClient { - return ApiIssueCommentClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewApiIssueCommentClientWithBaseURI(api environments.Api) (*ApiIssueCommentClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "apiissuecomment", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ApiIssueCommentClient: %+v", err) } + + return &ApiIssueCommentClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2021-08-01/apiissuecomment/method_createorupdate.go b/resource-manager/apimanagement/2021-08-01/apiissuecomment/method_createorupdate.go new file mode 100644 index 00000000000..4151626f6b6 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/apiissuecomment/method_createorupdate.go @@ -0,0 +1,85 @@ +package apiissuecomment + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *IssueCommentContract +} + +type CreateOrUpdateOperationOptions struct { + IfMatch *string +} + +func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { + return CreateOrUpdateOperationOptions{} +} + +func (o CreateOrUpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o CreateOrUpdateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o CreateOrUpdateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// CreateOrUpdate ... +func (c ApiIssueCommentClient) CreateOrUpdate(ctx context.Context, id CommentId, input IssueCommentContract, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + OptionsObject: options, + } + + 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/apimanagement/2021-08-01/apiissuecomment/method_createorupdate_autorest.go b/resource-manager/apimanagement/2021-08-01/apiissuecomment/method_createorupdate_autorest.go deleted file mode 100644 index 4b1b3d4e955..00000000000 --- a/resource-manager/apimanagement/2021-08-01/apiissuecomment/method_createorupdate_autorest.go +++ /dev/null @@ -1,98 +0,0 @@ -package apiissuecomment - -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 *IssueCommentContract -} - -type CreateOrUpdateOperationOptions struct { - IfMatch *string -} - -func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { - return CreateOrUpdateOperationOptions{} -} - -func (o CreateOrUpdateOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o CreateOrUpdateOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// CreateOrUpdate ... -func (c ApiIssueCommentClient) CreateOrUpdate(ctx context.Context, id CommentId, input IssueCommentContract, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdate(ctx, id, input, options) - if err != nil { - err = autorest.NewErrorWithError(err, "apiissuecomment.ApiIssueCommentClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apiissuecomment.ApiIssueCommentClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCreateOrUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apiissuecomment.ApiIssueCommentClient", "CreateOrUpdate", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCreateOrUpdate prepares the CreateOrUpdate request. -func (c ApiIssueCommentClient) preparerForCreateOrUpdate(ctx context.Context, id CommentId, input IssueCommentContract, options CreateOrUpdateOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - 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 ApiIssueCommentClient) responderForCreateOrUpdate(resp *http.Response) (result CreateOrUpdateOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2021-08-01/apiissuecomment/method_delete.go b/resource-manager/apimanagement/2021-08-01/apiissuecomment/method_delete.go new file mode 100644 index 00000000000..b6cb1c7f69b --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/apiissuecomment/method_delete.go @@ -0,0 +1,76 @@ +package apiissuecomment + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +type DeleteOperationOptions struct { + IfMatch *string +} + +func DefaultDeleteOperationOptions() DeleteOperationOptions { + return DeleteOperationOptions{} +} + +func (o DeleteOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o DeleteOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o DeleteOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// Delete ... +func (c ApiIssueCommentClient) Delete(ctx context.Context, id CommentId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2021-08-01/apiissuecomment/method_delete_autorest.go b/resource-manager/apimanagement/2021-08-01/apiissuecomment/method_delete_autorest.go deleted file mode 100644 index ae7d6a12be4..00000000000 --- a/resource-manager/apimanagement/2021-08-01/apiissuecomment/method_delete_autorest.go +++ /dev/null @@ -1,95 +0,0 @@ -package apiissuecomment - -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 DeleteOperationResponse struct { - HttpResponse *http.Response -} - -type DeleteOperationOptions struct { - IfMatch *string -} - -func DefaultDeleteOperationOptions() DeleteOperationOptions { - return DeleteOperationOptions{} -} - -func (o DeleteOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o DeleteOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// Delete ... -func (c ApiIssueCommentClient) Delete(ctx context.Context, id CommentId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { - req, err := c.preparerForDelete(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "apiissuecomment.ApiIssueCommentClient", "Delete", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apiissuecomment.ApiIssueCommentClient", "Delete", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForDelete(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apiissuecomment.ApiIssueCommentClient", "Delete", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForDelete prepares the Delete request. -func (c ApiIssueCommentClient) preparerForDelete(ctx context.Context, id CommentId, options DeleteOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForDelete handles the response to the Delete request. The method always -// closes the http.Response Body. -func (c ApiIssueCommentClient) responderForDelete(resp *http.Response) (result DeleteOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2021-08-01/apiissuecomment/method_get.go b/resource-manager/apimanagement/2021-08-01/apiissuecomment/method_get.go new file mode 100644 index 00000000000..df6ff41fb18 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/apiissuecomment/method_get.go @@ -0,0 +1,51 @@ +package apiissuecomment + +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 *IssueCommentContract +} + +// Get ... +func (c ApiIssueCommentClient) Get(ctx context.Context, id CommentId) (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/apimanagement/2021-08-01/apiissuecomment/method_get_autorest.go b/resource-manager/apimanagement/2021-08-01/apiissuecomment/method_get_autorest.go deleted file mode 100644 index 97cae9d1ac1..00000000000 --- a/resource-manager/apimanagement/2021-08-01/apiissuecomment/method_get_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package apiissuecomment - -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 *IssueCommentContract -} - -// Get ... -func (c ApiIssueCommentClient) Get(ctx context.Context, id CommentId) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "apiissuecomment.ApiIssueCommentClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apiissuecomment.ApiIssueCommentClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apiissuecomment.ApiIssueCommentClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c ApiIssueCommentClient) preparerForGet(ctx context.Context, id CommentId) (*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 ApiIssueCommentClient) 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/apimanagement/2021-08-01/apiissuecomment/method_getentitytag.go b/resource-manager/apimanagement/2021-08-01/apiissuecomment/method_getentitytag.go new file mode 100644 index 00000000000..a5ce802f723 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/apiissuecomment/method_getentitytag.go @@ -0,0 +1,46 @@ +package apiissuecomment + +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 GetEntityTagOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// GetEntityTag ... +func (c ApiIssueCommentClient) GetEntityTag(ctx context.Context, id CommentId) (result GetEntityTagOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodHead, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2021-08-01/apiissuecomment/method_getentitytag_autorest.go b/resource-manager/apimanagement/2021-08-01/apiissuecomment/method_getentitytag_autorest.go deleted file mode 100644 index 7793e44727b..00000000000 --- a/resource-manager/apimanagement/2021-08-01/apiissuecomment/method_getentitytag_autorest.go +++ /dev/null @@ -1,66 +0,0 @@ -package apiissuecomment - -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 GetEntityTagOperationResponse struct { - HttpResponse *http.Response -} - -// GetEntityTag ... -func (c ApiIssueCommentClient) GetEntityTag(ctx context.Context, id CommentId) (result GetEntityTagOperationResponse, err error) { - req, err := c.preparerForGetEntityTag(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "apiissuecomment.ApiIssueCommentClient", "GetEntityTag", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apiissuecomment.ApiIssueCommentClient", "GetEntityTag", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetEntityTag(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apiissuecomment.ApiIssueCommentClient", "GetEntityTag", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetEntityTag prepares the GetEntityTag request. -func (c ApiIssueCommentClient) preparerForGetEntityTag(ctx context.Context, id CommentId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsHead(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetEntityTag handles the response to the GetEntityTag request. The method always -// closes the http.Response Body. -func (c ApiIssueCommentClient) responderForGetEntityTag(resp *http.Response) (result GetEntityTagOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2021-08-01/apiissuecomment/method_listbyservice.go b/resource-manager/apimanagement/2021-08-01/apiissuecomment/method_listbyservice.go new file mode 100644 index 00000000000..3240d518d9c --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/apiissuecomment/method_listbyservice.go @@ -0,0 +1,125 @@ +package apiissuecomment + +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 ListByServiceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]IssueCommentContract +} + +type ListByServiceCompleteResult struct { + Items []IssueCommentContract +} + +type ListByServiceOperationOptions struct { + Filter *string + Skip *int64 + Top *int64 +} + +func DefaultListByServiceOperationOptions() ListByServiceOperationOptions { + return ListByServiceOperationOptions{} +} + +func (o ListByServiceOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListByServiceOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListByServiceOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.Skip != nil { + out.Append("$skip", fmt.Sprintf("%v", *o.Skip)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +// ListByService ... +func (c ApiIssueCommentClient) ListByService(ctx context.Context, id ApiIssueId, options ListByServiceOperationOptions) (result ListByServiceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/comments", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]IssueCommentContract `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByServiceComplete retrieves all the results into a single object +func (c ApiIssueCommentClient) ListByServiceComplete(ctx context.Context, id ApiIssueId, options ListByServiceOperationOptions) (ListByServiceCompleteResult, error) { + return c.ListByServiceCompleteMatchingPredicate(ctx, id, options, IssueCommentContractOperationPredicate{}) +} + +// ListByServiceCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ApiIssueCommentClient) ListByServiceCompleteMatchingPredicate(ctx context.Context, id ApiIssueId, options ListByServiceOperationOptions, predicate IssueCommentContractOperationPredicate) (result ListByServiceCompleteResult, err error) { + items := make([]IssueCommentContract, 0) + + resp, err := c.ListByService(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByServiceCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/apimanagement/2021-08-01/apiissuecomment/method_listbyservice_autorest.go b/resource-manager/apimanagement/2021-08-01/apiissuecomment/method_listbyservice_autorest.go deleted file mode 100644 index 3057cba0d58..00000000000 --- a/resource-manager/apimanagement/2021-08-01/apiissuecomment/method_listbyservice_autorest.go +++ /dev/null @@ -1,225 +0,0 @@ -package apiissuecomment - -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 ListByServiceOperationResponse struct { - HttpResponse *http.Response - Model *[]IssueCommentContract - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListByServiceOperationResponse, error) -} - -type ListByServiceCompleteResult struct { - Items []IssueCommentContract -} - -func (r ListByServiceOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListByServiceOperationResponse) LoadMore(ctx context.Context) (resp ListByServiceOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -type ListByServiceOperationOptions struct { - Filter *string - Skip *int64 - Top *int64 -} - -func DefaultListByServiceOperationOptions() ListByServiceOperationOptions { - return ListByServiceOperationOptions{} -} - -func (o ListByServiceOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o ListByServiceOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Filter != nil { - out["$filter"] = *o.Filter - } - - if o.Skip != nil { - out["$skip"] = *o.Skip - } - - if o.Top != nil { - out["$top"] = *o.Top - } - - return out -} - -// ListByService ... -func (c ApiIssueCommentClient) ListByService(ctx context.Context, id ApiIssueId, options ListByServiceOperationOptions) (resp ListByServiceOperationResponse, err error) { - req, err := c.preparerForListByService(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "apiissuecomment.ApiIssueCommentClient", "ListByService", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apiissuecomment.ApiIssueCommentClient", "ListByService", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListByService(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apiissuecomment.ApiIssueCommentClient", "ListByService", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListByService prepares the ListByService request. -func (c ApiIssueCommentClient) preparerForListByService(ctx context.Context, id ApiIssueId, options ListByServiceOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/comments", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListByServiceWithNextLink prepares the ListByService request with the given nextLink token. -func (c ApiIssueCommentClient) preparerForListByServiceWithNextLink(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)) -} - -// responderForListByService handles the response to the ListByService request. The method always -// closes the http.Response Body. -func (c ApiIssueCommentClient) responderForListByService(resp *http.Response) (result ListByServiceOperationResponse, err error) { - type page struct { - Values []IssueCommentContract `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 ListByServiceOperationResponse, err error) { - req, err := c.preparerForListByServiceWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "apiissuecomment.ApiIssueCommentClient", "ListByService", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apiissuecomment.ApiIssueCommentClient", "ListByService", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByService(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apiissuecomment.ApiIssueCommentClient", "ListByService", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListByServiceComplete retrieves all of the results into a single object -func (c ApiIssueCommentClient) ListByServiceComplete(ctx context.Context, id ApiIssueId, options ListByServiceOperationOptions) (ListByServiceCompleteResult, error) { - return c.ListByServiceCompleteMatchingPredicate(ctx, id, options, IssueCommentContractOperationPredicate{}) -} - -// ListByServiceCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c ApiIssueCommentClient) ListByServiceCompleteMatchingPredicate(ctx context.Context, id ApiIssueId, options ListByServiceOperationOptions, predicate IssueCommentContractOperationPredicate) (resp ListByServiceCompleteResult, err error) { - items := make([]IssueCommentContract, 0) - - page, err := c.ListByService(ctx, id, options) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListByServiceCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/apimanagement/2021-08-01/apimanagementservice/client.go b/resource-manager/apimanagement/2021-08-01/apimanagementservice/client.go index b6859cfd757..b7a7fbab358 100644 --- a/resource-manager/apimanagement/2021-08-01/apimanagementservice/client.go +++ b/resource-manager/apimanagement/2021-08-01/apimanagementservice/client.go @@ -1,18 +1,26 @@ package apimanagementservice -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 ApiManagementServiceClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewApiManagementServiceClientWithBaseURI(endpoint string) ApiManagementServiceClient { - return ApiManagementServiceClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewApiManagementServiceClientWithBaseURI(api environments.Api) (*ApiManagementServiceClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "apimanagementservice", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ApiManagementServiceClient: %+v", err) } + + return &ApiManagementServiceClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2021-08-01/apimanagementservice/constants.go b/resource-manager/apimanagement/2021-08-01/apimanagementservice/constants.go index a263c7d5663..2828a0eda16 100644 --- a/resource-manager/apimanagement/2021-08-01/apimanagementservice/constants.go +++ b/resource-manager/apimanagement/2021-08-01/apimanagementservice/constants.go @@ -1,6 +1,10 @@ package apimanagementservice -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 PossibleValuesForAccessType() []string { } } +func (s *AccessType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAccessType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseAccessType(input string) (*AccessType, error) { vals := map[string]AccessType{ "accesskey": AccessTypeAccessKey, @@ -54,6 +71,19 @@ func PossibleValuesForCertificateSource() []string { } } +func (s *CertificateSource) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCertificateSource(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseCertificateSource(input string) (*CertificateSource, error) { vals := map[string]CertificateSource{ "builtin": CertificateSourceBuiltIn, @@ -86,6 +116,19 @@ func PossibleValuesForCertificateStatus() []string { } } +func (s *CertificateStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCertificateStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseCertificateStatus(input string) (*CertificateStatus, error) { vals := map[string]CertificateStatus{ "completed": CertificateStatusCompleted, @@ -121,6 +164,19 @@ func PossibleValuesForHostnameType() []string { } } +func (s *HostnameType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseHostnameType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseHostnameType(input string) (*HostnameType, error) { vals := map[string]HostnameType{ "developerportal": HostnameTypeDeveloperPortal, @@ -154,6 +210,19 @@ func PossibleValuesForNameAvailabilityReason() []string { } } +func (s *NameAvailabilityReason) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNameAvailabilityReason(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseNameAvailabilityReason(input string) (*NameAvailabilityReason, error) { vals := map[string]NameAvailabilityReason{ "alreadyexists": NameAvailabilityReasonAlreadyExists, @@ -187,6 +256,19 @@ func PossibleValuesForPlatformVersion() []string { } } +func (s *PlatformVersion) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePlatformVersion(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parsePlatformVersion(input string) (*PlatformVersion, error) { vals := map[string]PlatformVersion{ "mtv1": PlatformVersionMtvOne, @@ -219,6 +301,19 @@ func PossibleValuesForPrivateEndpointServiceConnectionStatus() []string { } } +func (s *PrivateEndpointServiceConnectionStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePrivateEndpointServiceConnectionStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parsePrivateEndpointServiceConnectionStatus(input string) (*PrivateEndpointServiceConnectionStatus, error) { vals := map[string]PrivateEndpointServiceConnectionStatus{ "approved": PrivateEndpointServiceConnectionStatusApproved, @@ -248,6 +343,19 @@ func PossibleValuesForPublicNetworkAccess() []string { } } +func (s *PublicNetworkAccess) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePublicNetworkAccess(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parsePublicNetworkAccess(input string) (*PublicNetworkAccess, error) { vals := map[string]PublicNetworkAccess{ "disabled": PublicNetworkAccessDisabled, @@ -284,6 +392,19 @@ func PossibleValuesForSkuType() []string { } } +func (s *SkuType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSkuType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseSkuType(input string) (*SkuType, error) { vals := map[string]SkuType{ "basic": SkuTypeBasic, @@ -316,6 +437,19 @@ func PossibleValuesForStoreName() []string { } } +func (s *StoreName) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseStoreName(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseStoreName(input string) (*StoreName, error) { vals := map[string]StoreName{ "certificateauthority": StoreNameCertificateAuthority, @@ -346,6 +480,19 @@ func PossibleValuesForVirtualNetworkType() []string { } } +func (s *VirtualNetworkType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseVirtualNetworkType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseVirtualNetworkType(input string) (*VirtualNetworkType, error) { vals := map[string]VirtualNetworkType{ "external": VirtualNetworkTypeExternal, diff --git a/resource-manager/apimanagement/2021-08-01/apimanagementservice/method_applynetworkconfigurationupdates.go b/resource-manager/apimanagement/2021-08-01/apimanagementservice/method_applynetworkconfigurationupdates.go new file mode 100644 index 00000000000..47666690d41 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/apimanagementservice/method_applynetworkconfigurationupdates.go @@ -0,0 +1,74 @@ +package apimanagementservice + +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 ApplyNetworkConfigurationUpdatesOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// ApplyNetworkConfigurationUpdates ... +func (c ApiManagementServiceClient) ApplyNetworkConfigurationUpdates(ctx context.Context, id ServiceId, input ApiManagementServiceApplyNetworkConfigurationParameters) (result ApplyNetworkConfigurationUpdatesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/applynetworkconfigurationupdates", 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 +} + +// ApplyNetworkConfigurationUpdatesThenPoll performs ApplyNetworkConfigurationUpdates then polls until it's completed +func (c ApiManagementServiceClient) ApplyNetworkConfigurationUpdatesThenPoll(ctx context.Context, id ServiceId, input ApiManagementServiceApplyNetworkConfigurationParameters) error { + result, err := c.ApplyNetworkConfigurationUpdates(ctx, id, input) + if err != nil { + return fmt.Errorf("performing ApplyNetworkConfigurationUpdates: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after ApplyNetworkConfigurationUpdates: %+v", err) + } + + return nil +} diff --git a/resource-manager/apimanagement/2021-08-01/apimanagementservice/method_applynetworkconfigurationupdates_autorest.go b/resource-manager/apimanagement/2021-08-01/apimanagementservice/method_applynetworkconfigurationupdates_autorest.go deleted file mode 100644 index 7a1a5edef4d..00000000000 --- a/resource-manager/apimanagement/2021-08-01/apimanagementservice/method_applynetworkconfigurationupdates_autorest.go +++ /dev/null @@ -1,79 +0,0 @@ -package apimanagementservice - -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 ApplyNetworkConfigurationUpdatesOperationResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// ApplyNetworkConfigurationUpdates ... -func (c ApiManagementServiceClient) ApplyNetworkConfigurationUpdates(ctx context.Context, id ServiceId, input ApiManagementServiceApplyNetworkConfigurationParameters) (result ApplyNetworkConfigurationUpdatesOperationResponse, err error) { - req, err := c.preparerForApplyNetworkConfigurationUpdates(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "apimanagementservice.ApiManagementServiceClient", "ApplyNetworkConfigurationUpdates", nil, "Failure preparing request") - return - } - - result, err = c.senderForApplyNetworkConfigurationUpdates(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "apimanagementservice.ApiManagementServiceClient", "ApplyNetworkConfigurationUpdates", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// ApplyNetworkConfigurationUpdatesThenPoll performs ApplyNetworkConfigurationUpdates then polls until it's completed -func (c ApiManagementServiceClient) ApplyNetworkConfigurationUpdatesThenPoll(ctx context.Context, id ServiceId, input ApiManagementServiceApplyNetworkConfigurationParameters) error { - result, err := c.ApplyNetworkConfigurationUpdates(ctx, id, input) - if err != nil { - return fmt.Errorf("performing ApplyNetworkConfigurationUpdates: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after ApplyNetworkConfigurationUpdates: %+v", err) - } - - return nil -} - -// preparerForApplyNetworkConfigurationUpdates prepares the ApplyNetworkConfigurationUpdates request. -func (c ApiManagementServiceClient) preparerForApplyNetworkConfigurationUpdates(ctx context.Context, id ServiceId, input ApiManagementServiceApplyNetworkConfigurationParameters) (*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/applynetworkconfigurationupdates", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForApplyNetworkConfigurationUpdates sends the ApplyNetworkConfigurationUpdates request. The method will close the -// http.Response Body if it receives an error. -func (c ApiManagementServiceClient) senderForApplyNetworkConfigurationUpdates(ctx context.Context, req *http.Request) (future ApplyNetworkConfigurationUpdatesOperationResponse, 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/apimanagement/2021-08-01/apimanagementservice/method_backup.go b/resource-manager/apimanagement/2021-08-01/apimanagementservice/method_backup.go new file mode 100644 index 00000000000..2d68d0ef05f --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/apimanagementservice/method_backup.go @@ -0,0 +1,74 @@ +package apimanagementservice + +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 BackupOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Backup ... +func (c ApiManagementServiceClient) Backup(ctx context.Context, id ServiceId, input ApiManagementServiceBackupRestoreParameters) (result BackupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/backup", 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 +} + +// BackupThenPoll performs Backup then polls until it's completed +func (c ApiManagementServiceClient) BackupThenPoll(ctx context.Context, id ServiceId, input ApiManagementServiceBackupRestoreParameters) error { + result, err := c.Backup(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Backup: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Backup: %+v", err) + } + + return nil +} diff --git a/resource-manager/apimanagement/2021-08-01/apimanagementservice/method_backup_autorest.go b/resource-manager/apimanagement/2021-08-01/apimanagementservice/method_backup_autorest.go deleted file mode 100644 index 425460d47a1..00000000000 --- a/resource-manager/apimanagement/2021-08-01/apimanagementservice/method_backup_autorest.go +++ /dev/null @@ -1,79 +0,0 @@ -package apimanagementservice - -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 BackupOperationResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// Backup ... -func (c ApiManagementServiceClient) Backup(ctx context.Context, id ServiceId, input ApiManagementServiceBackupRestoreParameters) (result BackupOperationResponse, err error) { - req, err := c.preparerForBackup(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "apimanagementservice.ApiManagementServiceClient", "Backup", nil, "Failure preparing request") - return - } - - result, err = c.senderForBackup(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "apimanagementservice.ApiManagementServiceClient", "Backup", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// BackupThenPoll performs Backup then polls until it's completed -func (c ApiManagementServiceClient) BackupThenPoll(ctx context.Context, id ServiceId, input ApiManagementServiceBackupRestoreParameters) error { - result, err := c.Backup(ctx, id, input) - if err != nil { - return fmt.Errorf("performing Backup: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after Backup: %+v", err) - } - - return nil -} - -// preparerForBackup prepares the Backup request. -func (c ApiManagementServiceClient) preparerForBackup(ctx context.Context, id ServiceId, input ApiManagementServiceBackupRestoreParameters) (*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/backup", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForBackup sends the Backup request. The method will close the -// http.Response Body if it receives an error. -func (c ApiManagementServiceClient) senderForBackup(ctx context.Context, req *http.Request) (future BackupOperationResponse, 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/apimanagement/2021-08-01/apimanagementservice/method_checknameavailability.go b/resource-manager/apimanagement/2021-08-01/apimanagementservice/method_checknameavailability.go new file mode 100644 index 00000000000..69c30c85560 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/apimanagementservice/method_checknameavailability.go @@ -0,0 +1,57 @@ +package apimanagementservice + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CheckNameAvailabilityOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ApiManagementServiceNameAvailabilityResult +} + +// CheckNameAvailability ... +func (c ApiManagementServiceClient) CheckNameAvailability(ctx context.Context, id commonids.SubscriptionId, input ApiManagementServiceCheckNameAvailabilityParameters) (result CheckNameAvailabilityOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/providers/Microsoft.ApiManagement/checkNameAvailability", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + if err = resp.Unmarshal(&result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2021-08-01/apimanagementservice/method_checknameavailability_autorest.go b/resource-manager/apimanagement/2021-08-01/apimanagementservice/method_checknameavailability_autorest.go deleted file mode 100644 index cd62edeb4a2..00000000000 --- a/resource-manager/apimanagement/2021-08-01/apimanagementservice/method_checknameavailability_autorest.go +++ /dev/null @@ -1,71 +0,0 @@ -package apimanagementservice - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type CheckNameAvailabilityOperationResponse struct { - HttpResponse *http.Response - Model *ApiManagementServiceNameAvailabilityResult -} - -// CheckNameAvailability ... -func (c ApiManagementServiceClient) CheckNameAvailability(ctx context.Context, id commonids.SubscriptionId, input ApiManagementServiceCheckNameAvailabilityParameters) (result CheckNameAvailabilityOperationResponse, err error) { - req, err := c.preparerForCheckNameAvailability(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "apimanagementservice.ApiManagementServiceClient", "CheckNameAvailability", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apimanagementservice.ApiManagementServiceClient", "CheckNameAvailability", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCheckNameAvailability(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apimanagementservice.ApiManagementServiceClient", "CheckNameAvailability", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCheckNameAvailability prepares the CheckNameAvailability request. -func (c ApiManagementServiceClient) preparerForCheckNameAvailability(ctx context.Context, id commonids.SubscriptionId, input ApiManagementServiceCheckNameAvailabilityParameters) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/providers/Microsoft.ApiManagement/checkNameAvailability", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForCheckNameAvailability handles the response to the CheckNameAvailability request. The method always -// closes the http.Response Body. -func (c ApiManagementServiceClient) responderForCheckNameAvailability(resp *http.Response) (result CheckNameAvailabilityOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2021-08-01/apimanagementservice/method_createorupdate.go b/resource-manager/apimanagement/2021-08-01/apimanagementservice/method_createorupdate.go new file mode 100644 index 00000000000..37d9326ce19 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/apimanagementservice/method_createorupdate.go @@ -0,0 +1,75 @@ +package apimanagementservice + +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 +} + +// CreateOrUpdate ... +func (c ApiManagementServiceClient) CreateOrUpdate(ctx context.Context, id ServiceId, input ApiManagementServiceResource) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed +func (c ApiManagementServiceClient) CreateOrUpdateThenPoll(ctx context.Context, id ServiceId, input ApiManagementServiceResource) 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/apimanagement/2021-08-01/apimanagementservice/method_createorupdate_autorest.go b/resource-manager/apimanagement/2021-08-01/apimanagementservice/method_createorupdate_autorest.go deleted file mode 100644 index b374287e28f..00000000000 --- a/resource-manager/apimanagement/2021-08-01/apimanagementservice/method_createorupdate_autorest.go +++ /dev/null @@ -1,79 +0,0 @@ -package apimanagementservice - -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 -} - -// CreateOrUpdate ... -func (c ApiManagementServiceClient) CreateOrUpdate(ctx context.Context, id ServiceId, input ApiManagementServiceResource) (result CreateOrUpdateOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "apimanagementservice.ApiManagementServiceClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result, err = c.senderForCreateOrUpdate(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "apimanagementservice.ApiManagementServiceClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed -func (c ApiManagementServiceClient) CreateOrUpdateThenPoll(ctx context.Context, id ServiceId, input ApiManagementServiceResource) 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 ApiManagementServiceClient) preparerForCreateOrUpdate(ctx context.Context, id ServiceId, input ApiManagementServiceResource) (*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 ApiManagementServiceClient) 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/apimanagement/2021-08-01/apimanagementservice/method_delete.go b/resource-manager/apimanagement/2021-08-01/apimanagementservice/method_delete.go new file mode 100644 index 00000000000..e40cd93940a --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/apimanagementservice/method_delete.go @@ -0,0 +1,71 @@ +package apimanagementservice + +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 ApiManagementServiceClient) 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 ApiManagementServiceClient) 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/apimanagement/2021-08-01/apimanagementservice/method_delete_autorest.go b/resource-manager/apimanagement/2021-08-01/apimanagementservice/method_delete_autorest.go deleted file mode 100644 index c8aa7ccb600..00000000000 --- a/resource-manager/apimanagement/2021-08-01/apimanagementservice/method_delete_autorest.go +++ /dev/null @@ -1,78 +0,0 @@ -package apimanagementservice - -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 ApiManagementServiceClient) Delete(ctx context.Context, id ServiceId) (result DeleteOperationResponse, err error) { - req, err := c.preparerForDelete(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "apimanagementservice.ApiManagementServiceClient", "Delete", nil, "Failure preparing request") - return - } - - result, err = c.senderForDelete(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "apimanagementservice.ApiManagementServiceClient", "Delete", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// DeleteThenPoll performs Delete then polls until it's completed -func (c ApiManagementServiceClient) 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 ApiManagementServiceClient) 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 ApiManagementServiceClient) 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/apimanagement/2021-08-01/apimanagementservice/method_get.go b/resource-manager/apimanagement/2021-08-01/apimanagementservice/method_get.go new file mode 100644 index 00000000000..a12ef17aed4 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/apimanagementservice/method_get.go @@ -0,0 +1,51 @@ +package apimanagementservice + +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 *ApiManagementServiceResource +} + +// Get ... +func (c ApiManagementServiceClient) 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/apimanagement/2021-08-01/apimanagementservice/method_get_autorest.go b/resource-manager/apimanagement/2021-08-01/apimanagementservice/method_get_autorest.go deleted file mode 100644 index 83af95cf755..00000000000 --- a/resource-manager/apimanagement/2021-08-01/apimanagementservice/method_get_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package apimanagementservice - -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 *ApiManagementServiceResource -} - -// Get ... -func (c ApiManagementServiceClient) Get(ctx context.Context, id ServiceId) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "apimanagementservice.ApiManagementServiceClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apimanagementservice.ApiManagementServiceClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apimanagementservice.ApiManagementServiceClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c ApiManagementServiceClient) 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 ApiManagementServiceClient) 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/apimanagement/2021-08-01/apimanagementservice/method_getdomainownershipidentifier.go b/resource-manager/apimanagement/2021-08-01/apimanagementservice/method_getdomainownershipidentifier.go new file mode 100644 index 00000000000..de103cd5209 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/apimanagementservice/method_getdomainownershipidentifier.go @@ -0,0 +1,53 @@ +package apimanagementservice + +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 GetDomainOwnershipIdentifierOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ApiManagementServiceGetDomainOwnershipIdentifierResult +} + +// GetDomainOwnershipIdentifier ... +func (c ApiManagementServiceClient) GetDomainOwnershipIdentifier(ctx context.Context, id commonids.SubscriptionId) (result GetDomainOwnershipIdentifierOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/providers/Microsoft.ApiManagement/getDomainOwnershipIdentifier", 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/apimanagement/2021-08-01/apimanagementservice/method_getdomainownershipidentifier_autorest.go b/resource-manager/apimanagement/2021-08-01/apimanagementservice/method_getdomainownershipidentifier_autorest.go deleted file mode 100644 index 3ee44e20f2e..00000000000 --- a/resource-manager/apimanagement/2021-08-01/apimanagementservice/method_getdomainownershipidentifier_autorest.go +++ /dev/null @@ -1,70 +0,0 @@ -package apimanagementservice - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetDomainOwnershipIdentifierOperationResponse struct { - HttpResponse *http.Response - Model *ApiManagementServiceGetDomainOwnershipIdentifierResult -} - -// GetDomainOwnershipIdentifier ... -func (c ApiManagementServiceClient) GetDomainOwnershipIdentifier(ctx context.Context, id commonids.SubscriptionId) (result GetDomainOwnershipIdentifierOperationResponse, err error) { - req, err := c.preparerForGetDomainOwnershipIdentifier(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "apimanagementservice.ApiManagementServiceClient", "GetDomainOwnershipIdentifier", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apimanagementservice.ApiManagementServiceClient", "GetDomainOwnershipIdentifier", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetDomainOwnershipIdentifier(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apimanagementservice.ApiManagementServiceClient", "GetDomainOwnershipIdentifier", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetDomainOwnershipIdentifier prepares the GetDomainOwnershipIdentifier request. -func (c ApiManagementServiceClient) preparerForGetDomainOwnershipIdentifier(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.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/providers/Microsoft.ApiManagement/getDomainOwnershipIdentifier", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetDomainOwnershipIdentifier handles the response to the GetDomainOwnershipIdentifier request. The method always -// closes the http.Response Body. -func (c ApiManagementServiceClient) responderForGetDomainOwnershipIdentifier(resp *http.Response) (result GetDomainOwnershipIdentifierOperationResponse, 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/apimanagement/2021-08-01/apimanagementservice/method_getssotoken.go b/resource-manager/apimanagement/2021-08-01/apimanagementservice/method_getssotoken.go new file mode 100644 index 00000000000..2831bca105b --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/apimanagementservice/method_getssotoken.go @@ -0,0 +1,52 @@ +package apimanagementservice + +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 GetSsoTokenOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ApiManagementServiceGetSsoTokenResult +} + +// GetSsoToken ... +func (c ApiManagementServiceClient) GetSsoToken(ctx context.Context, id ServiceId) (result GetSsoTokenOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/getssotoken", 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/apimanagement/2021-08-01/apimanagementservice/method_getssotoken_autorest.go b/resource-manager/apimanagement/2021-08-01/apimanagementservice/method_getssotoken_autorest.go deleted file mode 100644 index e66d5a4b465..00000000000 --- a/resource-manager/apimanagement/2021-08-01/apimanagementservice/method_getssotoken_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package apimanagementservice - -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 GetSsoTokenOperationResponse struct { - HttpResponse *http.Response - Model *ApiManagementServiceGetSsoTokenResult -} - -// GetSsoToken ... -func (c ApiManagementServiceClient) GetSsoToken(ctx context.Context, id ServiceId) (result GetSsoTokenOperationResponse, err error) { - req, err := c.preparerForGetSsoToken(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "apimanagementservice.ApiManagementServiceClient", "GetSsoToken", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apimanagementservice.ApiManagementServiceClient", "GetSsoToken", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetSsoToken(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apimanagementservice.ApiManagementServiceClient", "GetSsoToken", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetSsoToken prepares the GetSsoToken request. -func (c ApiManagementServiceClient) preparerForGetSsoToken(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.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/getssotoken", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetSsoToken handles the response to the GetSsoToken request. The method always -// closes the http.Response Body. -func (c ApiManagementServiceClient) responderForGetSsoToken(resp *http.Response) (result GetSsoTokenOperationResponse, 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/apimanagement/2021-08-01/apimanagementservice/method_list.go b/resource-manager/apimanagement/2021-08-01/apimanagementservice/method_list.go new file mode 100644 index 00000000000..2f75508ba8a --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/apimanagementservice/method_list.go @@ -0,0 +1,90 @@ +package apimanagementservice + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ApiManagementServiceResource +} + +type ListCompleteResult struct { + Items []ApiManagementServiceResource +} + +// List ... +func (c ApiManagementServiceClient) List(ctx context.Context, id commonids.SubscriptionId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.ApiManagement/service", 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 *[]ApiManagementServiceResource `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 ApiManagementServiceClient) ListComplete(ctx context.Context, id commonids.SubscriptionId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, ApiManagementServiceResourceOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ApiManagementServiceClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate ApiManagementServiceResourceOperationPredicate) (result ListCompleteResult, err error) { + items := make([]ApiManagementServiceResource, 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{ + Items: items, + } + return +} diff --git a/resource-manager/apimanagement/2021-08-01/apimanagementservice/method_list_autorest.go b/resource-manager/apimanagement/2021-08-01/apimanagementservice/method_list_autorest.go deleted file mode 100644 index bc98fce7338..00000000000 --- a/resource-manager/apimanagement/2021-08-01/apimanagementservice/method_list_autorest.go +++ /dev/null @@ -1,187 +0,0 @@ -package apimanagementservice - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListOperationResponse struct { - HttpResponse *http.Response - Model *[]ApiManagementServiceResource - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListOperationResponse, error) -} - -type ListCompleteResult struct { - Items []ApiManagementServiceResource -} - -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 ApiManagementServiceClient) List(ctx context.Context, id commonids.SubscriptionId) (resp ListOperationResponse, err error) { - req, err := c.preparerForList(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "apimanagementservice.ApiManagementServiceClient", "List", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apimanagementservice.ApiManagementServiceClient", "List", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForList(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apimanagementservice.ApiManagementServiceClient", "List", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForList prepares the List request. -func (c ApiManagementServiceClient) preparerForList(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.ApiManagement/service", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListWithNextLink prepares the List request with the given nextLink token. -func (c ApiManagementServiceClient) 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 ApiManagementServiceClient) responderForList(resp *http.Response) (result ListOperationResponse, err error) { - type page struct { - Values []ApiManagementServiceResource `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, "apimanagementservice.ApiManagementServiceClient", "List", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apimanagementservice.ApiManagementServiceClient", "List", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForList(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apimanagementservice.ApiManagementServiceClient", "List", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListComplete retrieves all of the results into a single object -func (c ApiManagementServiceClient) ListComplete(ctx context.Context, id commonids.SubscriptionId) (ListCompleteResult, error) { - return c.ListCompleteMatchingPredicate(ctx, id, ApiManagementServiceResourceOperationPredicate{}) -} - -// ListCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c ApiManagementServiceClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate ApiManagementServiceResourceOperationPredicate) (resp ListCompleteResult, err error) { - items := make([]ApiManagementServiceResource, 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/apimanagement/2021-08-01/apimanagementservice/method_listbyresourcegroup.go b/resource-manager/apimanagement/2021-08-01/apimanagementservice/method_listbyresourcegroup.go new file mode 100644 index 00000000000..46aadae6bda --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/apimanagementservice/method_listbyresourcegroup.go @@ -0,0 +1,90 @@ +package apimanagementservice + +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 *[]ApiManagementServiceResource +} + +type ListByResourceGroupCompleteResult struct { + Items []ApiManagementServiceResource +} + +// ListByResourceGroup ... +func (c ApiManagementServiceClient) 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.ApiManagement/service", 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 *[]ApiManagementServiceResource `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 ApiManagementServiceClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (ListByResourceGroupCompleteResult, error) { + return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, ApiManagementServiceResourceOperationPredicate{}) +} + +// ListByResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ApiManagementServiceClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate ApiManagementServiceResourceOperationPredicate) (result ListByResourceGroupCompleteResult, err error) { + items := make([]ApiManagementServiceResource, 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{ + Items: items, + } + return +} diff --git a/resource-manager/apimanagement/2021-08-01/apimanagementservice/method_listbyresourcegroup_autorest.go b/resource-manager/apimanagement/2021-08-01/apimanagementservice/method_listbyresourcegroup_autorest.go deleted file mode 100644 index f7776316529..00000000000 --- a/resource-manager/apimanagement/2021-08-01/apimanagementservice/method_listbyresourcegroup_autorest.go +++ /dev/null @@ -1,187 +0,0 @@ -package apimanagementservice - -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 *[]ApiManagementServiceResource - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListByResourceGroupOperationResponse, error) -} - -type ListByResourceGroupCompleteResult struct { - Items []ApiManagementServiceResource -} - -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 ApiManagementServiceClient) ListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (resp ListByResourceGroupOperationResponse, err error) { - req, err := c.preparerForListByResourceGroup(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "apimanagementservice.ApiManagementServiceClient", "ListByResourceGroup", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apimanagementservice.ApiManagementServiceClient", "ListByResourceGroup", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListByResourceGroup(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apimanagementservice.ApiManagementServiceClient", "ListByResourceGroup", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListByResourceGroup prepares the ListByResourceGroup request. -func (c ApiManagementServiceClient) 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.ApiManagement/service", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListByResourceGroupWithNextLink prepares the ListByResourceGroup request with the given nextLink token. -func (c ApiManagementServiceClient) 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 ApiManagementServiceClient) responderForListByResourceGroup(resp *http.Response) (result ListByResourceGroupOperationResponse, err error) { - type page struct { - Values []ApiManagementServiceResource `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, "apimanagementservice.ApiManagementServiceClient", "ListByResourceGroup", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apimanagementservice.ApiManagementServiceClient", "ListByResourceGroup", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByResourceGroup(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apimanagementservice.ApiManagementServiceClient", "ListByResourceGroup", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListByResourceGroupComplete retrieves all of the results into a single object -func (c ApiManagementServiceClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (ListByResourceGroupCompleteResult, error) { - return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, ApiManagementServiceResourceOperationPredicate{}) -} - -// ListByResourceGroupCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c ApiManagementServiceClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate ApiManagementServiceResourceOperationPredicate) (resp ListByResourceGroupCompleteResult, err error) { - items := make([]ApiManagementServiceResource, 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/apimanagement/2021-08-01/apimanagementservice/method_restore.go b/resource-manager/apimanagement/2021-08-01/apimanagementservice/method_restore.go new file mode 100644 index 00000000000..5ea017b5905 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/apimanagementservice/method_restore.go @@ -0,0 +1,74 @@ +package apimanagementservice + +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 RestoreOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Restore ... +func (c ApiManagementServiceClient) Restore(ctx context.Context, id ServiceId, input ApiManagementServiceBackupRestoreParameters) (result RestoreOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/restore", 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 +} + +// RestoreThenPoll performs Restore then polls until it's completed +func (c ApiManagementServiceClient) RestoreThenPoll(ctx context.Context, id ServiceId, input ApiManagementServiceBackupRestoreParameters) error { + result, err := c.Restore(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Restore: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Restore: %+v", err) + } + + return nil +} diff --git a/resource-manager/apimanagement/2021-08-01/apimanagementservice/method_restore_autorest.go b/resource-manager/apimanagement/2021-08-01/apimanagementservice/method_restore_autorest.go deleted file mode 100644 index bb762b61349..00000000000 --- a/resource-manager/apimanagement/2021-08-01/apimanagementservice/method_restore_autorest.go +++ /dev/null @@ -1,79 +0,0 @@ -package apimanagementservice - -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 RestoreOperationResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// Restore ... -func (c ApiManagementServiceClient) Restore(ctx context.Context, id ServiceId, input ApiManagementServiceBackupRestoreParameters) (result RestoreOperationResponse, err error) { - req, err := c.preparerForRestore(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "apimanagementservice.ApiManagementServiceClient", "Restore", nil, "Failure preparing request") - return - } - - result, err = c.senderForRestore(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "apimanagementservice.ApiManagementServiceClient", "Restore", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// RestoreThenPoll performs Restore then polls until it's completed -func (c ApiManagementServiceClient) RestoreThenPoll(ctx context.Context, id ServiceId, input ApiManagementServiceBackupRestoreParameters) error { - result, err := c.Restore(ctx, id, input) - if err != nil { - return fmt.Errorf("performing Restore: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after Restore: %+v", err) - } - - return nil -} - -// preparerForRestore prepares the Restore request. -func (c ApiManagementServiceClient) preparerForRestore(ctx context.Context, id ServiceId, input ApiManagementServiceBackupRestoreParameters) (*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/restore", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForRestore sends the Restore request. The method will close the -// http.Response Body if it receives an error. -func (c ApiManagementServiceClient) senderForRestore(ctx context.Context, req *http.Request) (future RestoreOperationResponse, 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/apimanagement/2021-08-01/apimanagementservice/method_update.go b/resource-manager/apimanagement/2021-08-01/apimanagementservice/method_update.go new file mode 100644 index 00000000000..9a2e8907c9b --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/apimanagementservice/method_update.go @@ -0,0 +1,74 @@ +package apimanagementservice + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Update ... +func (c ApiManagementServiceClient) Update(ctx context.Context, id ServiceId, input ApiManagementServiceUpdateParameters) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// UpdateThenPoll performs Update then polls until it's completed +func (c ApiManagementServiceClient) UpdateThenPoll(ctx context.Context, id ServiceId, input ApiManagementServiceUpdateParameters) error { + result, err := c.Update(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Update: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Update: %+v", err) + } + + return nil +} diff --git a/resource-manager/apimanagement/2021-08-01/apimanagementservice/method_update_autorest.go b/resource-manager/apimanagement/2021-08-01/apimanagementservice/method_update_autorest.go deleted file mode 100644 index c4047579231..00000000000 --- a/resource-manager/apimanagement/2021-08-01/apimanagementservice/method_update_autorest.go +++ /dev/null @@ -1,79 +0,0 @@ -package apimanagementservice - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type UpdateOperationResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// Update ... -func (c ApiManagementServiceClient) Update(ctx context.Context, id ServiceId, input ApiManagementServiceUpdateParameters) (result UpdateOperationResponse, err error) { - req, err := c.preparerForUpdate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "apimanagementservice.ApiManagementServiceClient", "Update", nil, "Failure preparing request") - return - } - - result, err = c.senderForUpdate(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "apimanagementservice.ApiManagementServiceClient", "Update", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// UpdateThenPoll performs Update then polls until it's completed -func (c ApiManagementServiceClient) UpdateThenPoll(ctx context.Context, id ServiceId, input ApiManagementServiceUpdateParameters) error { - result, err := c.Update(ctx, id, input) - if err != nil { - return fmt.Errorf("performing Update: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after Update: %+v", err) - } - - return nil -} - -// preparerForUpdate prepares the Update request. -func (c ApiManagementServiceClient) preparerForUpdate(ctx context.Context, id ServiceId, input ApiManagementServiceUpdateParameters) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPatch(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForUpdate sends the Update request. The method will close the -// http.Response Body if it receives an error. -func (c ApiManagementServiceClient) senderForUpdate(ctx context.Context, req *http.Request) (future UpdateOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/apimanagement/2021-08-01/apimanagementserviceskus/client.go b/resource-manager/apimanagement/2021-08-01/apimanagementserviceskus/client.go index eb6747c1e12..1ce06d88a72 100644 --- a/resource-manager/apimanagement/2021-08-01/apimanagementserviceskus/client.go +++ b/resource-manager/apimanagement/2021-08-01/apimanagementserviceskus/client.go @@ -1,18 +1,26 @@ package apimanagementserviceskus -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 ApiManagementServiceSkusClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewApiManagementServiceSkusClientWithBaseURI(endpoint string) ApiManagementServiceSkusClient { - return ApiManagementServiceSkusClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewApiManagementServiceSkusClientWithBaseURI(api environments.Api) (*ApiManagementServiceSkusClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "apimanagementserviceskus", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ApiManagementServiceSkusClient: %+v", err) } + + return &ApiManagementServiceSkusClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2021-08-01/apimanagementserviceskus/constants.go b/resource-manager/apimanagement/2021-08-01/apimanagementserviceskus/constants.go index d5d2b9ea3eb..d9e2bd19e1c 100644 --- a/resource-manager/apimanagement/2021-08-01/apimanagementserviceskus/constants.go +++ b/resource-manager/apimanagement/2021-08-01/apimanagementserviceskus/constants.go @@ -1,6 +1,10 @@ package apimanagementserviceskus -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 PossibleValuesForResourceSkuCapacityScaleType() []string { } } +func (s *ResourceSkuCapacityScaleType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseResourceSkuCapacityScaleType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseResourceSkuCapacityScaleType(input string) (*ResourceSkuCapacityScaleType, error) { vals := map[string]ResourceSkuCapacityScaleType{ "automatic": ResourceSkuCapacityScaleTypeAutomatic, @@ -58,6 +75,19 @@ func PossibleValuesForSkuType() []string { } } +func (s *SkuType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSkuType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseSkuType(input string) (*SkuType, error) { vals := map[string]SkuType{ "basic": SkuTypeBasic, diff --git a/resource-manager/apimanagement/2021-08-01/apimanagementserviceskus/method_listavailableserviceskus.go b/resource-manager/apimanagement/2021-08-01/apimanagementserviceskus/method_listavailableserviceskus.go new file mode 100644 index 00000000000..afe8ea5af07 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/apimanagementserviceskus/method_listavailableserviceskus.go @@ -0,0 +1,89 @@ +package apimanagementserviceskus + +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 ListAvailableServiceSkusOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ResourceSkuResult +} + +type ListAvailableServiceSkusCompleteResult struct { + Items []ResourceSkuResult +} + +// ListAvailableServiceSkus ... +func (c ApiManagementServiceSkusClient) ListAvailableServiceSkus(ctx context.Context, id ServiceId) (result ListAvailableServiceSkusOperationResponse, 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 *[]ResourceSkuResult `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListAvailableServiceSkusComplete retrieves all the results into a single object +func (c ApiManagementServiceSkusClient) ListAvailableServiceSkusComplete(ctx context.Context, id ServiceId) (ListAvailableServiceSkusCompleteResult, error) { + return c.ListAvailableServiceSkusCompleteMatchingPredicate(ctx, id, ResourceSkuResultOperationPredicate{}) +} + +// ListAvailableServiceSkusCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ApiManagementServiceSkusClient) ListAvailableServiceSkusCompleteMatchingPredicate(ctx context.Context, id ServiceId, predicate ResourceSkuResultOperationPredicate) (result ListAvailableServiceSkusCompleteResult, err error) { + items := make([]ResourceSkuResult, 0) + + resp, err := c.ListAvailableServiceSkus(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 = ListAvailableServiceSkusCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/apimanagement/2021-08-01/apimanagementserviceskus/method_listavailableserviceskus_autorest.go b/resource-manager/apimanagement/2021-08-01/apimanagementserviceskus/method_listavailableserviceskus_autorest.go deleted file mode 100644 index f5aa634c623..00000000000 --- a/resource-manager/apimanagement/2021-08-01/apimanagementserviceskus/method_listavailableserviceskus_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package apimanagementserviceskus - -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 ListAvailableServiceSkusOperationResponse struct { - HttpResponse *http.Response - Model *[]ResourceSkuResult - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListAvailableServiceSkusOperationResponse, error) -} - -type ListAvailableServiceSkusCompleteResult struct { - Items []ResourceSkuResult -} - -func (r ListAvailableServiceSkusOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListAvailableServiceSkusOperationResponse) LoadMore(ctx context.Context) (resp ListAvailableServiceSkusOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListAvailableServiceSkus ... -func (c ApiManagementServiceSkusClient) ListAvailableServiceSkus(ctx context.Context, id ServiceId) (resp ListAvailableServiceSkusOperationResponse, err error) { - req, err := c.preparerForListAvailableServiceSkus(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "apimanagementserviceskus.ApiManagementServiceSkusClient", "ListAvailableServiceSkus", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apimanagementserviceskus.ApiManagementServiceSkusClient", "ListAvailableServiceSkus", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListAvailableServiceSkus(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apimanagementserviceskus.ApiManagementServiceSkusClient", "ListAvailableServiceSkus", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListAvailableServiceSkus prepares the ListAvailableServiceSkus request. -func (c ApiManagementServiceSkusClient) preparerForListAvailableServiceSkus(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(fmt.Sprintf("%s/skus", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListAvailableServiceSkusWithNextLink prepares the ListAvailableServiceSkus request with the given nextLink token. -func (c ApiManagementServiceSkusClient) preparerForListAvailableServiceSkusWithNextLink(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)) -} - -// responderForListAvailableServiceSkus handles the response to the ListAvailableServiceSkus request. The method always -// closes the http.Response Body. -func (c ApiManagementServiceSkusClient) responderForListAvailableServiceSkus(resp *http.Response) (result ListAvailableServiceSkusOperationResponse, err error) { - type page struct { - Values []ResourceSkuResult `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 ListAvailableServiceSkusOperationResponse, err error) { - req, err := c.preparerForListAvailableServiceSkusWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "apimanagementserviceskus.ApiManagementServiceSkusClient", "ListAvailableServiceSkus", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apimanagementserviceskus.ApiManagementServiceSkusClient", "ListAvailableServiceSkus", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListAvailableServiceSkus(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apimanagementserviceskus.ApiManagementServiceSkusClient", "ListAvailableServiceSkus", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListAvailableServiceSkusComplete retrieves all of the results into a single object -func (c ApiManagementServiceSkusClient) ListAvailableServiceSkusComplete(ctx context.Context, id ServiceId) (ListAvailableServiceSkusCompleteResult, error) { - return c.ListAvailableServiceSkusCompleteMatchingPredicate(ctx, id, ResourceSkuResultOperationPredicate{}) -} - -// ListAvailableServiceSkusCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c ApiManagementServiceSkusClient) ListAvailableServiceSkusCompleteMatchingPredicate(ctx context.Context, id ServiceId, predicate ResourceSkuResultOperationPredicate) (resp ListAvailableServiceSkusCompleteResult, err error) { - items := make([]ResourceSkuResult, 0) - - page, err := c.ListAvailableServiceSkus(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 := ListAvailableServiceSkusCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/apimanagement/2021-08-01/apioperation/client.go b/resource-manager/apimanagement/2021-08-01/apioperation/client.go index f4e640e1356..3385359b614 100644 --- a/resource-manager/apimanagement/2021-08-01/apioperation/client.go +++ b/resource-manager/apimanagement/2021-08-01/apioperation/client.go @@ -1,18 +1,26 @@ package apioperation -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 ApiOperationClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewApiOperationClientWithBaseURI(endpoint string) ApiOperationClient { - return ApiOperationClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewApiOperationClientWithBaseURI(api environments.Api) (*ApiOperationClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "apioperation", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ApiOperationClient: %+v", err) } + + return &ApiOperationClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2021-08-01/apioperation/method_createorupdate.go b/resource-manager/apimanagement/2021-08-01/apioperation/method_createorupdate.go new file mode 100644 index 00000000000..6dc046e355f --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/apioperation/method_createorupdate.go @@ -0,0 +1,85 @@ +package apioperation + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *OperationContract +} + +type CreateOrUpdateOperationOptions struct { + IfMatch *string +} + +func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { + return CreateOrUpdateOperationOptions{} +} + +func (o CreateOrUpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o CreateOrUpdateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o CreateOrUpdateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// CreateOrUpdate ... +func (c ApiOperationClient) CreateOrUpdate(ctx context.Context, id OperationId, input OperationContract, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + OptionsObject: options, + } + + 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/apimanagement/2021-08-01/apioperation/method_createorupdate_autorest.go b/resource-manager/apimanagement/2021-08-01/apioperation/method_createorupdate_autorest.go deleted file mode 100644 index 248feffbbb9..00000000000 --- a/resource-manager/apimanagement/2021-08-01/apioperation/method_createorupdate_autorest.go +++ /dev/null @@ -1,98 +0,0 @@ -package apioperation - -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 *OperationContract -} - -type CreateOrUpdateOperationOptions struct { - IfMatch *string -} - -func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { - return CreateOrUpdateOperationOptions{} -} - -func (o CreateOrUpdateOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o CreateOrUpdateOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// CreateOrUpdate ... -func (c ApiOperationClient) CreateOrUpdate(ctx context.Context, id OperationId, input OperationContract, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdate(ctx, id, input, options) - if err != nil { - err = autorest.NewErrorWithError(err, "apioperation.ApiOperationClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apioperation.ApiOperationClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCreateOrUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apioperation.ApiOperationClient", "CreateOrUpdate", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCreateOrUpdate prepares the CreateOrUpdate request. -func (c ApiOperationClient) preparerForCreateOrUpdate(ctx context.Context, id OperationId, input OperationContract, options CreateOrUpdateOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - 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 ApiOperationClient) responderForCreateOrUpdate(resp *http.Response) (result CreateOrUpdateOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2021-08-01/apioperation/method_delete.go b/resource-manager/apimanagement/2021-08-01/apioperation/method_delete.go new file mode 100644 index 00000000000..0693a0a284f --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/apioperation/method_delete.go @@ -0,0 +1,76 @@ +package apioperation + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +type DeleteOperationOptions struct { + IfMatch *string +} + +func DefaultDeleteOperationOptions() DeleteOperationOptions { + return DeleteOperationOptions{} +} + +func (o DeleteOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o DeleteOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o DeleteOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// Delete ... +func (c ApiOperationClient) Delete(ctx context.Context, id OperationId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2021-08-01/apioperation/method_delete_autorest.go b/resource-manager/apimanagement/2021-08-01/apioperation/method_delete_autorest.go deleted file mode 100644 index 6a968ca42c0..00000000000 --- a/resource-manager/apimanagement/2021-08-01/apioperation/method_delete_autorest.go +++ /dev/null @@ -1,95 +0,0 @@ -package apioperation - -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 DeleteOperationResponse struct { - HttpResponse *http.Response -} - -type DeleteOperationOptions struct { - IfMatch *string -} - -func DefaultDeleteOperationOptions() DeleteOperationOptions { - return DeleteOperationOptions{} -} - -func (o DeleteOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o DeleteOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// Delete ... -func (c ApiOperationClient) Delete(ctx context.Context, id OperationId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { - req, err := c.preparerForDelete(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "apioperation.ApiOperationClient", "Delete", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apioperation.ApiOperationClient", "Delete", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForDelete(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apioperation.ApiOperationClient", "Delete", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForDelete prepares the Delete request. -func (c ApiOperationClient) preparerForDelete(ctx context.Context, id OperationId, options DeleteOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForDelete handles the response to the Delete request. The method always -// closes the http.Response Body. -func (c ApiOperationClient) responderForDelete(resp *http.Response) (result DeleteOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2021-08-01/apioperation/method_get.go b/resource-manager/apimanagement/2021-08-01/apioperation/method_get.go new file mode 100644 index 00000000000..d5786d5ae91 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/apioperation/method_get.go @@ -0,0 +1,51 @@ +package apioperation + +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 *OperationContract +} + +// Get ... +func (c ApiOperationClient) Get(ctx context.Context, id OperationId) (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/apimanagement/2021-08-01/apioperation/method_get_autorest.go b/resource-manager/apimanagement/2021-08-01/apioperation/method_get_autorest.go deleted file mode 100644 index 71209f67ea1..00000000000 --- a/resource-manager/apimanagement/2021-08-01/apioperation/method_get_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package apioperation - -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 *OperationContract -} - -// Get ... -func (c ApiOperationClient) Get(ctx context.Context, id OperationId) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "apioperation.ApiOperationClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apioperation.ApiOperationClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apioperation.ApiOperationClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c ApiOperationClient) preparerForGet(ctx context.Context, id OperationId) (*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 ApiOperationClient) 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/apimanagement/2021-08-01/apioperation/method_getentitytag.go b/resource-manager/apimanagement/2021-08-01/apioperation/method_getentitytag.go new file mode 100644 index 00000000000..520a7b92e36 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/apioperation/method_getentitytag.go @@ -0,0 +1,46 @@ +package apioperation + +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 GetEntityTagOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// GetEntityTag ... +func (c ApiOperationClient) GetEntityTag(ctx context.Context, id OperationId) (result GetEntityTagOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodHead, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2021-08-01/apioperation/method_getentitytag_autorest.go b/resource-manager/apimanagement/2021-08-01/apioperation/method_getentitytag_autorest.go deleted file mode 100644 index fbf38551a9a..00000000000 --- a/resource-manager/apimanagement/2021-08-01/apioperation/method_getentitytag_autorest.go +++ /dev/null @@ -1,66 +0,0 @@ -package apioperation - -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 GetEntityTagOperationResponse struct { - HttpResponse *http.Response -} - -// GetEntityTag ... -func (c ApiOperationClient) GetEntityTag(ctx context.Context, id OperationId) (result GetEntityTagOperationResponse, err error) { - req, err := c.preparerForGetEntityTag(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "apioperation.ApiOperationClient", "GetEntityTag", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apioperation.ApiOperationClient", "GetEntityTag", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetEntityTag(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apioperation.ApiOperationClient", "GetEntityTag", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetEntityTag prepares the GetEntityTag request. -func (c ApiOperationClient) preparerForGetEntityTag(ctx context.Context, id OperationId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsHead(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetEntityTag handles the response to the GetEntityTag request. The method always -// closes the http.Response Body. -func (c ApiOperationClient) responderForGetEntityTag(resp *http.Response) (result GetEntityTagOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2021-08-01/apioperation/method_listbyapi.go b/resource-manager/apimanagement/2021-08-01/apioperation/method_listbyapi.go new file mode 100644 index 00000000000..5620f8b7c3e --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/apioperation/method_listbyapi.go @@ -0,0 +1,129 @@ +package apioperation + +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 ListByApiOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]OperationContract +} + +type ListByApiCompleteResult struct { + Items []OperationContract +} + +type ListByApiOperationOptions struct { + Filter *string + Skip *int64 + Tags *string + Top *int64 +} + +func DefaultListByApiOperationOptions() ListByApiOperationOptions { + return ListByApiOperationOptions{} +} + +func (o ListByApiOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListByApiOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListByApiOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.Skip != nil { + out.Append("$skip", fmt.Sprintf("%v", *o.Skip)) + } + if o.Tags != nil { + out.Append("tags", fmt.Sprintf("%v", *o.Tags)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +// ListByApi ... +func (c ApiOperationClient) ListByApi(ctx context.Context, id ApiId, options ListByApiOperationOptions) (result ListByApiOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/operations", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]OperationContract `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByApiComplete retrieves all the results into a single object +func (c ApiOperationClient) ListByApiComplete(ctx context.Context, id ApiId, options ListByApiOperationOptions) (ListByApiCompleteResult, error) { + return c.ListByApiCompleteMatchingPredicate(ctx, id, options, OperationContractOperationPredicate{}) +} + +// ListByApiCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ApiOperationClient) ListByApiCompleteMatchingPredicate(ctx context.Context, id ApiId, options ListByApiOperationOptions, predicate OperationContractOperationPredicate) (result ListByApiCompleteResult, err error) { + items := make([]OperationContract, 0) + + resp, err := c.ListByApi(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByApiCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/apimanagement/2021-08-01/apioperation/method_listbyapi_autorest.go b/resource-manager/apimanagement/2021-08-01/apioperation/method_listbyapi_autorest.go deleted file mode 100644 index 081748611d8..00000000000 --- a/resource-manager/apimanagement/2021-08-01/apioperation/method_listbyapi_autorest.go +++ /dev/null @@ -1,230 +0,0 @@ -package apioperation - -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 ListByApiOperationResponse struct { - HttpResponse *http.Response - Model *[]OperationContract - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListByApiOperationResponse, error) -} - -type ListByApiCompleteResult struct { - Items []OperationContract -} - -func (r ListByApiOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListByApiOperationResponse) LoadMore(ctx context.Context) (resp ListByApiOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -type ListByApiOperationOptions struct { - Filter *string - Skip *int64 - Tags *string - Top *int64 -} - -func DefaultListByApiOperationOptions() ListByApiOperationOptions { - return ListByApiOperationOptions{} -} - -func (o ListByApiOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o ListByApiOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Filter != nil { - out["$filter"] = *o.Filter - } - - if o.Skip != nil { - out["$skip"] = *o.Skip - } - - if o.Tags != nil { - out["tags"] = *o.Tags - } - - if o.Top != nil { - out["$top"] = *o.Top - } - - return out -} - -// ListByApi ... -func (c ApiOperationClient) ListByApi(ctx context.Context, id ApiId, options ListByApiOperationOptions) (resp ListByApiOperationResponse, err error) { - req, err := c.preparerForListByApi(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "apioperation.ApiOperationClient", "ListByApi", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apioperation.ApiOperationClient", "ListByApi", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListByApi(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apioperation.ApiOperationClient", "ListByApi", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListByApi prepares the ListByApi request. -func (c ApiOperationClient) preparerForListByApi(ctx context.Context, id ApiId, options ListByApiOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/operations", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListByApiWithNextLink prepares the ListByApi request with the given nextLink token. -func (c ApiOperationClient) preparerForListByApiWithNextLink(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)) -} - -// responderForListByApi handles the response to the ListByApi request. The method always -// closes the http.Response Body. -func (c ApiOperationClient) responderForListByApi(resp *http.Response) (result ListByApiOperationResponse, err error) { - type page struct { - Values []OperationContract `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 ListByApiOperationResponse, err error) { - req, err := c.preparerForListByApiWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "apioperation.ApiOperationClient", "ListByApi", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apioperation.ApiOperationClient", "ListByApi", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByApi(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apioperation.ApiOperationClient", "ListByApi", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListByApiComplete retrieves all of the results into a single object -func (c ApiOperationClient) ListByApiComplete(ctx context.Context, id ApiId, options ListByApiOperationOptions) (ListByApiCompleteResult, error) { - return c.ListByApiCompleteMatchingPredicate(ctx, id, options, OperationContractOperationPredicate{}) -} - -// ListByApiCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c ApiOperationClient) ListByApiCompleteMatchingPredicate(ctx context.Context, id ApiId, options ListByApiOperationOptions, predicate OperationContractOperationPredicate) (resp ListByApiCompleteResult, err error) { - items := make([]OperationContract, 0) - - page, err := c.ListByApi(ctx, id, options) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListByApiCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/apimanagement/2021-08-01/apioperation/method_update.go b/resource-manager/apimanagement/2021-08-01/apioperation/method_update.go new file mode 100644 index 00000000000..9b215cf692d --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/apioperation/method_update.go @@ -0,0 +1,84 @@ +package apioperation + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *OperationContract +} + +type UpdateOperationOptions struct { + IfMatch *string +} + +func DefaultUpdateOperationOptions() UpdateOperationOptions { + return UpdateOperationOptions{} +} + +func (o UpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o UpdateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o UpdateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// Update ... +func (c ApiOperationClient) Update(ctx context.Context, id OperationId, input OperationUpdateContract, options UpdateOperationOptions) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + OptionsObject: options, + } + + 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/apimanagement/2021-08-01/apioperation/method_update_autorest.go b/resource-manager/apimanagement/2021-08-01/apioperation/method_update_autorest.go deleted file mode 100644 index 753e7e9c090..00000000000 --- a/resource-manager/apimanagement/2021-08-01/apioperation/method_update_autorest.go +++ /dev/null @@ -1,98 +0,0 @@ -package apioperation - -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 *OperationContract -} - -type UpdateOperationOptions struct { - IfMatch *string -} - -func DefaultUpdateOperationOptions() UpdateOperationOptions { - return UpdateOperationOptions{} -} - -func (o UpdateOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o UpdateOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// Update ... -func (c ApiOperationClient) Update(ctx context.Context, id OperationId, input OperationUpdateContract, options UpdateOperationOptions) (result UpdateOperationResponse, err error) { - req, err := c.preparerForUpdate(ctx, id, input, options) - if err != nil { - err = autorest.NewErrorWithError(err, "apioperation.ApiOperationClient", "Update", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apioperation.ApiOperationClient", "Update", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apioperation.ApiOperationClient", "Update", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForUpdate prepares the Update request. -func (c ApiOperationClient) preparerForUpdate(ctx context.Context, id OperationId, input OperationUpdateContract, options UpdateOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPatch(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - 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 ApiOperationClient) 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/apimanagement/2021-08-01/apioperationpolicy/client.go b/resource-manager/apimanagement/2021-08-01/apioperationpolicy/client.go index 263cb368c90..4c6534acec8 100644 --- a/resource-manager/apimanagement/2021-08-01/apioperationpolicy/client.go +++ b/resource-manager/apimanagement/2021-08-01/apioperationpolicy/client.go @@ -1,18 +1,26 @@ package apioperationpolicy -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 ApiOperationPolicyClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewApiOperationPolicyClientWithBaseURI(endpoint string) ApiOperationPolicyClient { - return ApiOperationPolicyClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewApiOperationPolicyClientWithBaseURI(api environments.Api) (*ApiOperationPolicyClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "apioperationpolicy", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ApiOperationPolicyClient: %+v", err) } + + return &ApiOperationPolicyClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2021-08-01/apioperationpolicy/constants.go b/resource-manager/apimanagement/2021-08-01/apioperationpolicy/constants.go index c8bec979994..5a4b902d0cf 100644 --- a/resource-manager/apimanagement/2021-08-01/apioperationpolicy/constants.go +++ b/resource-manager/apimanagement/2021-08-01/apioperationpolicy/constants.go @@ -1,6 +1,10 @@ package apioperationpolicy -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 PossibleValuesForPolicyContentFormat() []string { } } +func (s *PolicyContentFormat) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePolicyContentFormat(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parsePolicyContentFormat(input string) (*PolicyContentFormat, error) { vals := map[string]PolicyContentFormat{ "rawxml": PolicyContentFormatRawxml, @@ -53,6 +70,19 @@ func PossibleValuesForPolicyExportFormat() []string { } } +func (s *PolicyExportFormat) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePolicyExportFormat(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parsePolicyExportFormat(input string) (*PolicyExportFormat, error) { vals := map[string]PolicyExportFormat{ "rawxml": PolicyExportFormatRawxml, diff --git a/resource-manager/apimanagement/2021-08-01/apioperationpolicy/method_createorupdate.go b/resource-manager/apimanagement/2021-08-01/apioperationpolicy/method_createorupdate.go new file mode 100644 index 00000000000..a25fdb2042e --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/apioperationpolicy/method_createorupdate.go @@ -0,0 +1,85 @@ +package apioperationpolicy + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PolicyContract +} + +type CreateOrUpdateOperationOptions struct { + IfMatch *string +} + +func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { + return CreateOrUpdateOperationOptions{} +} + +func (o CreateOrUpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o CreateOrUpdateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o CreateOrUpdateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// CreateOrUpdate ... +func (c ApiOperationPolicyClient) CreateOrUpdate(ctx context.Context, id OperationId, input PolicyContract, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/policies/policy", id.ID()), + OptionsObject: options, + } + + 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/apimanagement/2021-08-01/apioperationpolicy/method_createorupdate_autorest.go b/resource-manager/apimanagement/2021-08-01/apioperationpolicy/method_createorupdate_autorest.go deleted file mode 100644 index ab93439da2b..00000000000 --- a/resource-manager/apimanagement/2021-08-01/apioperationpolicy/method_createorupdate_autorest.go +++ /dev/null @@ -1,99 +0,0 @@ -package apioperationpolicy - -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 CreateOrUpdateOperationResponse struct { - HttpResponse *http.Response - Model *PolicyContract -} - -type CreateOrUpdateOperationOptions struct { - IfMatch *string -} - -func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { - return CreateOrUpdateOperationOptions{} -} - -func (o CreateOrUpdateOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o CreateOrUpdateOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// CreateOrUpdate ... -func (c ApiOperationPolicyClient) CreateOrUpdate(ctx context.Context, id OperationId, input PolicyContract, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdate(ctx, id, input, options) - if err != nil { - err = autorest.NewErrorWithError(err, "apioperationpolicy.ApiOperationPolicyClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apioperationpolicy.ApiOperationPolicyClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCreateOrUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apioperationpolicy.ApiOperationPolicyClient", "CreateOrUpdate", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCreateOrUpdate prepares the CreateOrUpdate request. -func (c ApiOperationPolicyClient) preparerForCreateOrUpdate(ctx context.Context, id OperationId, input PolicyContract, options CreateOrUpdateOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/policies/policy", 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 ApiOperationPolicyClient) responderForCreateOrUpdate(resp *http.Response) (result CreateOrUpdateOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2021-08-01/apioperationpolicy/method_delete.go b/resource-manager/apimanagement/2021-08-01/apioperationpolicy/method_delete.go new file mode 100644 index 00000000000..f30d7d3e932 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/apioperationpolicy/method_delete.go @@ -0,0 +1,76 @@ +package apioperationpolicy + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +type DeleteOperationOptions struct { + IfMatch *string +} + +func DefaultDeleteOperationOptions() DeleteOperationOptions { + return DeleteOperationOptions{} +} + +func (o DeleteOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o DeleteOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o DeleteOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// Delete ... +func (c ApiOperationPolicyClient) Delete(ctx context.Context, id OperationId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: fmt.Sprintf("%s/policies/policy", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2021-08-01/apioperationpolicy/method_delete_autorest.go b/resource-manager/apimanagement/2021-08-01/apioperationpolicy/method_delete_autorest.go deleted file mode 100644 index cb4dd35c12f..00000000000 --- a/resource-manager/apimanagement/2021-08-01/apioperationpolicy/method_delete_autorest.go +++ /dev/null @@ -1,96 +0,0 @@ -package apioperationpolicy - -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 DeleteOperationResponse struct { - HttpResponse *http.Response -} - -type DeleteOperationOptions struct { - IfMatch *string -} - -func DefaultDeleteOperationOptions() DeleteOperationOptions { - return DeleteOperationOptions{} -} - -func (o DeleteOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o DeleteOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// Delete ... -func (c ApiOperationPolicyClient) Delete(ctx context.Context, id OperationId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { - req, err := c.preparerForDelete(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "apioperationpolicy.ApiOperationPolicyClient", "Delete", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apioperationpolicy.ApiOperationPolicyClient", "Delete", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForDelete(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apioperationpolicy.ApiOperationPolicyClient", "Delete", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForDelete prepares the Delete request. -func (c ApiOperationPolicyClient) preparerForDelete(ctx context.Context, id OperationId, options DeleteOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/policies/policy", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForDelete handles the response to the Delete request. The method always -// closes the http.Response Body. -func (c ApiOperationPolicyClient) responderForDelete(resp *http.Response) (result DeleteOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2021-08-01/apioperationpolicy/method_get.go b/resource-manager/apimanagement/2021-08-01/apioperationpolicy/method_get.go new file mode 100644 index 00000000000..62c2e626268 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/apioperationpolicy/method_get.go @@ -0,0 +1,80 @@ +package apioperationpolicy + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PolicyContract +} + +type GetOperationOptions struct { + Format *PolicyExportFormat +} + +func DefaultGetOperationOptions() GetOperationOptions { + return GetOperationOptions{} +} + +func (o GetOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o GetOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o GetOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Format != nil { + out.Append("format", fmt.Sprintf("%v", *o.Format)) + } + return &out +} + +// Get ... +func (c ApiOperationPolicyClient) Get(ctx context.Context, id OperationId, options GetOperationOptions) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/policies/policy", id.ID()), + OptionsObject: options, + } + + 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/apimanagement/2021-08-01/apioperationpolicy/method_get_autorest.go b/resource-manager/apimanagement/2021-08-01/apioperationpolicy/method_get_autorest.go deleted file mode 100644 index 8016e93dbbe..00000000000 --- a/resource-manager/apimanagement/2021-08-01/apioperationpolicy/method_get_autorest.go +++ /dev/null @@ -1,98 +0,0 @@ -package apioperationpolicy - -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 GetOperationResponse struct { - HttpResponse *http.Response - Model *PolicyContract -} - -type GetOperationOptions struct { - Format *PolicyExportFormat -} - -func DefaultGetOperationOptions() GetOperationOptions { - return GetOperationOptions{} -} - -func (o GetOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o GetOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Format != nil { - out["format"] = *o.Format - } - - return out -} - -// Get ... -func (c ApiOperationPolicyClient) Get(ctx context.Context, id OperationId, options GetOperationOptions) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "apioperationpolicy.ApiOperationPolicyClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apioperationpolicy.ApiOperationPolicyClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apioperationpolicy.ApiOperationPolicyClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c ApiOperationPolicyClient) preparerForGet(ctx context.Context, id OperationId, options GetOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/policies/policy", 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 ApiOperationPolicyClient) 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/apimanagement/2021-08-01/apioperationpolicy/method_getentitytag.go b/resource-manager/apimanagement/2021-08-01/apioperationpolicy/method_getentitytag.go new file mode 100644 index 00000000000..88da95a1537 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/apioperationpolicy/method_getentitytag.go @@ -0,0 +1,47 @@ +package apioperationpolicy + +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 GetEntityTagOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// GetEntityTag ... +func (c ApiOperationPolicyClient) GetEntityTag(ctx context.Context, id OperationId) (result GetEntityTagOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodHead, + Path: fmt.Sprintf("%s/policies/policy", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2021-08-01/apioperationpolicy/method_getentitytag_autorest.go b/resource-manager/apimanagement/2021-08-01/apioperationpolicy/method_getentitytag_autorest.go deleted file mode 100644 index 694655ef4b7..00000000000 --- a/resource-manager/apimanagement/2021-08-01/apioperationpolicy/method_getentitytag_autorest.go +++ /dev/null @@ -1,67 +0,0 @@ -package apioperationpolicy - -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 GetEntityTagOperationResponse struct { - HttpResponse *http.Response -} - -// GetEntityTag ... -func (c ApiOperationPolicyClient) GetEntityTag(ctx context.Context, id OperationId) (result GetEntityTagOperationResponse, err error) { - req, err := c.preparerForGetEntityTag(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "apioperationpolicy.ApiOperationPolicyClient", "GetEntityTag", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apioperationpolicy.ApiOperationPolicyClient", "GetEntityTag", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetEntityTag(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apioperationpolicy.ApiOperationPolicyClient", "GetEntityTag", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetEntityTag prepares the GetEntityTag request. -func (c ApiOperationPolicyClient) preparerForGetEntityTag(ctx context.Context, id OperationId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsHead(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/policies/policy", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetEntityTag handles the response to the GetEntityTag request. The method always -// closes the http.Response Body. -func (c ApiOperationPolicyClient) responderForGetEntityTag(resp *http.Response) (result GetEntityTagOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2021-08-01/apioperationpolicy/method_listbyoperation.go b/resource-manager/apimanagement/2021-08-01/apioperationpolicy/method_listbyoperation.go new file mode 100644 index 00000000000..0f79c48d5fe --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/apioperationpolicy/method_listbyoperation.go @@ -0,0 +1,52 @@ +package apioperationpolicy + +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 ListByOperationOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PolicyCollection +} + +// ListByOperation ... +func (c ApiOperationPolicyClient) ListByOperation(ctx context.Context, id OperationId) (result ListByOperationOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/policies", 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/apimanagement/2021-08-01/apioperationpolicy/method_listbyoperation_autorest.go b/resource-manager/apimanagement/2021-08-01/apioperationpolicy/method_listbyoperation_autorest.go deleted file mode 100644 index 65975e5077b..00000000000 --- a/resource-manager/apimanagement/2021-08-01/apioperationpolicy/method_listbyoperation_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package apioperationpolicy - -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 ListByOperationOperationResponse struct { - HttpResponse *http.Response - Model *PolicyCollection -} - -// ListByOperation ... -func (c ApiOperationPolicyClient) ListByOperation(ctx context.Context, id OperationId) (result ListByOperationOperationResponse, err error) { - req, err := c.preparerForListByOperation(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "apioperationpolicy.ApiOperationPolicyClient", "ListByOperation", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apioperationpolicy.ApiOperationPolicyClient", "ListByOperation", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByOperation(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apioperationpolicy.ApiOperationPolicyClient", "ListByOperation", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForListByOperation prepares the ListByOperation request. -func (c ApiOperationPolicyClient) preparerForListByOperation(ctx context.Context, id OperationId) (*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/policies", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListByOperation handles the response to the ListByOperation request. The method always -// closes the http.Response Body. -func (c ApiOperationPolicyClient) responderForListByOperation(resp *http.Response) (result ListByOperationOperationResponse, 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/apimanagement/2021-08-01/apioperationsbytag/client.go b/resource-manager/apimanagement/2021-08-01/apioperationsbytag/client.go index 48716e67800..2cae8f256da 100644 --- a/resource-manager/apimanagement/2021-08-01/apioperationsbytag/client.go +++ b/resource-manager/apimanagement/2021-08-01/apioperationsbytag/client.go @@ -1,18 +1,26 @@ package apioperationsbytag -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 ApiOperationsByTagClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewApiOperationsByTagClientWithBaseURI(endpoint string) ApiOperationsByTagClient { - return ApiOperationsByTagClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewApiOperationsByTagClientWithBaseURI(api environments.Api) (*ApiOperationsByTagClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "apioperationsbytag", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ApiOperationsByTagClient: %+v", err) } + + return &ApiOperationsByTagClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2021-08-01/apioperationsbytag/constants.go b/resource-manager/apimanagement/2021-08-01/apioperationsbytag/constants.go index 7a4b9772ad9..c0f30b87134 100644 --- a/resource-manager/apimanagement/2021-08-01/apioperationsbytag/constants.go +++ b/resource-manager/apimanagement/2021-08-01/apioperationsbytag/constants.go @@ -1,6 +1,10 @@ package apioperationsbytag -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 PossibleValuesForApiType() []string { } } +func (s *ApiType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseApiType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseApiType(input string) (*ApiType, error) { vals := map[string]ApiType{ "graphql": ApiTypeGraphql, @@ -53,6 +70,19 @@ func PossibleValuesForBearerTokenSendingMethods() []string { } } +func (s *BearerTokenSendingMethods) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseBearerTokenSendingMethods(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseBearerTokenSendingMethods(input string) (*BearerTokenSendingMethods, error) { vals := map[string]BearerTokenSendingMethods{ "authorizationheader": BearerTokenSendingMethodsAuthorizationHeader, @@ -81,6 +111,19 @@ func PossibleValuesForProductState() []string { } } +func (s *ProductState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProductState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseProductState(input string) (*ProductState, error) { vals := map[string]ProductState{ "notpublished": ProductStateNotPublished, @@ -113,6 +156,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{ "http": ProtocolHTTP, diff --git a/resource-manager/apimanagement/2021-08-01/apioperationsbytag/method_operationlistbytags.go b/resource-manager/apimanagement/2021-08-01/apioperationsbytag/method_operationlistbytags.go new file mode 100644 index 00000000000..2e348997053 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/apioperationsbytag/method_operationlistbytags.go @@ -0,0 +1,129 @@ +package apioperationsbytag + +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 OperationListByTagsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]TagResourceContract +} + +type OperationListByTagsCompleteResult struct { + Items []TagResourceContract +} + +type OperationListByTagsOperationOptions struct { + Filter *string + IncludeNotTaggedOperations *bool + Skip *int64 + Top *int64 +} + +func DefaultOperationListByTagsOperationOptions() OperationListByTagsOperationOptions { + return OperationListByTagsOperationOptions{} +} + +func (o OperationListByTagsOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o OperationListByTagsOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o OperationListByTagsOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.IncludeNotTaggedOperations != nil { + out.Append("includeNotTaggedOperations", fmt.Sprintf("%v", *o.IncludeNotTaggedOperations)) + } + if o.Skip != nil { + out.Append("$skip", fmt.Sprintf("%v", *o.Skip)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +// OperationListByTags ... +func (c ApiOperationsByTagClient) OperationListByTags(ctx context.Context, id ApiId, options OperationListByTagsOperationOptions) (result OperationListByTagsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/operationsByTags", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]TagResourceContract `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// OperationListByTagsComplete retrieves all the results into a single object +func (c ApiOperationsByTagClient) OperationListByTagsComplete(ctx context.Context, id ApiId, options OperationListByTagsOperationOptions) (OperationListByTagsCompleteResult, error) { + return c.OperationListByTagsCompleteMatchingPredicate(ctx, id, options, TagResourceContractOperationPredicate{}) +} + +// OperationListByTagsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ApiOperationsByTagClient) OperationListByTagsCompleteMatchingPredicate(ctx context.Context, id ApiId, options OperationListByTagsOperationOptions, predicate TagResourceContractOperationPredicate) (result OperationListByTagsCompleteResult, err error) { + items := make([]TagResourceContract, 0) + + resp, err := c.OperationListByTags(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = OperationListByTagsCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/apimanagement/2021-08-01/apioperationsbytag/method_operationlistbytags_autorest.go b/resource-manager/apimanagement/2021-08-01/apioperationsbytag/method_operationlistbytags_autorest.go deleted file mode 100644 index 0c8ab093faf..00000000000 --- a/resource-manager/apimanagement/2021-08-01/apioperationsbytag/method_operationlistbytags_autorest.go +++ /dev/null @@ -1,230 +0,0 @@ -package apioperationsbytag - -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 OperationListByTagsOperationResponse struct { - HttpResponse *http.Response - Model *[]TagResourceContract - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (OperationListByTagsOperationResponse, error) -} - -type OperationListByTagsCompleteResult struct { - Items []TagResourceContract -} - -func (r OperationListByTagsOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r OperationListByTagsOperationResponse) LoadMore(ctx context.Context) (resp OperationListByTagsOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -type OperationListByTagsOperationOptions struct { - Filter *string - IncludeNotTaggedOperations *bool - Skip *int64 - Top *int64 -} - -func DefaultOperationListByTagsOperationOptions() OperationListByTagsOperationOptions { - return OperationListByTagsOperationOptions{} -} - -func (o OperationListByTagsOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o OperationListByTagsOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Filter != nil { - out["$filter"] = *o.Filter - } - - if o.IncludeNotTaggedOperations != nil { - out["includeNotTaggedOperations"] = *o.IncludeNotTaggedOperations - } - - if o.Skip != nil { - out["$skip"] = *o.Skip - } - - if o.Top != nil { - out["$top"] = *o.Top - } - - return out -} - -// OperationListByTags ... -func (c ApiOperationsByTagClient) OperationListByTags(ctx context.Context, id ApiId, options OperationListByTagsOperationOptions) (resp OperationListByTagsOperationResponse, err error) { - req, err := c.preparerForOperationListByTags(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "apioperationsbytag.ApiOperationsByTagClient", "OperationListByTags", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apioperationsbytag.ApiOperationsByTagClient", "OperationListByTags", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForOperationListByTags(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apioperationsbytag.ApiOperationsByTagClient", "OperationListByTags", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForOperationListByTags prepares the OperationListByTags request. -func (c ApiOperationsByTagClient) preparerForOperationListByTags(ctx context.Context, id ApiId, options OperationListByTagsOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/operationsByTags", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForOperationListByTagsWithNextLink prepares the OperationListByTags request with the given nextLink token. -func (c ApiOperationsByTagClient) preparerForOperationListByTagsWithNextLink(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)) -} - -// responderForOperationListByTags handles the response to the OperationListByTags request. The method always -// closes the http.Response Body. -func (c ApiOperationsByTagClient) responderForOperationListByTags(resp *http.Response) (result OperationListByTagsOperationResponse, err error) { - type page struct { - Values []TagResourceContract `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 OperationListByTagsOperationResponse, err error) { - req, err := c.preparerForOperationListByTagsWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "apioperationsbytag.ApiOperationsByTagClient", "OperationListByTags", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apioperationsbytag.ApiOperationsByTagClient", "OperationListByTags", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForOperationListByTags(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apioperationsbytag.ApiOperationsByTagClient", "OperationListByTags", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// OperationListByTagsComplete retrieves all of the results into a single object -func (c ApiOperationsByTagClient) OperationListByTagsComplete(ctx context.Context, id ApiId, options OperationListByTagsOperationOptions) (OperationListByTagsCompleteResult, error) { - return c.OperationListByTagsCompleteMatchingPredicate(ctx, id, options, TagResourceContractOperationPredicate{}) -} - -// OperationListByTagsCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c ApiOperationsByTagClient) OperationListByTagsCompleteMatchingPredicate(ctx context.Context, id ApiId, options OperationListByTagsOperationOptions, predicate TagResourceContractOperationPredicate) (resp OperationListByTagsCompleteResult, err error) { - items := make([]TagResourceContract, 0) - - page, err := c.OperationListByTags(ctx, id, options) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := OperationListByTagsCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/apimanagement/2021-08-01/apioperationtag/client.go b/resource-manager/apimanagement/2021-08-01/apioperationtag/client.go index 3bfc477ea28..5ddac6abce5 100644 --- a/resource-manager/apimanagement/2021-08-01/apioperationtag/client.go +++ b/resource-manager/apimanagement/2021-08-01/apioperationtag/client.go @@ -1,18 +1,26 @@ package apioperationtag -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 ApiOperationTagClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewApiOperationTagClientWithBaseURI(endpoint string) ApiOperationTagClient { - return ApiOperationTagClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewApiOperationTagClientWithBaseURI(api environments.Api) (*ApiOperationTagClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "apioperationtag", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ApiOperationTagClient: %+v", err) } + + return &ApiOperationTagClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2021-08-01/apioperationtag/method_tagassigntooperation.go b/resource-manager/apimanagement/2021-08-01/apioperationtag/method_tagassigntooperation.go new file mode 100644 index 00000000000..2c431fe03fa --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/apioperationtag/method_tagassigntooperation.go @@ -0,0 +1,52 @@ +package apioperationtag + +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 TagAssignToOperationOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *TagContract +} + +// TagAssignToOperation ... +func (c ApiOperationTagClient) TagAssignToOperation(ctx context.Context, id OperationTagId) (result TagAssignToOperationOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + 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/apimanagement/2021-08-01/apioperationtag/method_tagassigntooperation_autorest.go b/resource-manager/apimanagement/2021-08-01/apioperationtag/method_tagassigntooperation_autorest.go deleted file mode 100644 index 9d8aa0afd9a..00000000000 --- a/resource-manager/apimanagement/2021-08-01/apioperationtag/method_tagassigntooperation_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package apioperationtag - -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 TagAssignToOperationOperationResponse struct { - HttpResponse *http.Response - Model *TagContract -} - -// TagAssignToOperation ... -func (c ApiOperationTagClient) TagAssignToOperation(ctx context.Context, id OperationTagId) (result TagAssignToOperationOperationResponse, err error) { - req, err := c.preparerForTagAssignToOperation(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "apioperationtag.ApiOperationTagClient", "TagAssignToOperation", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apioperationtag.ApiOperationTagClient", "TagAssignToOperation", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForTagAssignToOperation(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apioperationtag.ApiOperationTagClient", "TagAssignToOperation", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForTagAssignToOperation prepares the TagAssignToOperation request. -func (c ApiOperationTagClient) preparerForTagAssignToOperation(ctx context.Context, id OperationTagId) (*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.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForTagAssignToOperation handles the response to the TagAssignToOperation request. The method always -// closes the http.Response Body. -func (c ApiOperationTagClient) responderForTagAssignToOperation(resp *http.Response) (result TagAssignToOperationOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2021-08-01/apioperationtag/method_tagdetachfromoperation.go b/resource-manager/apimanagement/2021-08-01/apioperationtag/method_tagdetachfromoperation.go new file mode 100644 index 00000000000..b49f13cabd9 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/apioperationtag/method_tagdetachfromoperation.go @@ -0,0 +1,47 @@ +package apioperationtag + +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 TagDetachFromOperationOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// TagDetachFromOperation ... +func (c ApiOperationTagClient) TagDetachFromOperation(ctx context.Context, id OperationTagId) (result TagDetachFromOperationOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2021-08-01/apioperationtag/method_tagdetachfromoperation_autorest.go b/resource-manager/apimanagement/2021-08-01/apioperationtag/method_tagdetachfromoperation_autorest.go deleted file mode 100644 index b7845a36364..00000000000 --- a/resource-manager/apimanagement/2021-08-01/apioperationtag/method_tagdetachfromoperation_autorest.go +++ /dev/null @@ -1,66 +0,0 @@ -package apioperationtag - -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 TagDetachFromOperationOperationResponse struct { - HttpResponse *http.Response -} - -// TagDetachFromOperation ... -func (c ApiOperationTagClient) TagDetachFromOperation(ctx context.Context, id OperationTagId) (result TagDetachFromOperationOperationResponse, err error) { - req, err := c.preparerForTagDetachFromOperation(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "apioperationtag.ApiOperationTagClient", "TagDetachFromOperation", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apioperationtag.ApiOperationTagClient", "TagDetachFromOperation", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForTagDetachFromOperation(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apioperationtag.ApiOperationTagClient", "TagDetachFromOperation", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForTagDetachFromOperation prepares the TagDetachFromOperation request. -func (c ApiOperationTagClient) preparerForTagDetachFromOperation(ctx context.Context, id OperationTagId) (*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)) -} - -// responderForTagDetachFromOperation handles the response to the TagDetachFromOperation request. The method always -// closes the http.Response Body. -func (c ApiOperationTagClient) responderForTagDetachFromOperation(resp *http.Response) (result TagDetachFromOperationOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2021-08-01/apioperationtag/method_taggetbyoperation.go b/resource-manager/apimanagement/2021-08-01/apioperationtag/method_taggetbyoperation.go new file mode 100644 index 00000000000..a56dc05b28f --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/apioperationtag/method_taggetbyoperation.go @@ -0,0 +1,51 @@ +package apioperationtag + +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 TagGetByOperationOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *TagContract +} + +// TagGetByOperation ... +func (c ApiOperationTagClient) TagGetByOperation(ctx context.Context, id OperationTagId) (result TagGetByOperationOperationResponse, 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/apimanagement/2021-08-01/apioperationtag/method_taggetbyoperation_autorest.go b/resource-manager/apimanagement/2021-08-01/apioperationtag/method_taggetbyoperation_autorest.go deleted file mode 100644 index 8e6507984f5..00000000000 --- a/resource-manager/apimanagement/2021-08-01/apioperationtag/method_taggetbyoperation_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package apioperationtag - -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 TagGetByOperationOperationResponse struct { - HttpResponse *http.Response - Model *TagContract -} - -// TagGetByOperation ... -func (c ApiOperationTagClient) TagGetByOperation(ctx context.Context, id OperationTagId) (result TagGetByOperationOperationResponse, err error) { - req, err := c.preparerForTagGetByOperation(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "apioperationtag.ApiOperationTagClient", "TagGetByOperation", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apioperationtag.ApiOperationTagClient", "TagGetByOperation", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForTagGetByOperation(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apioperationtag.ApiOperationTagClient", "TagGetByOperation", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForTagGetByOperation prepares the TagGetByOperation request. -func (c ApiOperationTagClient) preparerForTagGetByOperation(ctx context.Context, id OperationTagId) (*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)) -} - -// responderForTagGetByOperation handles the response to the TagGetByOperation request. The method always -// closes the http.Response Body. -func (c ApiOperationTagClient) responderForTagGetByOperation(resp *http.Response) (result TagGetByOperationOperationResponse, 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/apimanagement/2021-08-01/apioperationtag/method_taggetentitystatebyoperation.go b/resource-manager/apimanagement/2021-08-01/apioperationtag/method_taggetentitystatebyoperation.go new file mode 100644 index 00000000000..066af82b190 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/apioperationtag/method_taggetentitystatebyoperation.go @@ -0,0 +1,46 @@ +package apioperationtag + +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 TagGetEntityStateByOperationOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// TagGetEntityStateByOperation ... +func (c ApiOperationTagClient) TagGetEntityStateByOperation(ctx context.Context, id OperationTagId) (result TagGetEntityStateByOperationOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodHead, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2021-08-01/apioperationtag/method_taggetentitystatebyoperation_autorest.go b/resource-manager/apimanagement/2021-08-01/apioperationtag/method_taggetentitystatebyoperation_autorest.go deleted file mode 100644 index beaef9dc15a..00000000000 --- a/resource-manager/apimanagement/2021-08-01/apioperationtag/method_taggetentitystatebyoperation_autorest.go +++ /dev/null @@ -1,66 +0,0 @@ -package apioperationtag - -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 TagGetEntityStateByOperationOperationResponse struct { - HttpResponse *http.Response -} - -// TagGetEntityStateByOperation ... -func (c ApiOperationTagClient) TagGetEntityStateByOperation(ctx context.Context, id OperationTagId) (result TagGetEntityStateByOperationOperationResponse, err error) { - req, err := c.preparerForTagGetEntityStateByOperation(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "apioperationtag.ApiOperationTagClient", "TagGetEntityStateByOperation", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apioperationtag.ApiOperationTagClient", "TagGetEntityStateByOperation", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForTagGetEntityStateByOperation(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apioperationtag.ApiOperationTagClient", "TagGetEntityStateByOperation", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForTagGetEntityStateByOperation prepares the TagGetEntityStateByOperation request. -func (c ApiOperationTagClient) preparerForTagGetEntityStateByOperation(ctx context.Context, id OperationTagId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsHead(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForTagGetEntityStateByOperation handles the response to the TagGetEntityStateByOperation request. The method always -// closes the http.Response Body. -func (c ApiOperationTagClient) responderForTagGetEntityStateByOperation(resp *http.Response) (result TagGetEntityStateByOperationOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2021-08-01/apioperationtag/method_taglistbyoperation.go b/resource-manager/apimanagement/2021-08-01/apioperationtag/method_taglistbyoperation.go new file mode 100644 index 00000000000..b857e4ac190 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/apioperationtag/method_taglistbyoperation.go @@ -0,0 +1,125 @@ +package apioperationtag + +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 TagListByOperationOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]TagContract +} + +type TagListByOperationCompleteResult struct { + Items []TagContract +} + +type TagListByOperationOperationOptions struct { + Filter *string + Skip *int64 + Top *int64 +} + +func DefaultTagListByOperationOperationOptions() TagListByOperationOperationOptions { + return TagListByOperationOperationOptions{} +} + +func (o TagListByOperationOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o TagListByOperationOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o TagListByOperationOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.Skip != nil { + out.Append("$skip", fmt.Sprintf("%v", *o.Skip)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +// TagListByOperation ... +func (c ApiOperationTagClient) TagListByOperation(ctx context.Context, id OperationId, options TagListByOperationOperationOptions) (result TagListByOperationOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/tags", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]TagContract `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// TagListByOperationComplete retrieves all the results into a single object +func (c ApiOperationTagClient) TagListByOperationComplete(ctx context.Context, id OperationId, options TagListByOperationOperationOptions) (TagListByOperationCompleteResult, error) { + return c.TagListByOperationCompleteMatchingPredicate(ctx, id, options, TagContractOperationPredicate{}) +} + +// TagListByOperationCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ApiOperationTagClient) TagListByOperationCompleteMatchingPredicate(ctx context.Context, id OperationId, options TagListByOperationOperationOptions, predicate TagContractOperationPredicate) (result TagListByOperationCompleteResult, err error) { + items := make([]TagContract, 0) + + resp, err := c.TagListByOperation(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = TagListByOperationCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/apimanagement/2021-08-01/apioperationtag/method_taglistbyoperation_autorest.go b/resource-manager/apimanagement/2021-08-01/apioperationtag/method_taglistbyoperation_autorest.go deleted file mode 100644 index 5bc7a969362..00000000000 --- a/resource-manager/apimanagement/2021-08-01/apioperationtag/method_taglistbyoperation_autorest.go +++ /dev/null @@ -1,225 +0,0 @@ -package apioperationtag - -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 TagListByOperationOperationResponse struct { - HttpResponse *http.Response - Model *[]TagContract - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (TagListByOperationOperationResponse, error) -} - -type TagListByOperationCompleteResult struct { - Items []TagContract -} - -func (r TagListByOperationOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r TagListByOperationOperationResponse) LoadMore(ctx context.Context) (resp TagListByOperationOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -type TagListByOperationOperationOptions struct { - Filter *string - Skip *int64 - Top *int64 -} - -func DefaultTagListByOperationOperationOptions() TagListByOperationOperationOptions { - return TagListByOperationOperationOptions{} -} - -func (o TagListByOperationOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o TagListByOperationOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Filter != nil { - out["$filter"] = *o.Filter - } - - if o.Skip != nil { - out["$skip"] = *o.Skip - } - - if o.Top != nil { - out["$top"] = *o.Top - } - - return out -} - -// TagListByOperation ... -func (c ApiOperationTagClient) TagListByOperation(ctx context.Context, id OperationId, options TagListByOperationOperationOptions) (resp TagListByOperationOperationResponse, err error) { - req, err := c.preparerForTagListByOperation(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "apioperationtag.ApiOperationTagClient", "TagListByOperation", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apioperationtag.ApiOperationTagClient", "TagListByOperation", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForTagListByOperation(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apioperationtag.ApiOperationTagClient", "TagListByOperation", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForTagListByOperation prepares the TagListByOperation request. -func (c ApiOperationTagClient) preparerForTagListByOperation(ctx context.Context, id OperationId, options TagListByOperationOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/tags", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForTagListByOperationWithNextLink prepares the TagListByOperation request with the given nextLink token. -func (c ApiOperationTagClient) preparerForTagListByOperationWithNextLink(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)) -} - -// responderForTagListByOperation handles the response to the TagListByOperation request. The method always -// closes the http.Response Body. -func (c ApiOperationTagClient) responderForTagListByOperation(resp *http.Response) (result TagListByOperationOperationResponse, err error) { - type page struct { - Values []TagContract `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 TagListByOperationOperationResponse, err error) { - req, err := c.preparerForTagListByOperationWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "apioperationtag.ApiOperationTagClient", "TagListByOperation", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apioperationtag.ApiOperationTagClient", "TagListByOperation", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForTagListByOperation(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apioperationtag.ApiOperationTagClient", "TagListByOperation", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// TagListByOperationComplete retrieves all of the results into a single object -func (c ApiOperationTagClient) TagListByOperationComplete(ctx context.Context, id OperationId, options TagListByOperationOperationOptions) (TagListByOperationCompleteResult, error) { - return c.TagListByOperationCompleteMatchingPredicate(ctx, id, options, TagContractOperationPredicate{}) -} - -// TagListByOperationCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c ApiOperationTagClient) TagListByOperationCompleteMatchingPredicate(ctx context.Context, id OperationId, options TagListByOperationOperationOptions, predicate TagContractOperationPredicate) (resp TagListByOperationCompleteResult, err error) { - items := make([]TagContract, 0) - - page, err := c.TagListByOperation(ctx, id, options) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := TagListByOperationCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/apimanagement/2021-08-01/apipolicy/client.go b/resource-manager/apimanagement/2021-08-01/apipolicy/client.go index 849c529fef4..036eadf1bfd 100644 --- a/resource-manager/apimanagement/2021-08-01/apipolicy/client.go +++ b/resource-manager/apimanagement/2021-08-01/apipolicy/client.go @@ -1,18 +1,26 @@ package apipolicy -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 ApiPolicyClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewApiPolicyClientWithBaseURI(endpoint string) ApiPolicyClient { - return ApiPolicyClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewApiPolicyClientWithBaseURI(api environments.Api) (*ApiPolicyClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "apipolicy", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ApiPolicyClient: %+v", err) } + + return &ApiPolicyClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2021-08-01/apipolicy/constants.go b/resource-manager/apimanagement/2021-08-01/apipolicy/constants.go index 0622a9d8ec5..3a402942dd8 100644 --- a/resource-manager/apimanagement/2021-08-01/apipolicy/constants.go +++ b/resource-manager/apimanagement/2021-08-01/apipolicy/constants.go @@ -1,6 +1,10 @@ package apipolicy -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 PossibleValuesForPolicyContentFormat() []string { } } +func (s *PolicyContentFormat) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePolicyContentFormat(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parsePolicyContentFormat(input string) (*PolicyContentFormat, error) { vals := map[string]PolicyContentFormat{ "rawxml": PolicyContentFormatRawxml, @@ -53,6 +70,19 @@ func PossibleValuesForPolicyExportFormat() []string { } } +func (s *PolicyExportFormat) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePolicyExportFormat(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parsePolicyExportFormat(input string) (*PolicyExportFormat, error) { vals := map[string]PolicyExportFormat{ "rawxml": PolicyExportFormatRawxml, diff --git a/resource-manager/apimanagement/2021-08-01/apipolicy/method_createorupdate.go b/resource-manager/apimanagement/2021-08-01/apipolicy/method_createorupdate.go new file mode 100644 index 00000000000..34932d9e40b --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/apipolicy/method_createorupdate.go @@ -0,0 +1,85 @@ +package apipolicy + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PolicyContract +} + +type CreateOrUpdateOperationOptions struct { + IfMatch *string +} + +func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { + return CreateOrUpdateOperationOptions{} +} + +func (o CreateOrUpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o CreateOrUpdateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o CreateOrUpdateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// CreateOrUpdate ... +func (c ApiPolicyClient) CreateOrUpdate(ctx context.Context, id ApiId, input PolicyContract, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/policies/policy", id.ID()), + OptionsObject: options, + } + + 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/apimanagement/2021-08-01/apipolicy/method_createorupdate_autorest.go b/resource-manager/apimanagement/2021-08-01/apipolicy/method_createorupdate_autorest.go deleted file mode 100644 index 1d3e07d089c..00000000000 --- a/resource-manager/apimanagement/2021-08-01/apipolicy/method_createorupdate_autorest.go +++ /dev/null @@ -1,99 +0,0 @@ -package apipolicy - -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 CreateOrUpdateOperationResponse struct { - HttpResponse *http.Response - Model *PolicyContract -} - -type CreateOrUpdateOperationOptions struct { - IfMatch *string -} - -func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { - return CreateOrUpdateOperationOptions{} -} - -func (o CreateOrUpdateOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o CreateOrUpdateOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// CreateOrUpdate ... -func (c ApiPolicyClient) CreateOrUpdate(ctx context.Context, id ApiId, input PolicyContract, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdate(ctx, id, input, options) - if err != nil { - err = autorest.NewErrorWithError(err, "apipolicy.ApiPolicyClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apipolicy.ApiPolicyClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCreateOrUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apipolicy.ApiPolicyClient", "CreateOrUpdate", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCreateOrUpdate prepares the CreateOrUpdate request. -func (c ApiPolicyClient) preparerForCreateOrUpdate(ctx context.Context, id ApiId, input PolicyContract, options CreateOrUpdateOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/policies/policy", 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 ApiPolicyClient) responderForCreateOrUpdate(resp *http.Response) (result CreateOrUpdateOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2021-08-01/apipolicy/method_delete.go b/resource-manager/apimanagement/2021-08-01/apipolicy/method_delete.go new file mode 100644 index 00000000000..10b8c3c63c0 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/apipolicy/method_delete.go @@ -0,0 +1,76 @@ +package apipolicy + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +type DeleteOperationOptions struct { + IfMatch *string +} + +func DefaultDeleteOperationOptions() DeleteOperationOptions { + return DeleteOperationOptions{} +} + +func (o DeleteOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o DeleteOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o DeleteOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// Delete ... +func (c ApiPolicyClient) Delete(ctx context.Context, id ApiId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: fmt.Sprintf("%s/policies/policy", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2021-08-01/apipolicy/method_delete_autorest.go b/resource-manager/apimanagement/2021-08-01/apipolicy/method_delete_autorest.go deleted file mode 100644 index 010fbd8de58..00000000000 --- a/resource-manager/apimanagement/2021-08-01/apipolicy/method_delete_autorest.go +++ /dev/null @@ -1,96 +0,0 @@ -package apipolicy - -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 DeleteOperationResponse struct { - HttpResponse *http.Response -} - -type DeleteOperationOptions struct { - IfMatch *string -} - -func DefaultDeleteOperationOptions() DeleteOperationOptions { - return DeleteOperationOptions{} -} - -func (o DeleteOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o DeleteOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// Delete ... -func (c ApiPolicyClient) Delete(ctx context.Context, id ApiId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { - req, err := c.preparerForDelete(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "apipolicy.ApiPolicyClient", "Delete", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apipolicy.ApiPolicyClient", "Delete", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForDelete(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apipolicy.ApiPolicyClient", "Delete", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForDelete prepares the Delete request. -func (c ApiPolicyClient) preparerForDelete(ctx context.Context, id ApiId, options DeleteOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/policies/policy", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForDelete handles the response to the Delete request. The method always -// closes the http.Response Body. -func (c ApiPolicyClient) responderForDelete(resp *http.Response) (result DeleteOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2021-08-01/apipolicy/method_get.go b/resource-manager/apimanagement/2021-08-01/apipolicy/method_get.go new file mode 100644 index 00000000000..aaa7b1d2c78 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/apipolicy/method_get.go @@ -0,0 +1,80 @@ +package apipolicy + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PolicyContract +} + +type GetOperationOptions struct { + Format *PolicyExportFormat +} + +func DefaultGetOperationOptions() GetOperationOptions { + return GetOperationOptions{} +} + +func (o GetOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o GetOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o GetOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Format != nil { + out.Append("format", fmt.Sprintf("%v", *o.Format)) + } + return &out +} + +// Get ... +func (c ApiPolicyClient) Get(ctx context.Context, id ApiId, options GetOperationOptions) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/policies/policy", id.ID()), + OptionsObject: options, + } + + 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/apimanagement/2021-08-01/apipolicy/method_get_autorest.go b/resource-manager/apimanagement/2021-08-01/apipolicy/method_get_autorest.go deleted file mode 100644 index 4003515afa2..00000000000 --- a/resource-manager/apimanagement/2021-08-01/apipolicy/method_get_autorest.go +++ /dev/null @@ -1,98 +0,0 @@ -package apipolicy - -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 GetOperationResponse struct { - HttpResponse *http.Response - Model *PolicyContract -} - -type GetOperationOptions struct { - Format *PolicyExportFormat -} - -func DefaultGetOperationOptions() GetOperationOptions { - return GetOperationOptions{} -} - -func (o GetOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o GetOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Format != nil { - out["format"] = *o.Format - } - - return out -} - -// Get ... -func (c ApiPolicyClient) Get(ctx context.Context, id ApiId, options GetOperationOptions) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "apipolicy.ApiPolicyClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apipolicy.ApiPolicyClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apipolicy.ApiPolicyClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c ApiPolicyClient) preparerForGet(ctx context.Context, id ApiId, options GetOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/policies/policy", 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 ApiPolicyClient) 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/apimanagement/2021-08-01/apipolicy/method_getentitytag.go b/resource-manager/apimanagement/2021-08-01/apipolicy/method_getentitytag.go new file mode 100644 index 00000000000..5ab255150b8 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/apipolicy/method_getentitytag.go @@ -0,0 +1,47 @@ +package apipolicy + +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 GetEntityTagOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// GetEntityTag ... +func (c ApiPolicyClient) GetEntityTag(ctx context.Context, id ApiId) (result GetEntityTagOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodHead, + Path: fmt.Sprintf("%s/policies/policy", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2021-08-01/apipolicy/method_getentitytag_autorest.go b/resource-manager/apimanagement/2021-08-01/apipolicy/method_getentitytag_autorest.go deleted file mode 100644 index 522426b034b..00000000000 --- a/resource-manager/apimanagement/2021-08-01/apipolicy/method_getentitytag_autorest.go +++ /dev/null @@ -1,67 +0,0 @@ -package apipolicy - -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 GetEntityTagOperationResponse struct { - HttpResponse *http.Response -} - -// GetEntityTag ... -func (c ApiPolicyClient) GetEntityTag(ctx context.Context, id ApiId) (result GetEntityTagOperationResponse, err error) { - req, err := c.preparerForGetEntityTag(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "apipolicy.ApiPolicyClient", "GetEntityTag", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apipolicy.ApiPolicyClient", "GetEntityTag", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetEntityTag(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apipolicy.ApiPolicyClient", "GetEntityTag", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetEntityTag prepares the GetEntityTag request. -func (c ApiPolicyClient) preparerForGetEntityTag(ctx context.Context, id ApiId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsHead(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/policies/policy", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetEntityTag handles the response to the GetEntityTag request. The method always -// closes the http.Response Body. -func (c ApiPolicyClient) responderForGetEntityTag(resp *http.Response) (result GetEntityTagOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2021-08-01/apipolicy/method_listbyapi.go b/resource-manager/apimanagement/2021-08-01/apipolicy/method_listbyapi.go new file mode 100644 index 00000000000..5afb8149c87 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/apipolicy/method_listbyapi.go @@ -0,0 +1,52 @@ +package apipolicy + +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 ListByApiOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PolicyCollection +} + +// ListByApi ... +func (c ApiPolicyClient) ListByApi(ctx context.Context, id ApiId) (result ListByApiOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/policies", 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/apimanagement/2021-08-01/apipolicy/method_listbyapi_autorest.go b/resource-manager/apimanagement/2021-08-01/apipolicy/method_listbyapi_autorest.go deleted file mode 100644 index 3c5cfc6d95f..00000000000 --- a/resource-manager/apimanagement/2021-08-01/apipolicy/method_listbyapi_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package apipolicy - -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 ListByApiOperationResponse struct { - HttpResponse *http.Response - Model *PolicyCollection -} - -// ListByApi ... -func (c ApiPolicyClient) ListByApi(ctx context.Context, id ApiId) (result ListByApiOperationResponse, err error) { - req, err := c.preparerForListByApi(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "apipolicy.ApiPolicyClient", "ListByApi", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apipolicy.ApiPolicyClient", "ListByApi", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByApi(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apipolicy.ApiPolicyClient", "ListByApi", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForListByApi prepares the ListByApi request. -func (c ApiPolicyClient) preparerForListByApi(ctx context.Context, id ApiId) (*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/policies", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListByApi handles the response to the ListByApi request. The method always -// closes the http.Response Body. -func (c ApiPolicyClient) responderForListByApi(resp *http.Response) (result ListByApiOperationResponse, 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/apimanagement/2021-08-01/apiproduct/client.go b/resource-manager/apimanagement/2021-08-01/apiproduct/client.go index 4c35dacbaa3..87853216789 100644 --- a/resource-manager/apimanagement/2021-08-01/apiproduct/client.go +++ b/resource-manager/apimanagement/2021-08-01/apiproduct/client.go @@ -1,18 +1,26 @@ package apiproduct -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 ApiProductClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewApiProductClientWithBaseURI(endpoint string) ApiProductClient { - return ApiProductClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewApiProductClientWithBaseURI(api environments.Api) (*ApiProductClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "apiproduct", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ApiProductClient: %+v", err) } + + return &ApiProductClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2021-08-01/apiproduct/constants.go b/resource-manager/apimanagement/2021-08-01/apiproduct/constants.go index f0fb051f3c2..12fdc8dd3d6 100644 --- a/resource-manager/apimanagement/2021-08-01/apiproduct/constants.go +++ b/resource-manager/apimanagement/2021-08-01/apiproduct/constants.go @@ -1,6 +1,10 @@ package apiproduct -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 PossibleValuesForProductState() []string { } } +func (s *ProductState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProductState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseProductState(input string) (*ProductState, error) { vals := map[string]ProductState{ "notpublished": ProductStateNotPublished, diff --git a/resource-manager/apimanagement/2021-08-01/apiproduct/method_listbyapis.go b/resource-manager/apimanagement/2021-08-01/apiproduct/method_listbyapis.go new file mode 100644 index 00000000000..2acd3899dfb --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/apiproduct/method_listbyapis.go @@ -0,0 +1,125 @@ +package apiproduct + +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 ListByApisOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ProductContract +} + +type ListByApisCompleteResult struct { + Items []ProductContract +} + +type ListByApisOperationOptions struct { + Filter *string + Skip *int64 + Top *int64 +} + +func DefaultListByApisOperationOptions() ListByApisOperationOptions { + return ListByApisOperationOptions{} +} + +func (o ListByApisOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListByApisOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListByApisOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.Skip != nil { + out.Append("$skip", fmt.Sprintf("%v", *o.Skip)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +// ListByApis ... +func (c ApiProductClient) ListByApis(ctx context.Context, id ApiId, options ListByApisOperationOptions) (result ListByApisOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/products", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ProductContract `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByApisComplete retrieves all the results into a single object +func (c ApiProductClient) ListByApisComplete(ctx context.Context, id ApiId, options ListByApisOperationOptions) (ListByApisCompleteResult, error) { + return c.ListByApisCompleteMatchingPredicate(ctx, id, options, ProductContractOperationPredicate{}) +} + +// ListByApisCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ApiProductClient) ListByApisCompleteMatchingPredicate(ctx context.Context, id ApiId, options ListByApisOperationOptions, predicate ProductContractOperationPredicate) (result ListByApisCompleteResult, err error) { + items := make([]ProductContract, 0) + + resp, err := c.ListByApis(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByApisCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/apimanagement/2021-08-01/apiproduct/method_listbyapis_autorest.go b/resource-manager/apimanagement/2021-08-01/apiproduct/method_listbyapis_autorest.go deleted file mode 100644 index 3ef1fe2b276..00000000000 --- a/resource-manager/apimanagement/2021-08-01/apiproduct/method_listbyapis_autorest.go +++ /dev/null @@ -1,225 +0,0 @@ -package apiproduct - -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 ListByApisOperationResponse struct { - HttpResponse *http.Response - Model *[]ProductContract - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListByApisOperationResponse, error) -} - -type ListByApisCompleteResult struct { - Items []ProductContract -} - -func (r ListByApisOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListByApisOperationResponse) LoadMore(ctx context.Context) (resp ListByApisOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -type ListByApisOperationOptions struct { - Filter *string - Skip *int64 - Top *int64 -} - -func DefaultListByApisOperationOptions() ListByApisOperationOptions { - return ListByApisOperationOptions{} -} - -func (o ListByApisOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o ListByApisOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Filter != nil { - out["$filter"] = *o.Filter - } - - if o.Skip != nil { - out["$skip"] = *o.Skip - } - - if o.Top != nil { - out["$top"] = *o.Top - } - - return out -} - -// ListByApis ... -func (c ApiProductClient) ListByApis(ctx context.Context, id ApiId, options ListByApisOperationOptions) (resp ListByApisOperationResponse, err error) { - req, err := c.preparerForListByApis(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "apiproduct.ApiProductClient", "ListByApis", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apiproduct.ApiProductClient", "ListByApis", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListByApis(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apiproduct.ApiProductClient", "ListByApis", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListByApis prepares the ListByApis request. -func (c ApiProductClient) preparerForListByApis(ctx context.Context, id ApiId, options ListByApisOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/products", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListByApisWithNextLink prepares the ListByApis request with the given nextLink token. -func (c ApiProductClient) preparerForListByApisWithNextLink(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)) -} - -// responderForListByApis handles the response to the ListByApis request. The method always -// closes the http.Response Body. -func (c ApiProductClient) responderForListByApis(resp *http.Response) (result ListByApisOperationResponse, err error) { - type page struct { - Values []ProductContract `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 ListByApisOperationResponse, err error) { - req, err := c.preparerForListByApisWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "apiproduct.ApiProductClient", "ListByApis", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apiproduct.ApiProductClient", "ListByApis", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByApis(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apiproduct.ApiProductClient", "ListByApis", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListByApisComplete retrieves all of the results into a single object -func (c ApiProductClient) ListByApisComplete(ctx context.Context, id ApiId, options ListByApisOperationOptions) (ListByApisCompleteResult, error) { - return c.ListByApisCompleteMatchingPredicate(ctx, id, options, ProductContractOperationPredicate{}) -} - -// ListByApisCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c ApiProductClient) ListByApisCompleteMatchingPredicate(ctx context.Context, id ApiId, options ListByApisOperationOptions, predicate ProductContractOperationPredicate) (resp ListByApisCompleteResult, err error) { - items := make([]ProductContract, 0) - - page, err := c.ListByApis(ctx, id, options) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListByApisCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/apimanagement/2021-08-01/apirelease/client.go b/resource-manager/apimanagement/2021-08-01/apirelease/client.go index 7daeaa5351d..452fd61dfa4 100644 --- a/resource-manager/apimanagement/2021-08-01/apirelease/client.go +++ b/resource-manager/apimanagement/2021-08-01/apirelease/client.go @@ -1,18 +1,26 @@ package apirelease -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 ApiReleaseClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewApiReleaseClientWithBaseURI(endpoint string) ApiReleaseClient { - return ApiReleaseClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewApiReleaseClientWithBaseURI(api environments.Api) (*ApiReleaseClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "apirelease", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ApiReleaseClient: %+v", err) } + + return &ApiReleaseClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2021-08-01/apirelease/method_createorupdate.go b/resource-manager/apimanagement/2021-08-01/apirelease/method_createorupdate.go new file mode 100644 index 00000000000..406976fb2f8 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/apirelease/method_createorupdate.go @@ -0,0 +1,85 @@ +package apirelease + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ApiReleaseContract +} + +type CreateOrUpdateOperationOptions struct { + IfMatch *string +} + +func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { + return CreateOrUpdateOperationOptions{} +} + +func (o CreateOrUpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o CreateOrUpdateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o CreateOrUpdateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// CreateOrUpdate ... +func (c ApiReleaseClient) CreateOrUpdate(ctx context.Context, id ReleaseId, input ApiReleaseContract, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + OptionsObject: options, + } + + 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/apimanagement/2021-08-01/apirelease/method_createorupdate_autorest.go b/resource-manager/apimanagement/2021-08-01/apirelease/method_createorupdate_autorest.go deleted file mode 100644 index a9bb0d861fe..00000000000 --- a/resource-manager/apimanagement/2021-08-01/apirelease/method_createorupdate_autorest.go +++ /dev/null @@ -1,98 +0,0 @@ -package apirelease - -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 *ApiReleaseContract -} - -type CreateOrUpdateOperationOptions struct { - IfMatch *string -} - -func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { - return CreateOrUpdateOperationOptions{} -} - -func (o CreateOrUpdateOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o CreateOrUpdateOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// CreateOrUpdate ... -func (c ApiReleaseClient) CreateOrUpdate(ctx context.Context, id ReleaseId, input ApiReleaseContract, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdate(ctx, id, input, options) - if err != nil { - err = autorest.NewErrorWithError(err, "apirelease.ApiReleaseClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apirelease.ApiReleaseClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCreateOrUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apirelease.ApiReleaseClient", "CreateOrUpdate", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCreateOrUpdate prepares the CreateOrUpdate request. -func (c ApiReleaseClient) preparerForCreateOrUpdate(ctx context.Context, id ReleaseId, input ApiReleaseContract, options CreateOrUpdateOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - 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 ApiReleaseClient) responderForCreateOrUpdate(resp *http.Response) (result CreateOrUpdateOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2021-08-01/apirelease/method_delete.go b/resource-manager/apimanagement/2021-08-01/apirelease/method_delete.go new file mode 100644 index 00000000000..cdfaf120b2b --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/apirelease/method_delete.go @@ -0,0 +1,76 @@ +package apirelease + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +type DeleteOperationOptions struct { + IfMatch *string +} + +func DefaultDeleteOperationOptions() DeleteOperationOptions { + return DeleteOperationOptions{} +} + +func (o DeleteOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o DeleteOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o DeleteOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// Delete ... +func (c ApiReleaseClient) Delete(ctx context.Context, id ReleaseId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2021-08-01/apirelease/method_delete_autorest.go b/resource-manager/apimanagement/2021-08-01/apirelease/method_delete_autorest.go deleted file mode 100644 index d5290cd9c81..00000000000 --- a/resource-manager/apimanagement/2021-08-01/apirelease/method_delete_autorest.go +++ /dev/null @@ -1,95 +0,0 @@ -package apirelease - -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 DeleteOperationResponse struct { - HttpResponse *http.Response -} - -type DeleteOperationOptions struct { - IfMatch *string -} - -func DefaultDeleteOperationOptions() DeleteOperationOptions { - return DeleteOperationOptions{} -} - -func (o DeleteOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o DeleteOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// Delete ... -func (c ApiReleaseClient) Delete(ctx context.Context, id ReleaseId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { - req, err := c.preparerForDelete(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "apirelease.ApiReleaseClient", "Delete", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apirelease.ApiReleaseClient", "Delete", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForDelete(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apirelease.ApiReleaseClient", "Delete", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForDelete prepares the Delete request. -func (c ApiReleaseClient) preparerForDelete(ctx context.Context, id ReleaseId, options DeleteOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForDelete handles the response to the Delete request. The method always -// closes the http.Response Body. -func (c ApiReleaseClient) responderForDelete(resp *http.Response) (result DeleteOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2021-08-01/apirelease/method_get.go b/resource-manager/apimanagement/2021-08-01/apirelease/method_get.go new file mode 100644 index 00000000000..afe7107ae45 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/apirelease/method_get.go @@ -0,0 +1,51 @@ +package apirelease + +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 *ApiReleaseContract +} + +// Get ... +func (c ApiReleaseClient) Get(ctx context.Context, id ReleaseId) (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/apimanagement/2021-08-01/apirelease/method_get_autorest.go b/resource-manager/apimanagement/2021-08-01/apirelease/method_get_autorest.go deleted file mode 100644 index 6b5b8bbd11a..00000000000 --- a/resource-manager/apimanagement/2021-08-01/apirelease/method_get_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package apirelease - -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 *ApiReleaseContract -} - -// Get ... -func (c ApiReleaseClient) Get(ctx context.Context, id ReleaseId) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "apirelease.ApiReleaseClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apirelease.ApiReleaseClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apirelease.ApiReleaseClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c ApiReleaseClient) preparerForGet(ctx context.Context, id ReleaseId) (*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 ApiReleaseClient) 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/apimanagement/2021-08-01/apirelease/method_getentitytag.go b/resource-manager/apimanagement/2021-08-01/apirelease/method_getentitytag.go new file mode 100644 index 00000000000..97a2ff54ef1 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/apirelease/method_getentitytag.go @@ -0,0 +1,46 @@ +package apirelease + +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 GetEntityTagOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// GetEntityTag ... +func (c ApiReleaseClient) GetEntityTag(ctx context.Context, id ReleaseId) (result GetEntityTagOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodHead, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2021-08-01/apirelease/method_getentitytag_autorest.go b/resource-manager/apimanagement/2021-08-01/apirelease/method_getentitytag_autorest.go deleted file mode 100644 index 67f795accdb..00000000000 --- a/resource-manager/apimanagement/2021-08-01/apirelease/method_getentitytag_autorest.go +++ /dev/null @@ -1,66 +0,0 @@ -package apirelease - -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 GetEntityTagOperationResponse struct { - HttpResponse *http.Response -} - -// GetEntityTag ... -func (c ApiReleaseClient) GetEntityTag(ctx context.Context, id ReleaseId) (result GetEntityTagOperationResponse, err error) { - req, err := c.preparerForGetEntityTag(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "apirelease.ApiReleaseClient", "GetEntityTag", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apirelease.ApiReleaseClient", "GetEntityTag", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetEntityTag(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apirelease.ApiReleaseClient", "GetEntityTag", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetEntityTag prepares the GetEntityTag request. -func (c ApiReleaseClient) preparerForGetEntityTag(ctx context.Context, id ReleaseId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsHead(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetEntityTag handles the response to the GetEntityTag request. The method always -// closes the http.Response Body. -func (c ApiReleaseClient) responderForGetEntityTag(resp *http.Response) (result GetEntityTagOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2021-08-01/apirelease/method_listbyservice.go b/resource-manager/apimanagement/2021-08-01/apirelease/method_listbyservice.go new file mode 100644 index 00000000000..ffb1a5e65b4 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/apirelease/method_listbyservice.go @@ -0,0 +1,125 @@ +package apirelease + +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 ListByServiceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ApiReleaseContract +} + +type ListByServiceCompleteResult struct { + Items []ApiReleaseContract +} + +type ListByServiceOperationOptions struct { + Filter *string + Skip *int64 + Top *int64 +} + +func DefaultListByServiceOperationOptions() ListByServiceOperationOptions { + return ListByServiceOperationOptions{} +} + +func (o ListByServiceOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListByServiceOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListByServiceOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.Skip != nil { + out.Append("$skip", fmt.Sprintf("%v", *o.Skip)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +// ListByService ... +func (c ApiReleaseClient) ListByService(ctx context.Context, id ApiId, options ListByServiceOperationOptions) (result ListByServiceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/releases", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ApiReleaseContract `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByServiceComplete retrieves all the results into a single object +func (c ApiReleaseClient) ListByServiceComplete(ctx context.Context, id ApiId, options ListByServiceOperationOptions) (ListByServiceCompleteResult, error) { + return c.ListByServiceCompleteMatchingPredicate(ctx, id, options, ApiReleaseContractOperationPredicate{}) +} + +// ListByServiceCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ApiReleaseClient) ListByServiceCompleteMatchingPredicate(ctx context.Context, id ApiId, options ListByServiceOperationOptions, predicate ApiReleaseContractOperationPredicate) (result ListByServiceCompleteResult, err error) { + items := make([]ApiReleaseContract, 0) + + resp, err := c.ListByService(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByServiceCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/apimanagement/2021-08-01/apirelease/method_listbyservice_autorest.go b/resource-manager/apimanagement/2021-08-01/apirelease/method_listbyservice_autorest.go deleted file mode 100644 index a503853e31a..00000000000 --- a/resource-manager/apimanagement/2021-08-01/apirelease/method_listbyservice_autorest.go +++ /dev/null @@ -1,225 +0,0 @@ -package apirelease - -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 ListByServiceOperationResponse struct { - HttpResponse *http.Response - Model *[]ApiReleaseContract - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListByServiceOperationResponse, error) -} - -type ListByServiceCompleteResult struct { - Items []ApiReleaseContract -} - -func (r ListByServiceOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListByServiceOperationResponse) LoadMore(ctx context.Context) (resp ListByServiceOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -type ListByServiceOperationOptions struct { - Filter *string - Skip *int64 - Top *int64 -} - -func DefaultListByServiceOperationOptions() ListByServiceOperationOptions { - return ListByServiceOperationOptions{} -} - -func (o ListByServiceOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o ListByServiceOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Filter != nil { - out["$filter"] = *o.Filter - } - - if o.Skip != nil { - out["$skip"] = *o.Skip - } - - if o.Top != nil { - out["$top"] = *o.Top - } - - return out -} - -// ListByService ... -func (c ApiReleaseClient) ListByService(ctx context.Context, id ApiId, options ListByServiceOperationOptions) (resp ListByServiceOperationResponse, err error) { - req, err := c.preparerForListByService(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "apirelease.ApiReleaseClient", "ListByService", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apirelease.ApiReleaseClient", "ListByService", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListByService(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apirelease.ApiReleaseClient", "ListByService", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListByService prepares the ListByService request. -func (c ApiReleaseClient) preparerForListByService(ctx context.Context, id ApiId, options ListByServiceOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/releases", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListByServiceWithNextLink prepares the ListByService request with the given nextLink token. -func (c ApiReleaseClient) preparerForListByServiceWithNextLink(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)) -} - -// responderForListByService handles the response to the ListByService request. The method always -// closes the http.Response Body. -func (c ApiReleaseClient) responderForListByService(resp *http.Response) (result ListByServiceOperationResponse, err error) { - type page struct { - Values []ApiReleaseContract `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 ListByServiceOperationResponse, err error) { - req, err := c.preparerForListByServiceWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "apirelease.ApiReleaseClient", "ListByService", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apirelease.ApiReleaseClient", "ListByService", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByService(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apirelease.ApiReleaseClient", "ListByService", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListByServiceComplete retrieves all of the results into a single object -func (c ApiReleaseClient) ListByServiceComplete(ctx context.Context, id ApiId, options ListByServiceOperationOptions) (ListByServiceCompleteResult, error) { - return c.ListByServiceCompleteMatchingPredicate(ctx, id, options, ApiReleaseContractOperationPredicate{}) -} - -// ListByServiceCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c ApiReleaseClient) ListByServiceCompleteMatchingPredicate(ctx context.Context, id ApiId, options ListByServiceOperationOptions, predicate ApiReleaseContractOperationPredicate) (resp ListByServiceCompleteResult, err error) { - items := make([]ApiReleaseContract, 0) - - page, err := c.ListByService(ctx, id, options) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListByServiceCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/apimanagement/2021-08-01/apirelease/method_update.go b/resource-manager/apimanagement/2021-08-01/apirelease/method_update.go new file mode 100644 index 00000000000..23af82628f6 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/apirelease/method_update.go @@ -0,0 +1,84 @@ +package apirelease + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ApiReleaseContract +} + +type UpdateOperationOptions struct { + IfMatch *string +} + +func DefaultUpdateOperationOptions() UpdateOperationOptions { + return UpdateOperationOptions{} +} + +func (o UpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o UpdateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o UpdateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// Update ... +func (c ApiReleaseClient) Update(ctx context.Context, id ReleaseId, input ApiReleaseContract, options UpdateOperationOptions) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + OptionsObject: options, + } + + 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/apimanagement/2021-08-01/apirelease/method_update_autorest.go b/resource-manager/apimanagement/2021-08-01/apirelease/method_update_autorest.go deleted file mode 100644 index b94e10e254e..00000000000 --- a/resource-manager/apimanagement/2021-08-01/apirelease/method_update_autorest.go +++ /dev/null @@ -1,98 +0,0 @@ -package apirelease - -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 *ApiReleaseContract -} - -type UpdateOperationOptions struct { - IfMatch *string -} - -func DefaultUpdateOperationOptions() UpdateOperationOptions { - return UpdateOperationOptions{} -} - -func (o UpdateOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o UpdateOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// Update ... -func (c ApiReleaseClient) Update(ctx context.Context, id ReleaseId, input ApiReleaseContract, options UpdateOperationOptions) (result UpdateOperationResponse, err error) { - req, err := c.preparerForUpdate(ctx, id, input, options) - if err != nil { - err = autorest.NewErrorWithError(err, "apirelease.ApiReleaseClient", "Update", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apirelease.ApiReleaseClient", "Update", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apirelease.ApiReleaseClient", "Update", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForUpdate prepares the Update request. -func (c ApiReleaseClient) preparerForUpdate(ctx context.Context, id ReleaseId, input ApiReleaseContract, options UpdateOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPatch(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - 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 ApiReleaseClient) 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/apimanagement/2021-08-01/apirevision/client.go b/resource-manager/apimanagement/2021-08-01/apirevision/client.go index 4f27298efa9..3efc0f7c9fe 100644 --- a/resource-manager/apimanagement/2021-08-01/apirevision/client.go +++ b/resource-manager/apimanagement/2021-08-01/apirevision/client.go @@ -1,18 +1,26 @@ package apirevision -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 ApiRevisionClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewApiRevisionClientWithBaseURI(endpoint string) ApiRevisionClient { - return ApiRevisionClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewApiRevisionClientWithBaseURI(api environments.Api) (*ApiRevisionClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "apirevision", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ApiRevisionClient: %+v", err) } + + return &ApiRevisionClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2021-08-01/apirevision/method_listbyservice.go b/resource-manager/apimanagement/2021-08-01/apirevision/method_listbyservice.go new file mode 100644 index 00000000000..ddc821890de --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/apirevision/method_listbyservice.go @@ -0,0 +1,125 @@ +package apirevision + +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 ListByServiceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ApiRevisionContract +} + +type ListByServiceCompleteResult struct { + Items []ApiRevisionContract +} + +type ListByServiceOperationOptions struct { + Filter *string + Skip *int64 + Top *int64 +} + +func DefaultListByServiceOperationOptions() ListByServiceOperationOptions { + return ListByServiceOperationOptions{} +} + +func (o ListByServiceOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListByServiceOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListByServiceOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.Skip != nil { + out.Append("$skip", fmt.Sprintf("%v", *o.Skip)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +// ListByService ... +func (c ApiRevisionClient) ListByService(ctx context.Context, id ApiId, options ListByServiceOperationOptions) (result ListByServiceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/revisions", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ApiRevisionContract `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByServiceComplete retrieves all the results into a single object +func (c ApiRevisionClient) ListByServiceComplete(ctx context.Context, id ApiId, options ListByServiceOperationOptions) (ListByServiceCompleteResult, error) { + return c.ListByServiceCompleteMatchingPredicate(ctx, id, options, ApiRevisionContractOperationPredicate{}) +} + +// ListByServiceCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ApiRevisionClient) ListByServiceCompleteMatchingPredicate(ctx context.Context, id ApiId, options ListByServiceOperationOptions, predicate ApiRevisionContractOperationPredicate) (result ListByServiceCompleteResult, err error) { + items := make([]ApiRevisionContract, 0) + + resp, err := c.ListByService(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByServiceCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/apimanagement/2021-08-01/apirevision/method_listbyservice_autorest.go b/resource-manager/apimanagement/2021-08-01/apirevision/method_listbyservice_autorest.go deleted file mode 100644 index 02f5fa345c9..00000000000 --- a/resource-manager/apimanagement/2021-08-01/apirevision/method_listbyservice_autorest.go +++ /dev/null @@ -1,225 +0,0 @@ -package apirevision - -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 ListByServiceOperationResponse struct { - HttpResponse *http.Response - Model *[]ApiRevisionContract - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListByServiceOperationResponse, error) -} - -type ListByServiceCompleteResult struct { - Items []ApiRevisionContract -} - -func (r ListByServiceOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListByServiceOperationResponse) LoadMore(ctx context.Context) (resp ListByServiceOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -type ListByServiceOperationOptions struct { - Filter *string - Skip *int64 - Top *int64 -} - -func DefaultListByServiceOperationOptions() ListByServiceOperationOptions { - return ListByServiceOperationOptions{} -} - -func (o ListByServiceOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o ListByServiceOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Filter != nil { - out["$filter"] = *o.Filter - } - - if o.Skip != nil { - out["$skip"] = *o.Skip - } - - if o.Top != nil { - out["$top"] = *o.Top - } - - return out -} - -// ListByService ... -func (c ApiRevisionClient) ListByService(ctx context.Context, id ApiId, options ListByServiceOperationOptions) (resp ListByServiceOperationResponse, err error) { - req, err := c.preparerForListByService(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "apirevision.ApiRevisionClient", "ListByService", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apirevision.ApiRevisionClient", "ListByService", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListByService(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apirevision.ApiRevisionClient", "ListByService", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListByService prepares the ListByService request. -func (c ApiRevisionClient) preparerForListByService(ctx context.Context, id ApiId, options ListByServiceOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/revisions", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListByServiceWithNextLink prepares the ListByService request with the given nextLink token. -func (c ApiRevisionClient) preparerForListByServiceWithNextLink(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)) -} - -// responderForListByService handles the response to the ListByService request. The method always -// closes the http.Response Body. -func (c ApiRevisionClient) responderForListByService(resp *http.Response) (result ListByServiceOperationResponse, err error) { - type page struct { - Values []ApiRevisionContract `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 ListByServiceOperationResponse, err error) { - req, err := c.preparerForListByServiceWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "apirevision.ApiRevisionClient", "ListByService", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apirevision.ApiRevisionClient", "ListByService", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByService(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apirevision.ApiRevisionClient", "ListByService", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListByServiceComplete retrieves all of the results into a single object -func (c ApiRevisionClient) ListByServiceComplete(ctx context.Context, id ApiId, options ListByServiceOperationOptions) (ListByServiceCompleteResult, error) { - return c.ListByServiceCompleteMatchingPredicate(ctx, id, options, ApiRevisionContractOperationPredicate{}) -} - -// ListByServiceCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c ApiRevisionClient) ListByServiceCompleteMatchingPredicate(ctx context.Context, id ApiId, options ListByServiceOperationOptions, predicate ApiRevisionContractOperationPredicate) (resp ListByServiceCompleteResult, err error) { - items := make([]ApiRevisionContract, 0) - - page, err := c.ListByService(ctx, id, options) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListByServiceCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/apimanagement/2021-08-01/apisbytag/client.go b/resource-manager/apimanagement/2021-08-01/apisbytag/client.go index 300fac77149..a2f766f24fe 100644 --- a/resource-manager/apimanagement/2021-08-01/apisbytag/client.go +++ b/resource-manager/apimanagement/2021-08-01/apisbytag/client.go @@ -1,18 +1,26 @@ package apisbytag -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 ApisByTagClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewApisByTagClientWithBaseURI(endpoint string) ApisByTagClient { - return ApisByTagClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewApisByTagClientWithBaseURI(api environments.Api) (*ApisByTagClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "apisbytag", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ApisByTagClient: %+v", err) } + + return &ApisByTagClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2021-08-01/apisbytag/constants.go b/resource-manager/apimanagement/2021-08-01/apisbytag/constants.go index 6f6b4ccc0c1..66e070901d4 100644 --- a/resource-manager/apimanagement/2021-08-01/apisbytag/constants.go +++ b/resource-manager/apimanagement/2021-08-01/apisbytag/constants.go @@ -1,6 +1,10 @@ package apisbytag -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 PossibleValuesForApiType() []string { } } +func (s *ApiType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseApiType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseApiType(input string) (*ApiType, error) { vals := map[string]ApiType{ "graphql": ApiTypeGraphql, @@ -53,6 +70,19 @@ func PossibleValuesForBearerTokenSendingMethods() []string { } } +func (s *BearerTokenSendingMethods) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseBearerTokenSendingMethods(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseBearerTokenSendingMethods(input string) (*BearerTokenSendingMethods, error) { vals := map[string]BearerTokenSendingMethods{ "authorizationheader": BearerTokenSendingMethodsAuthorizationHeader, @@ -81,6 +111,19 @@ func PossibleValuesForProductState() []string { } } +func (s *ProductState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProductState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseProductState(input string) (*ProductState, error) { vals := map[string]ProductState{ "notpublished": ProductStateNotPublished, @@ -113,6 +156,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{ "http": ProtocolHTTP, diff --git a/resource-manager/apimanagement/2021-08-01/apisbytag/method_apilistbytags.go b/resource-manager/apimanagement/2021-08-01/apisbytag/method_apilistbytags.go new file mode 100644 index 00000000000..80debd8f476 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/apisbytag/method_apilistbytags.go @@ -0,0 +1,129 @@ +package apisbytag + +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 ApiListByTagsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]TagResourceContract +} + +type ApiListByTagsCompleteResult struct { + Items []TagResourceContract +} + +type ApiListByTagsOperationOptions struct { + Filter *string + IncludeNotTaggedApis *bool + Skip *int64 + Top *int64 +} + +func DefaultApiListByTagsOperationOptions() ApiListByTagsOperationOptions { + return ApiListByTagsOperationOptions{} +} + +func (o ApiListByTagsOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ApiListByTagsOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ApiListByTagsOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.IncludeNotTaggedApis != nil { + out.Append("includeNotTaggedApis", fmt.Sprintf("%v", *o.IncludeNotTaggedApis)) + } + if o.Skip != nil { + out.Append("$skip", fmt.Sprintf("%v", *o.Skip)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +// ApiListByTags ... +func (c ApisByTagClient) ApiListByTags(ctx context.Context, id ServiceId, options ApiListByTagsOperationOptions) (result ApiListByTagsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/apisByTags", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]TagResourceContract `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ApiListByTagsComplete retrieves all the results into a single object +func (c ApisByTagClient) ApiListByTagsComplete(ctx context.Context, id ServiceId, options ApiListByTagsOperationOptions) (ApiListByTagsCompleteResult, error) { + return c.ApiListByTagsCompleteMatchingPredicate(ctx, id, options, TagResourceContractOperationPredicate{}) +} + +// ApiListByTagsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ApisByTagClient) ApiListByTagsCompleteMatchingPredicate(ctx context.Context, id ServiceId, options ApiListByTagsOperationOptions, predicate TagResourceContractOperationPredicate) (result ApiListByTagsCompleteResult, err error) { + items := make([]TagResourceContract, 0) + + resp, err := c.ApiListByTags(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ApiListByTagsCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/apimanagement/2021-08-01/apisbytag/method_apilistbytags_autorest.go b/resource-manager/apimanagement/2021-08-01/apisbytag/method_apilistbytags_autorest.go deleted file mode 100644 index 5cb4c9a2e49..00000000000 --- a/resource-manager/apimanagement/2021-08-01/apisbytag/method_apilistbytags_autorest.go +++ /dev/null @@ -1,230 +0,0 @@ -package apisbytag - -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 ApiListByTagsOperationResponse struct { - HttpResponse *http.Response - Model *[]TagResourceContract - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ApiListByTagsOperationResponse, error) -} - -type ApiListByTagsCompleteResult struct { - Items []TagResourceContract -} - -func (r ApiListByTagsOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ApiListByTagsOperationResponse) LoadMore(ctx context.Context) (resp ApiListByTagsOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -type ApiListByTagsOperationOptions struct { - Filter *string - IncludeNotTaggedApis *bool - Skip *int64 - Top *int64 -} - -func DefaultApiListByTagsOperationOptions() ApiListByTagsOperationOptions { - return ApiListByTagsOperationOptions{} -} - -func (o ApiListByTagsOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o ApiListByTagsOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Filter != nil { - out["$filter"] = *o.Filter - } - - if o.IncludeNotTaggedApis != nil { - out["includeNotTaggedApis"] = *o.IncludeNotTaggedApis - } - - if o.Skip != nil { - out["$skip"] = *o.Skip - } - - if o.Top != nil { - out["$top"] = *o.Top - } - - return out -} - -// ApiListByTags ... -func (c ApisByTagClient) ApiListByTags(ctx context.Context, id ServiceId, options ApiListByTagsOperationOptions) (resp ApiListByTagsOperationResponse, err error) { - req, err := c.preparerForApiListByTags(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "apisbytag.ApisByTagClient", "ApiListByTags", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apisbytag.ApisByTagClient", "ApiListByTags", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForApiListByTags(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apisbytag.ApisByTagClient", "ApiListByTags", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForApiListByTags prepares the ApiListByTags request. -func (c ApisByTagClient) preparerForApiListByTags(ctx context.Context, id ServiceId, options ApiListByTagsOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/apisByTags", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForApiListByTagsWithNextLink prepares the ApiListByTags request with the given nextLink token. -func (c ApisByTagClient) preparerForApiListByTagsWithNextLink(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)) -} - -// responderForApiListByTags handles the response to the ApiListByTags request. The method always -// closes the http.Response Body. -func (c ApisByTagClient) responderForApiListByTags(resp *http.Response) (result ApiListByTagsOperationResponse, err error) { - type page struct { - Values []TagResourceContract `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 ApiListByTagsOperationResponse, err error) { - req, err := c.preparerForApiListByTagsWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "apisbytag.ApisByTagClient", "ApiListByTags", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apisbytag.ApisByTagClient", "ApiListByTags", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForApiListByTags(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apisbytag.ApisByTagClient", "ApiListByTags", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ApiListByTagsComplete retrieves all of the results into a single object -func (c ApisByTagClient) ApiListByTagsComplete(ctx context.Context, id ServiceId, options ApiListByTagsOperationOptions) (ApiListByTagsCompleteResult, error) { - return c.ApiListByTagsCompleteMatchingPredicate(ctx, id, options, TagResourceContractOperationPredicate{}) -} - -// ApiListByTagsCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c ApisByTagClient) ApiListByTagsCompleteMatchingPredicate(ctx context.Context, id ServiceId, options ApiListByTagsOperationOptions, predicate TagResourceContractOperationPredicate) (resp ApiListByTagsCompleteResult, err error) { - items := make([]TagResourceContract, 0) - - page, err := c.ApiListByTags(ctx, id, options) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ApiListByTagsCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/apimanagement/2021-08-01/apischema/client.go b/resource-manager/apimanagement/2021-08-01/apischema/client.go index 1b7ddf09061..c958a1a817f 100644 --- a/resource-manager/apimanagement/2021-08-01/apischema/client.go +++ b/resource-manager/apimanagement/2021-08-01/apischema/client.go @@ -1,18 +1,26 @@ package apischema -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 ApiSchemaClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewApiSchemaClientWithBaseURI(endpoint string) ApiSchemaClient { - return ApiSchemaClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewApiSchemaClientWithBaseURI(api environments.Api) (*ApiSchemaClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "apischema", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ApiSchemaClient: %+v", err) } + + return &ApiSchemaClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2021-08-01/apischema/method_createorupdate.go b/resource-manager/apimanagement/2021-08-01/apischema/method_createorupdate.go new file mode 100644 index 00000000000..ee50a77ff43 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/apischema/method_createorupdate.go @@ -0,0 +1,103 @@ +package apischema + +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 +} + +type CreateOrUpdateOperationOptions struct { + IfMatch *string +} + +func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { + return CreateOrUpdateOperationOptions{} +} + +func (o CreateOrUpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o CreateOrUpdateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o CreateOrUpdateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// CreateOrUpdate ... +func (c ApiSchemaClient) CreateOrUpdate(ctx context.Context, id ApiSchemaId, input SchemaContract, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + OptionsObject: options, + } + + 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 ApiSchemaClient) CreateOrUpdateThenPoll(ctx context.Context, id ApiSchemaId, input SchemaContract, options CreateOrUpdateOperationOptions) error { + result, err := c.CreateOrUpdate(ctx, id, input, options) + 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/apimanagement/2021-08-01/apischema/method_createorupdate_autorest.go b/resource-manager/apimanagement/2021-08-01/apischema/method_createorupdate_autorest.go deleted file mode 100644 index b66a431a79b..00000000000 --- a/resource-manager/apimanagement/2021-08-01/apischema/method_createorupdate_autorest.go +++ /dev/null @@ -1,108 +0,0 @@ -package apischema - -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 -} - -type CreateOrUpdateOperationOptions struct { - IfMatch *string -} - -func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { - return CreateOrUpdateOperationOptions{} -} - -func (o CreateOrUpdateOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o CreateOrUpdateOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// CreateOrUpdate ... -func (c ApiSchemaClient) CreateOrUpdate(ctx context.Context, id ApiSchemaId, input SchemaContract, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdate(ctx, id, input, options) - if err != nil { - err = autorest.NewErrorWithError(err, "apischema.ApiSchemaClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result, err = c.senderForCreateOrUpdate(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "apischema.ApiSchemaClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed -func (c ApiSchemaClient) CreateOrUpdateThenPoll(ctx context.Context, id ApiSchemaId, input SchemaContract, options CreateOrUpdateOperationOptions) error { - result, err := c.CreateOrUpdate(ctx, id, input, options) - 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 ApiSchemaClient) preparerForCreateOrUpdate(ctx context.Context, id ApiSchemaId, input SchemaContract, options CreateOrUpdateOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - 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 ApiSchemaClient) 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/apimanagement/2021-08-01/apischema/method_delete.go b/resource-manager/apimanagement/2021-08-01/apischema/method_delete.go new file mode 100644 index 00000000000..6fab6914573 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/apischema/method_delete.go @@ -0,0 +1,79 @@ +package apischema + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +type DeleteOperationOptions struct { + Force *bool + IfMatch *string +} + +func DefaultDeleteOperationOptions() DeleteOperationOptions { + return DeleteOperationOptions{} +} + +func (o DeleteOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o DeleteOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o DeleteOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Force != nil { + out.Append("force", fmt.Sprintf("%v", *o.Force)) + } + return &out +} + +// Delete ... +func (c ApiSchemaClient) Delete(ctx context.Context, id ApiSchemaId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2021-08-01/apischema/method_delete_autorest.go b/resource-manager/apimanagement/2021-08-01/apischema/method_delete_autorest.go deleted file mode 100644 index 861123ba5f1..00000000000 --- a/resource-manager/apimanagement/2021-08-01/apischema/method_delete_autorest.go +++ /dev/null @@ -1,100 +0,0 @@ -package apischema - -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 DeleteOperationResponse struct { - HttpResponse *http.Response -} - -type DeleteOperationOptions struct { - Force *bool - IfMatch *string -} - -func DefaultDeleteOperationOptions() DeleteOperationOptions { - return DeleteOperationOptions{} -} - -func (o DeleteOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o DeleteOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Force != nil { - out["force"] = *o.Force - } - - return out -} - -// Delete ... -func (c ApiSchemaClient) Delete(ctx context.Context, id ApiSchemaId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { - req, err := c.preparerForDelete(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "apischema.ApiSchemaClient", "Delete", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apischema.ApiSchemaClient", "Delete", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForDelete(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apischema.ApiSchemaClient", "Delete", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForDelete prepares the Delete request. -func (c ApiSchemaClient) preparerForDelete(ctx context.Context, id ApiSchemaId, options DeleteOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForDelete handles the response to the Delete request. The method always -// closes the http.Response Body. -func (c ApiSchemaClient) responderForDelete(resp *http.Response) (result DeleteOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2021-08-01/apischema/method_get.go b/resource-manager/apimanagement/2021-08-01/apischema/method_get.go new file mode 100644 index 00000000000..544b5401b16 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/apischema/method_get.go @@ -0,0 +1,51 @@ +package apischema + +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 *SchemaContract +} + +// Get ... +func (c ApiSchemaClient) Get(ctx context.Context, id ApiSchemaId) (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/apimanagement/2021-08-01/apischema/method_get_autorest.go b/resource-manager/apimanagement/2021-08-01/apischema/method_get_autorest.go deleted file mode 100644 index a2f6ed627d0..00000000000 --- a/resource-manager/apimanagement/2021-08-01/apischema/method_get_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package apischema - -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 *SchemaContract -} - -// Get ... -func (c ApiSchemaClient) Get(ctx context.Context, id ApiSchemaId) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "apischema.ApiSchemaClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apischema.ApiSchemaClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apischema.ApiSchemaClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c ApiSchemaClient) preparerForGet(ctx context.Context, id ApiSchemaId) (*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 ApiSchemaClient) 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/apimanagement/2021-08-01/apischema/method_getentitytag.go b/resource-manager/apimanagement/2021-08-01/apischema/method_getentitytag.go new file mode 100644 index 00000000000..06aa5ede3ba --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/apischema/method_getentitytag.go @@ -0,0 +1,46 @@ +package apischema + +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 GetEntityTagOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// GetEntityTag ... +func (c ApiSchemaClient) GetEntityTag(ctx context.Context, id ApiSchemaId) (result GetEntityTagOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodHead, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2021-08-01/apischema/method_getentitytag_autorest.go b/resource-manager/apimanagement/2021-08-01/apischema/method_getentitytag_autorest.go deleted file mode 100644 index fc901aa3419..00000000000 --- a/resource-manager/apimanagement/2021-08-01/apischema/method_getentitytag_autorest.go +++ /dev/null @@ -1,66 +0,0 @@ -package apischema - -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 GetEntityTagOperationResponse struct { - HttpResponse *http.Response -} - -// GetEntityTag ... -func (c ApiSchemaClient) GetEntityTag(ctx context.Context, id ApiSchemaId) (result GetEntityTagOperationResponse, err error) { - req, err := c.preparerForGetEntityTag(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "apischema.ApiSchemaClient", "GetEntityTag", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apischema.ApiSchemaClient", "GetEntityTag", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetEntityTag(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apischema.ApiSchemaClient", "GetEntityTag", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetEntityTag prepares the GetEntityTag request. -func (c ApiSchemaClient) preparerForGetEntityTag(ctx context.Context, id ApiSchemaId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsHead(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetEntityTag handles the response to the GetEntityTag request. The method always -// closes the http.Response Body. -func (c ApiSchemaClient) responderForGetEntityTag(resp *http.Response) (result GetEntityTagOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2021-08-01/apischema/method_listbyapi.go b/resource-manager/apimanagement/2021-08-01/apischema/method_listbyapi.go new file mode 100644 index 00000000000..8486736bbe2 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/apischema/method_listbyapi.go @@ -0,0 +1,125 @@ +package apischema + +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 ListByApiOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]SchemaContract +} + +type ListByApiCompleteResult struct { + Items []SchemaContract +} + +type ListByApiOperationOptions struct { + Filter *string + Skip *int64 + Top *int64 +} + +func DefaultListByApiOperationOptions() ListByApiOperationOptions { + return ListByApiOperationOptions{} +} + +func (o ListByApiOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListByApiOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListByApiOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.Skip != nil { + out.Append("$skip", fmt.Sprintf("%v", *o.Skip)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +// ListByApi ... +func (c ApiSchemaClient) ListByApi(ctx context.Context, id ApiId, options ListByApiOperationOptions) (result ListByApiOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/schemas", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]SchemaContract `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByApiComplete retrieves all the results into a single object +func (c ApiSchemaClient) ListByApiComplete(ctx context.Context, id ApiId, options ListByApiOperationOptions) (ListByApiCompleteResult, error) { + return c.ListByApiCompleteMatchingPredicate(ctx, id, options, SchemaContractOperationPredicate{}) +} + +// ListByApiCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ApiSchemaClient) ListByApiCompleteMatchingPredicate(ctx context.Context, id ApiId, options ListByApiOperationOptions, predicate SchemaContractOperationPredicate) (result ListByApiCompleteResult, err error) { + items := make([]SchemaContract, 0) + + resp, err := c.ListByApi(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByApiCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/apimanagement/2021-08-01/apischema/method_listbyapi_autorest.go b/resource-manager/apimanagement/2021-08-01/apischema/method_listbyapi_autorest.go deleted file mode 100644 index c29a0ea33a5..00000000000 --- a/resource-manager/apimanagement/2021-08-01/apischema/method_listbyapi_autorest.go +++ /dev/null @@ -1,225 +0,0 @@ -package apischema - -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 ListByApiOperationResponse struct { - HttpResponse *http.Response - Model *[]SchemaContract - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListByApiOperationResponse, error) -} - -type ListByApiCompleteResult struct { - Items []SchemaContract -} - -func (r ListByApiOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListByApiOperationResponse) LoadMore(ctx context.Context) (resp ListByApiOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -type ListByApiOperationOptions struct { - Filter *string - Skip *int64 - Top *int64 -} - -func DefaultListByApiOperationOptions() ListByApiOperationOptions { - return ListByApiOperationOptions{} -} - -func (o ListByApiOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o ListByApiOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Filter != nil { - out["$filter"] = *o.Filter - } - - if o.Skip != nil { - out["$skip"] = *o.Skip - } - - if o.Top != nil { - out["$top"] = *o.Top - } - - return out -} - -// ListByApi ... -func (c ApiSchemaClient) ListByApi(ctx context.Context, id ApiId, options ListByApiOperationOptions) (resp ListByApiOperationResponse, err error) { - req, err := c.preparerForListByApi(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "apischema.ApiSchemaClient", "ListByApi", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apischema.ApiSchemaClient", "ListByApi", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListByApi(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apischema.ApiSchemaClient", "ListByApi", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListByApi prepares the ListByApi request. -func (c ApiSchemaClient) preparerForListByApi(ctx context.Context, id ApiId, options ListByApiOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/schemas", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListByApiWithNextLink prepares the ListByApi request with the given nextLink token. -func (c ApiSchemaClient) preparerForListByApiWithNextLink(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)) -} - -// responderForListByApi handles the response to the ListByApi request. The method always -// closes the http.Response Body. -func (c ApiSchemaClient) responderForListByApi(resp *http.Response) (result ListByApiOperationResponse, err error) { - type page struct { - Values []SchemaContract `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 ListByApiOperationResponse, err error) { - req, err := c.preparerForListByApiWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "apischema.ApiSchemaClient", "ListByApi", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apischema.ApiSchemaClient", "ListByApi", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByApi(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apischema.ApiSchemaClient", "ListByApi", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListByApiComplete retrieves all of the results into a single object -func (c ApiSchemaClient) ListByApiComplete(ctx context.Context, id ApiId, options ListByApiOperationOptions) (ListByApiCompleteResult, error) { - return c.ListByApiCompleteMatchingPredicate(ctx, id, options, SchemaContractOperationPredicate{}) -} - -// ListByApiCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c ApiSchemaClient) ListByApiCompleteMatchingPredicate(ctx context.Context, id ApiId, options ListByApiOperationOptions, predicate SchemaContractOperationPredicate) (resp ListByApiCompleteResult, err error) { - items := make([]SchemaContract, 0) - - page, err := c.ListByApi(ctx, id, options) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListByApiCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/apimanagement/2021-08-01/apitag/client.go b/resource-manager/apimanagement/2021-08-01/apitag/client.go index 6224a081278..3bf88479c6c 100644 --- a/resource-manager/apimanagement/2021-08-01/apitag/client.go +++ b/resource-manager/apimanagement/2021-08-01/apitag/client.go @@ -1,18 +1,26 @@ package apitag -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 ApiTagClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewApiTagClientWithBaseURI(endpoint string) ApiTagClient { - return ApiTagClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewApiTagClientWithBaseURI(api environments.Api) (*ApiTagClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "apitag", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ApiTagClient: %+v", err) } + + return &ApiTagClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2021-08-01/apitag/method_tagassigntoapi.go b/resource-manager/apimanagement/2021-08-01/apitag/method_tagassigntoapi.go new file mode 100644 index 00000000000..96c964a74bd --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/apitag/method_tagassigntoapi.go @@ -0,0 +1,52 @@ +package apitag + +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 TagAssignToApiOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *TagContract +} + +// TagAssignToApi ... +func (c ApiTagClient) TagAssignToApi(ctx context.Context, id ApiTagId) (result TagAssignToApiOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + 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/apimanagement/2021-08-01/apitag/method_tagassigntoapi_autorest.go b/resource-manager/apimanagement/2021-08-01/apitag/method_tagassigntoapi_autorest.go deleted file mode 100644 index e08a016a227..00000000000 --- a/resource-manager/apimanagement/2021-08-01/apitag/method_tagassigntoapi_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package apitag - -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 TagAssignToApiOperationResponse struct { - HttpResponse *http.Response - Model *TagContract -} - -// TagAssignToApi ... -func (c ApiTagClient) TagAssignToApi(ctx context.Context, id ApiTagId) (result TagAssignToApiOperationResponse, err error) { - req, err := c.preparerForTagAssignToApi(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "apitag.ApiTagClient", "TagAssignToApi", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apitag.ApiTagClient", "TagAssignToApi", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForTagAssignToApi(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apitag.ApiTagClient", "TagAssignToApi", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForTagAssignToApi prepares the TagAssignToApi request. -func (c ApiTagClient) preparerForTagAssignToApi(ctx context.Context, id ApiTagId) (*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.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForTagAssignToApi handles the response to the TagAssignToApi request. The method always -// closes the http.Response Body. -func (c ApiTagClient) responderForTagAssignToApi(resp *http.Response) (result TagAssignToApiOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2021-08-01/apitag/method_tagdetachfromapi.go b/resource-manager/apimanagement/2021-08-01/apitag/method_tagdetachfromapi.go new file mode 100644 index 00000000000..ad546cf7c3c --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/apitag/method_tagdetachfromapi.go @@ -0,0 +1,47 @@ +package apitag + +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 TagDetachFromApiOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// TagDetachFromApi ... +func (c ApiTagClient) TagDetachFromApi(ctx context.Context, id ApiTagId) (result TagDetachFromApiOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2021-08-01/apitag/method_tagdetachfromapi_autorest.go b/resource-manager/apimanagement/2021-08-01/apitag/method_tagdetachfromapi_autorest.go deleted file mode 100644 index e7ecb70287d..00000000000 --- a/resource-manager/apimanagement/2021-08-01/apitag/method_tagdetachfromapi_autorest.go +++ /dev/null @@ -1,66 +0,0 @@ -package apitag - -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 TagDetachFromApiOperationResponse struct { - HttpResponse *http.Response -} - -// TagDetachFromApi ... -func (c ApiTagClient) TagDetachFromApi(ctx context.Context, id ApiTagId) (result TagDetachFromApiOperationResponse, err error) { - req, err := c.preparerForTagDetachFromApi(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "apitag.ApiTagClient", "TagDetachFromApi", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apitag.ApiTagClient", "TagDetachFromApi", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForTagDetachFromApi(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apitag.ApiTagClient", "TagDetachFromApi", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForTagDetachFromApi prepares the TagDetachFromApi request. -func (c ApiTagClient) preparerForTagDetachFromApi(ctx context.Context, id ApiTagId) (*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)) -} - -// responderForTagDetachFromApi handles the response to the TagDetachFromApi request. The method always -// closes the http.Response Body. -func (c ApiTagClient) responderForTagDetachFromApi(resp *http.Response) (result TagDetachFromApiOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2021-08-01/apitag/method_taggetbyapi.go b/resource-manager/apimanagement/2021-08-01/apitag/method_taggetbyapi.go new file mode 100644 index 00000000000..97876d1178c --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/apitag/method_taggetbyapi.go @@ -0,0 +1,51 @@ +package apitag + +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 TagGetByApiOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *TagContract +} + +// TagGetByApi ... +func (c ApiTagClient) TagGetByApi(ctx context.Context, id ApiTagId) (result TagGetByApiOperationResponse, 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/apimanagement/2021-08-01/apitag/method_taggetbyapi_autorest.go b/resource-manager/apimanagement/2021-08-01/apitag/method_taggetbyapi_autorest.go deleted file mode 100644 index cdc7b57c932..00000000000 --- a/resource-manager/apimanagement/2021-08-01/apitag/method_taggetbyapi_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package apitag - -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 TagGetByApiOperationResponse struct { - HttpResponse *http.Response - Model *TagContract -} - -// TagGetByApi ... -func (c ApiTagClient) TagGetByApi(ctx context.Context, id ApiTagId) (result TagGetByApiOperationResponse, err error) { - req, err := c.preparerForTagGetByApi(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "apitag.ApiTagClient", "TagGetByApi", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apitag.ApiTagClient", "TagGetByApi", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForTagGetByApi(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apitag.ApiTagClient", "TagGetByApi", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForTagGetByApi prepares the TagGetByApi request. -func (c ApiTagClient) preparerForTagGetByApi(ctx context.Context, id ApiTagId) (*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)) -} - -// responderForTagGetByApi handles the response to the TagGetByApi request. The method always -// closes the http.Response Body. -func (c ApiTagClient) responderForTagGetByApi(resp *http.Response) (result TagGetByApiOperationResponse, 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/apimanagement/2021-08-01/apitag/method_taggetentitystatebyapi.go b/resource-manager/apimanagement/2021-08-01/apitag/method_taggetentitystatebyapi.go new file mode 100644 index 00000000000..eb833e96b2a --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/apitag/method_taggetentitystatebyapi.go @@ -0,0 +1,46 @@ +package apitag + +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 TagGetEntityStateByApiOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// TagGetEntityStateByApi ... +func (c ApiTagClient) TagGetEntityStateByApi(ctx context.Context, id ApiTagId) (result TagGetEntityStateByApiOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodHead, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2021-08-01/apitag/method_taggetentitystatebyapi_autorest.go b/resource-manager/apimanagement/2021-08-01/apitag/method_taggetentitystatebyapi_autorest.go deleted file mode 100644 index f0c60a63c86..00000000000 --- a/resource-manager/apimanagement/2021-08-01/apitag/method_taggetentitystatebyapi_autorest.go +++ /dev/null @@ -1,66 +0,0 @@ -package apitag - -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 TagGetEntityStateByApiOperationResponse struct { - HttpResponse *http.Response -} - -// TagGetEntityStateByApi ... -func (c ApiTagClient) TagGetEntityStateByApi(ctx context.Context, id ApiTagId) (result TagGetEntityStateByApiOperationResponse, err error) { - req, err := c.preparerForTagGetEntityStateByApi(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "apitag.ApiTagClient", "TagGetEntityStateByApi", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apitag.ApiTagClient", "TagGetEntityStateByApi", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForTagGetEntityStateByApi(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apitag.ApiTagClient", "TagGetEntityStateByApi", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForTagGetEntityStateByApi prepares the TagGetEntityStateByApi request. -func (c ApiTagClient) preparerForTagGetEntityStateByApi(ctx context.Context, id ApiTagId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsHead(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForTagGetEntityStateByApi handles the response to the TagGetEntityStateByApi request. The method always -// closes the http.Response Body. -func (c ApiTagClient) responderForTagGetEntityStateByApi(resp *http.Response) (result TagGetEntityStateByApiOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2021-08-01/apitag/method_taglistbyapi.go b/resource-manager/apimanagement/2021-08-01/apitag/method_taglistbyapi.go new file mode 100644 index 00000000000..9ab4d2bb22c --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/apitag/method_taglistbyapi.go @@ -0,0 +1,125 @@ +package apitag + +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 TagListByApiOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]TagContract +} + +type TagListByApiCompleteResult struct { + Items []TagContract +} + +type TagListByApiOperationOptions struct { + Filter *string + Skip *int64 + Top *int64 +} + +func DefaultTagListByApiOperationOptions() TagListByApiOperationOptions { + return TagListByApiOperationOptions{} +} + +func (o TagListByApiOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o TagListByApiOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o TagListByApiOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.Skip != nil { + out.Append("$skip", fmt.Sprintf("%v", *o.Skip)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +// TagListByApi ... +func (c ApiTagClient) TagListByApi(ctx context.Context, id ApiId, options TagListByApiOperationOptions) (result TagListByApiOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/tags", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]TagContract `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// TagListByApiComplete retrieves all the results into a single object +func (c ApiTagClient) TagListByApiComplete(ctx context.Context, id ApiId, options TagListByApiOperationOptions) (TagListByApiCompleteResult, error) { + return c.TagListByApiCompleteMatchingPredicate(ctx, id, options, TagContractOperationPredicate{}) +} + +// TagListByApiCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ApiTagClient) TagListByApiCompleteMatchingPredicate(ctx context.Context, id ApiId, options TagListByApiOperationOptions, predicate TagContractOperationPredicate) (result TagListByApiCompleteResult, err error) { + items := make([]TagContract, 0) + + resp, err := c.TagListByApi(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = TagListByApiCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/apimanagement/2021-08-01/apitag/method_taglistbyapi_autorest.go b/resource-manager/apimanagement/2021-08-01/apitag/method_taglistbyapi_autorest.go deleted file mode 100644 index 750fb144087..00000000000 --- a/resource-manager/apimanagement/2021-08-01/apitag/method_taglistbyapi_autorest.go +++ /dev/null @@ -1,225 +0,0 @@ -package apitag - -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 TagListByApiOperationResponse struct { - HttpResponse *http.Response - Model *[]TagContract - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (TagListByApiOperationResponse, error) -} - -type TagListByApiCompleteResult struct { - Items []TagContract -} - -func (r TagListByApiOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r TagListByApiOperationResponse) LoadMore(ctx context.Context) (resp TagListByApiOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -type TagListByApiOperationOptions struct { - Filter *string - Skip *int64 - Top *int64 -} - -func DefaultTagListByApiOperationOptions() TagListByApiOperationOptions { - return TagListByApiOperationOptions{} -} - -func (o TagListByApiOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o TagListByApiOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Filter != nil { - out["$filter"] = *o.Filter - } - - if o.Skip != nil { - out["$skip"] = *o.Skip - } - - if o.Top != nil { - out["$top"] = *o.Top - } - - return out -} - -// TagListByApi ... -func (c ApiTagClient) TagListByApi(ctx context.Context, id ApiId, options TagListByApiOperationOptions) (resp TagListByApiOperationResponse, err error) { - req, err := c.preparerForTagListByApi(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "apitag.ApiTagClient", "TagListByApi", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apitag.ApiTagClient", "TagListByApi", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForTagListByApi(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apitag.ApiTagClient", "TagListByApi", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForTagListByApi prepares the TagListByApi request. -func (c ApiTagClient) preparerForTagListByApi(ctx context.Context, id ApiId, options TagListByApiOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/tags", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForTagListByApiWithNextLink prepares the TagListByApi request with the given nextLink token. -func (c ApiTagClient) preparerForTagListByApiWithNextLink(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)) -} - -// responderForTagListByApi handles the response to the TagListByApi request. The method always -// closes the http.Response Body. -func (c ApiTagClient) responderForTagListByApi(resp *http.Response) (result TagListByApiOperationResponse, err error) { - type page struct { - Values []TagContract `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 TagListByApiOperationResponse, err error) { - req, err := c.preparerForTagListByApiWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "apitag.ApiTagClient", "TagListByApi", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apitag.ApiTagClient", "TagListByApi", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForTagListByApi(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apitag.ApiTagClient", "TagListByApi", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// TagListByApiComplete retrieves all of the results into a single object -func (c ApiTagClient) TagListByApiComplete(ctx context.Context, id ApiId, options TagListByApiOperationOptions) (TagListByApiCompleteResult, error) { - return c.TagListByApiCompleteMatchingPredicate(ctx, id, options, TagContractOperationPredicate{}) -} - -// TagListByApiCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c ApiTagClient) TagListByApiCompleteMatchingPredicate(ctx context.Context, id ApiId, options TagListByApiOperationOptions, predicate TagContractOperationPredicate) (resp TagListByApiCompleteResult, err error) { - items := make([]TagContract, 0) - - page, err := c.TagListByApi(ctx, id, options) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := TagListByApiCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/apimanagement/2021-08-01/apitagdescription/client.go b/resource-manager/apimanagement/2021-08-01/apitagdescription/client.go index e11c12678bb..dc91413d9ab 100644 --- a/resource-manager/apimanagement/2021-08-01/apitagdescription/client.go +++ b/resource-manager/apimanagement/2021-08-01/apitagdescription/client.go @@ -1,18 +1,26 @@ package apitagdescription -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 ApiTagDescriptionClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewApiTagDescriptionClientWithBaseURI(endpoint string) ApiTagDescriptionClient { - return ApiTagDescriptionClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewApiTagDescriptionClientWithBaseURI(api environments.Api) (*ApiTagDescriptionClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "apitagdescription", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ApiTagDescriptionClient: %+v", err) } + + return &ApiTagDescriptionClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2021-08-01/apitagdescription/method_createorupdate.go b/resource-manager/apimanagement/2021-08-01/apitagdescription/method_createorupdate.go new file mode 100644 index 00000000000..08f839f5fe5 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/apitagdescription/method_createorupdate.go @@ -0,0 +1,85 @@ +package apitagdescription + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *TagDescriptionContract +} + +type CreateOrUpdateOperationOptions struct { + IfMatch *string +} + +func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { + return CreateOrUpdateOperationOptions{} +} + +func (o CreateOrUpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o CreateOrUpdateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o CreateOrUpdateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// CreateOrUpdate ... +func (c ApiTagDescriptionClient) CreateOrUpdate(ctx context.Context, id TagDescriptionId, input TagDescriptionCreateParameters, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + OptionsObject: options, + } + + 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/apimanagement/2021-08-01/apitagdescription/method_createorupdate_autorest.go b/resource-manager/apimanagement/2021-08-01/apitagdescription/method_createorupdate_autorest.go deleted file mode 100644 index 876ae7520b3..00000000000 --- a/resource-manager/apimanagement/2021-08-01/apitagdescription/method_createorupdate_autorest.go +++ /dev/null @@ -1,98 +0,0 @@ -package apitagdescription - -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 *TagDescriptionContract -} - -type CreateOrUpdateOperationOptions struct { - IfMatch *string -} - -func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { - return CreateOrUpdateOperationOptions{} -} - -func (o CreateOrUpdateOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o CreateOrUpdateOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// CreateOrUpdate ... -func (c ApiTagDescriptionClient) CreateOrUpdate(ctx context.Context, id TagDescriptionId, input TagDescriptionCreateParameters, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdate(ctx, id, input, options) - if err != nil { - err = autorest.NewErrorWithError(err, "apitagdescription.ApiTagDescriptionClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apitagdescription.ApiTagDescriptionClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCreateOrUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apitagdescription.ApiTagDescriptionClient", "CreateOrUpdate", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCreateOrUpdate prepares the CreateOrUpdate request. -func (c ApiTagDescriptionClient) preparerForCreateOrUpdate(ctx context.Context, id TagDescriptionId, input TagDescriptionCreateParameters, options CreateOrUpdateOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - 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 ApiTagDescriptionClient) responderForCreateOrUpdate(resp *http.Response) (result CreateOrUpdateOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2021-08-01/apitagdescription/method_delete.go b/resource-manager/apimanagement/2021-08-01/apitagdescription/method_delete.go new file mode 100644 index 00000000000..bc50e1495af --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/apitagdescription/method_delete.go @@ -0,0 +1,76 @@ +package apitagdescription + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +type DeleteOperationOptions struct { + IfMatch *string +} + +func DefaultDeleteOperationOptions() DeleteOperationOptions { + return DeleteOperationOptions{} +} + +func (o DeleteOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o DeleteOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o DeleteOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// Delete ... +func (c ApiTagDescriptionClient) Delete(ctx context.Context, id TagDescriptionId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2021-08-01/apitagdescription/method_delete_autorest.go b/resource-manager/apimanagement/2021-08-01/apitagdescription/method_delete_autorest.go deleted file mode 100644 index a383875ca12..00000000000 --- a/resource-manager/apimanagement/2021-08-01/apitagdescription/method_delete_autorest.go +++ /dev/null @@ -1,95 +0,0 @@ -package apitagdescription - -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 DeleteOperationResponse struct { - HttpResponse *http.Response -} - -type DeleteOperationOptions struct { - IfMatch *string -} - -func DefaultDeleteOperationOptions() DeleteOperationOptions { - return DeleteOperationOptions{} -} - -func (o DeleteOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o DeleteOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// Delete ... -func (c ApiTagDescriptionClient) Delete(ctx context.Context, id TagDescriptionId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { - req, err := c.preparerForDelete(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "apitagdescription.ApiTagDescriptionClient", "Delete", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apitagdescription.ApiTagDescriptionClient", "Delete", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForDelete(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apitagdescription.ApiTagDescriptionClient", "Delete", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForDelete prepares the Delete request. -func (c ApiTagDescriptionClient) preparerForDelete(ctx context.Context, id TagDescriptionId, options DeleteOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForDelete handles the response to the Delete request. The method always -// closes the http.Response Body. -func (c ApiTagDescriptionClient) responderForDelete(resp *http.Response) (result DeleteOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2021-08-01/apitagdescription/method_get.go b/resource-manager/apimanagement/2021-08-01/apitagdescription/method_get.go new file mode 100644 index 00000000000..b4eb50d639b --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/apitagdescription/method_get.go @@ -0,0 +1,51 @@ +package apitagdescription + +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 *TagDescriptionContract +} + +// Get ... +func (c ApiTagDescriptionClient) Get(ctx context.Context, id TagDescriptionId) (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/apimanagement/2021-08-01/apitagdescription/method_get_autorest.go b/resource-manager/apimanagement/2021-08-01/apitagdescription/method_get_autorest.go deleted file mode 100644 index 062aee3683f..00000000000 --- a/resource-manager/apimanagement/2021-08-01/apitagdescription/method_get_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package apitagdescription - -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 *TagDescriptionContract -} - -// Get ... -func (c ApiTagDescriptionClient) Get(ctx context.Context, id TagDescriptionId) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "apitagdescription.ApiTagDescriptionClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apitagdescription.ApiTagDescriptionClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apitagdescription.ApiTagDescriptionClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c ApiTagDescriptionClient) preparerForGet(ctx context.Context, id TagDescriptionId) (*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 ApiTagDescriptionClient) 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/apimanagement/2021-08-01/apitagdescription/method_getentitytag.go b/resource-manager/apimanagement/2021-08-01/apitagdescription/method_getentitytag.go new file mode 100644 index 00000000000..1db8e6e13d4 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/apitagdescription/method_getentitytag.go @@ -0,0 +1,46 @@ +package apitagdescription + +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 GetEntityTagOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// GetEntityTag ... +func (c ApiTagDescriptionClient) GetEntityTag(ctx context.Context, id TagDescriptionId) (result GetEntityTagOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodHead, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2021-08-01/apitagdescription/method_getentitytag_autorest.go b/resource-manager/apimanagement/2021-08-01/apitagdescription/method_getentitytag_autorest.go deleted file mode 100644 index f75e60f2cdd..00000000000 --- a/resource-manager/apimanagement/2021-08-01/apitagdescription/method_getentitytag_autorest.go +++ /dev/null @@ -1,66 +0,0 @@ -package apitagdescription - -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 GetEntityTagOperationResponse struct { - HttpResponse *http.Response -} - -// GetEntityTag ... -func (c ApiTagDescriptionClient) GetEntityTag(ctx context.Context, id TagDescriptionId) (result GetEntityTagOperationResponse, err error) { - req, err := c.preparerForGetEntityTag(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "apitagdescription.ApiTagDescriptionClient", "GetEntityTag", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apitagdescription.ApiTagDescriptionClient", "GetEntityTag", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetEntityTag(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apitagdescription.ApiTagDescriptionClient", "GetEntityTag", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetEntityTag prepares the GetEntityTag request. -func (c ApiTagDescriptionClient) preparerForGetEntityTag(ctx context.Context, id TagDescriptionId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsHead(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetEntityTag handles the response to the GetEntityTag request. The method always -// closes the http.Response Body. -func (c ApiTagDescriptionClient) responderForGetEntityTag(resp *http.Response) (result GetEntityTagOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2021-08-01/apitagdescription/method_listbyservice.go b/resource-manager/apimanagement/2021-08-01/apitagdescription/method_listbyservice.go new file mode 100644 index 00000000000..ccc6ebbef03 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/apitagdescription/method_listbyservice.go @@ -0,0 +1,125 @@ +package apitagdescription + +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 ListByServiceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]TagDescriptionContract +} + +type ListByServiceCompleteResult struct { + Items []TagDescriptionContract +} + +type ListByServiceOperationOptions struct { + Filter *string + Skip *int64 + Top *int64 +} + +func DefaultListByServiceOperationOptions() ListByServiceOperationOptions { + return ListByServiceOperationOptions{} +} + +func (o ListByServiceOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListByServiceOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListByServiceOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.Skip != nil { + out.Append("$skip", fmt.Sprintf("%v", *o.Skip)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +// ListByService ... +func (c ApiTagDescriptionClient) ListByService(ctx context.Context, id ApiId, options ListByServiceOperationOptions) (result ListByServiceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/tagDescriptions", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]TagDescriptionContract `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByServiceComplete retrieves all the results into a single object +func (c ApiTagDescriptionClient) ListByServiceComplete(ctx context.Context, id ApiId, options ListByServiceOperationOptions) (ListByServiceCompleteResult, error) { + return c.ListByServiceCompleteMatchingPredicate(ctx, id, options, TagDescriptionContractOperationPredicate{}) +} + +// ListByServiceCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ApiTagDescriptionClient) ListByServiceCompleteMatchingPredicate(ctx context.Context, id ApiId, options ListByServiceOperationOptions, predicate TagDescriptionContractOperationPredicate) (result ListByServiceCompleteResult, err error) { + items := make([]TagDescriptionContract, 0) + + resp, err := c.ListByService(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByServiceCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/apimanagement/2021-08-01/apitagdescription/method_listbyservice_autorest.go b/resource-manager/apimanagement/2021-08-01/apitagdescription/method_listbyservice_autorest.go deleted file mode 100644 index d6970e826db..00000000000 --- a/resource-manager/apimanagement/2021-08-01/apitagdescription/method_listbyservice_autorest.go +++ /dev/null @@ -1,225 +0,0 @@ -package apitagdescription - -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 ListByServiceOperationResponse struct { - HttpResponse *http.Response - Model *[]TagDescriptionContract - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListByServiceOperationResponse, error) -} - -type ListByServiceCompleteResult struct { - Items []TagDescriptionContract -} - -func (r ListByServiceOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListByServiceOperationResponse) LoadMore(ctx context.Context) (resp ListByServiceOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -type ListByServiceOperationOptions struct { - Filter *string - Skip *int64 - Top *int64 -} - -func DefaultListByServiceOperationOptions() ListByServiceOperationOptions { - return ListByServiceOperationOptions{} -} - -func (o ListByServiceOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o ListByServiceOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Filter != nil { - out["$filter"] = *o.Filter - } - - if o.Skip != nil { - out["$skip"] = *o.Skip - } - - if o.Top != nil { - out["$top"] = *o.Top - } - - return out -} - -// ListByService ... -func (c ApiTagDescriptionClient) ListByService(ctx context.Context, id ApiId, options ListByServiceOperationOptions) (resp ListByServiceOperationResponse, err error) { - req, err := c.preparerForListByService(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "apitagdescription.ApiTagDescriptionClient", "ListByService", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apitagdescription.ApiTagDescriptionClient", "ListByService", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListByService(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apitagdescription.ApiTagDescriptionClient", "ListByService", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListByService prepares the ListByService request. -func (c ApiTagDescriptionClient) preparerForListByService(ctx context.Context, id ApiId, options ListByServiceOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/tagDescriptions", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListByServiceWithNextLink prepares the ListByService request with the given nextLink token. -func (c ApiTagDescriptionClient) preparerForListByServiceWithNextLink(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)) -} - -// responderForListByService handles the response to the ListByService request. The method always -// closes the http.Response Body. -func (c ApiTagDescriptionClient) responderForListByService(resp *http.Response) (result ListByServiceOperationResponse, err error) { - type page struct { - Values []TagDescriptionContract `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 ListByServiceOperationResponse, err error) { - req, err := c.preparerForListByServiceWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "apitagdescription.ApiTagDescriptionClient", "ListByService", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apitagdescription.ApiTagDescriptionClient", "ListByService", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByService(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apitagdescription.ApiTagDescriptionClient", "ListByService", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListByServiceComplete retrieves all of the results into a single object -func (c ApiTagDescriptionClient) ListByServiceComplete(ctx context.Context, id ApiId, options ListByServiceOperationOptions) (ListByServiceCompleteResult, error) { - return c.ListByServiceCompleteMatchingPredicate(ctx, id, options, TagDescriptionContractOperationPredicate{}) -} - -// ListByServiceCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c ApiTagDescriptionClient) ListByServiceCompleteMatchingPredicate(ctx context.Context, id ApiId, options ListByServiceOperationOptions, predicate TagDescriptionContractOperationPredicate) (resp ListByServiceCompleteResult, err error) { - items := make([]TagDescriptionContract, 0) - - page, err := c.ListByService(ctx, id, options) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListByServiceCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/apimanagement/2021-08-01/apiversionset/client.go b/resource-manager/apimanagement/2021-08-01/apiversionset/client.go index 7fbe4fc8a0f..6be65936dfb 100644 --- a/resource-manager/apimanagement/2021-08-01/apiversionset/client.go +++ b/resource-manager/apimanagement/2021-08-01/apiversionset/client.go @@ -1,18 +1,26 @@ package apiversionset -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 ApiVersionSetClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewApiVersionSetClientWithBaseURI(endpoint string) ApiVersionSetClient { - return ApiVersionSetClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewApiVersionSetClientWithBaseURI(api environments.Api) (*ApiVersionSetClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "apiversionset", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ApiVersionSetClient: %+v", err) } + + return &ApiVersionSetClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2021-08-01/apiversionset/constants.go b/resource-manager/apimanagement/2021-08-01/apiversionset/constants.go index c13d5055144..4fb4d169fff 100644 --- a/resource-manager/apimanagement/2021-08-01/apiversionset/constants.go +++ b/resource-manager/apimanagement/2021-08-01/apiversionset/constants.go @@ -1,6 +1,10 @@ package apiversionset -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 PossibleValuesForVersioningScheme() []string { } } +func (s *VersioningScheme) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseVersioningScheme(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseVersioningScheme(input string) (*VersioningScheme, error) { vals := map[string]VersioningScheme{ "header": VersioningSchemeHeader, diff --git a/resource-manager/apimanagement/2021-08-01/apiversionset/method_createorupdate.go b/resource-manager/apimanagement/2021-08-01/apiversionset/method_createorupdate.go new file mode 100644 index 00000000000..69f9d46f502 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/apiversionset/method_createorupdate.go @@ -0,0 +1,85 @@ +package apiversionset + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ApiVersionSetContract +} + +type CreateOrUpdateOperationOptions struct { + IfMatch *string +} + +func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { + return CreateOrUpdateOperationOptions{} +} + +func (o CreateOrUpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o CreateOrUpdateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o CreateOrUpdateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// CreateOrUpdate ... +func (c ApiVersionSetClient) CreateOrUpdate(ctx context.Context, id ApiVersionSetId, input ApiVersionSetContract, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + OptionsObject: options, + } + + 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/apimanagement/2021-08-01/apiversionset/method_createorupdate_autorest.go b/resource-manager/apimanagement/2021-08-01/apiversionset/method_createorupdate_autorest.go deleted file mode 100644 index 5ec307cada5..00000000000 --- a/resource-manager/apimanagement/2021-08-01/apiversionset/method_createorupdate_autorest.go +++ /dev/null @@ -1,98 +0,0 @@ -package apiversionset - -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 *ApiVersionSetContract -} - -type CreateOrUpdateOperationOptions struct { - IfMatch *string -} - -func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { - return CreateOrUpdateOperationOptions{} -} - -func (o CreateOrUpdateOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o CreateOrUpdateOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// CreateOrUpdate ... -func (c ApiVersionSetClient) CreateOrUpdate(ctx context.Context, id ApiVersionSetId, input ApiVersionSetContract, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdate(ctx, id, input, options) - if err != nil { - err = autorest.NewErrorWithError(err, "apiversionset.ApiVersionSetClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apiversionset.ApiVersionSetClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCreateOrUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apiversionset.ApiVersionSetClient", "CreateOrUpdate", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCreateOrUpdate prepares the CreateOrUpdate request. -func (c ApiVersionSetClient) preparerForCreateOrUpdate(ctx context.Context, id ApiVersionSetId, input ApiVersionSetContract, options CreateOrUpdateOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - 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 ApiVersionSetClient) responderForCreateOrUpdate(resp *http.Response) (result CreateOrUpdateOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2021-08-01/apiversionset/method_get.go b/resource-manager/apimanagement/2021-08-01/apiversionset/method_get.go new file mode 100644 index 00000000000..910c5a90631 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/apiversionset/method_get.go @@ -0,0 +1,51 @@ +package apiversionset + +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 *ApiVersionSetContract +} + +// Get ... +func (c ApiVersionSetClient) Get(ctx context.Context, id ApiVersionSetId) (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/apimanagement/2021-08-01/apiversionset/method_get_autorest.go b/resource-manager/apimanagement/2021-08-01/apiversionset/method_get_autorest.go deleted file mode 100644 index 51f2f6edc1b..00000000000 --- a/resource-manager/apimanagement/2021-08-01/apiversionset/method_get_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package apiversionset - -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 *ApiVersionSetContract -} - -// Get ... -func (c ApiVersionSetClient) Get(ctx context.Context, id ApiVersionSetId) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "apiversionset.ApiVersionSetClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apiversionset.ApiVersionSetClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apiversionset.ApiVersionSetClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c ApiVersionSetClient) preparerForGet(ctx context.Context, id ApiVersionSetId) (*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 ApiVersionSetClient) 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/apimanagement/2021-08-01/apiversionset/method_getentitytag.go b/resource-manager/apimanagement/2021-08-01/apiversionset/method_getentitytag.go new file mode 100644 index 00000000000..9f95f1e557c --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/apiversionset/method_getentitytag.go @@ -0,0 +1,46 @@ +package apiversionset + +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 GetEntityTagOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// GetEntityTag ... +func (c ApiVersionSetClient) GetEntityTag(ctx context.Context, id ApiVersionSetId) (result GetEntityTagOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodHead, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2021-08-01/apiversionset/method_getentitytag_autorest.go b/resource-manager/apimanagement/2021-08-01/apiversionset/method_getentitytag_autorest.go deleted file mode 100644 index a0997df5dc8..00000000000 --- a/resource-manager/apimanagement/2021-08-01/apiversionset/method_getentitytag_autorest.go +++ /dev/null @@ -1,66 +0,0 @@ -package apiversionset - -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 GetEntityTagOperationResponse struct { - HttpResponse *http.Response -} - -// GetEntityTag ... -func (c ApiVersionSetClient) GetEntityTag(ctx context.Context, id ApiVersionSetId) (result GetEntityTagOperationResponse, err error) { - req, err := c.preparerForGetEntityTag(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "apiversionset.ApiVersionSetClient", "GetEntityTag", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apiversionset.ApiVersionSetClient", "GetEntityTag", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetEntityTag(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apiversionset.ApiVersionSetClient", "GetEntityTag", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetEntityTag prepares the GetEntityTag request. -func (c ApiVersionSetClient) preparerForGetEntityTag(ctx context.Context, id ApiVersionSetId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsHead(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetEntityTag handles the response to the GetEntityTag request. The method always -// closes the http.Response Body. -func (c ApiVersionSetClient) responderForGetEntityTag(resp *http.Response) (result GetEntityTagOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2021-08-01/apiversionset/method_listbyservice.go b/resource-manager/apimanagement/2021-08-01/apiversionset/method_listbyservice.go new file mode 100644 index 00000000000..c850c773f5e --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/apiversionset/method_listbyservice.go @@ -0,0 +1,125 @@ +package apiversionset + +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 ListByServiceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ApiVersionSetContract +} + +type ListByServiceCompleteResult struct { + Items []ApiVersionSetContract +} + +type ListByServiceOperationOptions struct { + Filter *string + Skip *int64 + Top *int64 +} + +func DefaultListByServiceOperationOptions() ListByServiceOperationOptions { + return ListByServiceOperationOptions{} +} + +func (o ListByServiceOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListByServiceOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListByServiceOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.Skip != nil { + out.Append("$skip", fmt.Sprintf("%v", *o.Skip)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +// ListByService ... +func (c ApiVersionSetClient) ListByService(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (result ListByServiceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/apiVersionSets", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ApiVersionSetContract `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByServiceComplete retrieves all the results into a single object +func (c ApiVersionSetClient) ListByServiceComplete(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (ListByServiceCompleteResult, error) { + return c.ListByServiceCompleteMatchingPredicate(ctx, id, options, ApiVersionSetContractOperationPredicate{}) +} + +// ListByServiceCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ApiVersionSetClient) ListByServiceCompleteMatchingPredicate(ctx context.Context, id ServiceId, options ListByServiceOperationOptions, predicate ApiVersionSetContractOperationPredicate) (result ListByServiceCompleteResult, err error) { + items := make([]ApiVersionSetContract, 0) + + resp, err := c.ListByService(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByServiceCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/apimanagement/2021-08-01/apiversionset/method_listbyservice_autorest.go b/resource-manager/apimanagement/2021-08-01/apiversionset/method_listbyservice_autorest.go deleted file mode 100644 index a724e716e3a..00000000000 --- a/resource-manager/apimanagement/2021-08-01/apiversionset/method_listbyservice_autorest.go +++ /dev/null @@ -1,225 +0,0 @@ -package apiversionset - -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 ListByServiceOperationResponse struct { - HttpResponse *http.Response - Model *[]ApiVersionSetContract - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListByServiceOperationResponse, error) -} - -type ListByServiceCompleteResult struct { - Items []ApiVersionSetContract -} - -func (r ListByServiceOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListByServiceOperationResponse) LoadMore(ctx context.Context) (resp ListByServiceOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -type ListByServiceOperationOptions struct { - Filter *string - Skip *int64 - Top *int64 -} - -func DefaultListByServiceOperationOptions() ListByServiceOperationOptions { - return ListByServiceOperationOptions{} -} - -func (o ListByServiceOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o ListByServiceOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Filter != nil { - out["$filter"] = *o.Filter - } - - if o.Skip != nil { - out["$skip"] = *o.Skip - } - - if o.Top != nil { - out["$top"] = *o.Top - } - - return out -} - -// ListByService ... -func (c ApiVersionSetClient) ListByService(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (resp ListByServiceOperationResponse, err error) { - req, err := c.preparerForListByService(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "apiversionset.ApiVersionSetClient", "ListByService", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apiversionset.ApiVersionSetClient", "ListByService", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListByService(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apiversionset.ApiVersionSetClient", "ListByService", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListByService prepares the ListByService request. -func (c ApiVersionSetClient) preparerForListByService(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/apiVersionSets", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListByServiceWithNextLink prepares the ListByService request with the given nextLink token. -func (c ApiVersionSetClient) preparerForListByServiceWithNextLink(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)) -} - -// responderForListByService handles the response to the ListByService request. The method always -// closes the http.Response Body. -func (c ApiVersionSetClient) responderForListByService(resp *http.Response) (result ListByServiceOperationResponse, err error) { - type page struct { - Values []ApiVersionSetContract `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 ListByServiceOperationResponse, err error) { - req, err := c.preparerForListByServiceWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "apiversionset.ApiVersionSetClient", "ListByService", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apiversionset.ApiVersionSetClient", "ListByService", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByService(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apiversionset.ApiVersionSetClient", "ListByService", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListByServiceComplete retrieves all of the results into a single object -func (c ApiVersionSetClient) ListByServiceComplete(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (ListByServiceCompleteResult, error) { - return c.ListByServiceCompleteMatchingPredicate(ctx, id, options, ApiVersionSetContractOperationPredicate{}) -} - -// ListByServiceCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c ApiVersionSetClient) ListByServiceCompleteMatchingPredicate(ctx context.Context, id ServiceId, options ListByServiceOperationOptions, predicate ApiVersionSetContractOperationPredicate) (resp ListByServiceCompleteResult, err error) { - items := make([]ApiVersionSetContract, 0) - - page, err := c.ListByService(ctx, id, options) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListByServiceCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/apimanagement/2021-08-01/apiversionset/method_update.go b/resource-manager/apimanagement/2021-08-01/apiversionset/method_update.go new file mode 100644 index 00000000000..a894808f20a --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/apiversionset/method_update.go @@ -0,0 +1,84 @@ +package apiversionset + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ApiVersionSetContract +} + +type UpdateOperationOptions struct { + IfMatch *string +} + +func DefaultUpdateOperationOptions() UpdateOperationOptions { + return UpdateOperationOptions{} +} + +func (o UpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o UpdateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o UpdateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// Update ... +func (c ApiVersionSetClient) Update(ctx context.Context, id ApiVersionSetId, input ApiVersionSetUpdateParameters, options UpdateOperationOptions) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + OptionsObject: options, + } + + 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/apimanagement/2021-08-01/apiversionset/method_update_autorest.go b/resource-manager/apimanagement/2021-08-01/apiversionset/method_update_autorest.go deleted file mode 100644 index c839759e328..00000000000 --- a/resource-manager/apimanagement/2021-08-01/apiversionset/method_update_autorest.go +++ /dev/null @@ -1,98 +0,0 @@ -package apiversionset - -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 *ApiVersionSetContract -} - -type UpdateOperationOptions struct { - IfMatch *string -} - -func DefaultUpdateOperationOptions() UpdateOperationOptions { - return UpdateOperationOptions{} -} - -func (o UpdateOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o UpdateOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// Update ... -func (c ApiVersionSetClient) Update(ctx context.Context, id ApiVersionSetId, input ApiVersionSetUpdateParameters, options UpdateOperationOptions) (result UpdateOperationResponse, err error) { - req, err := c.preparerForUpdate(ctx, id, input, options) - if err != nil { - err = autorest.NewErrorWithError(err, "apiversionset.ApiVersionSetClient", "Update", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apiversionset.ApiVersionSetClient", "Update", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apiversionset.ApiVersionSetClient", "Update", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForUpdate prepares the Update request. -func (c ApiVersionSetClient) preparerForUpdate(ctx context.Context, id ApiVersionSetId, input ApiVersionSetUpdateParameters, options UpdateOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPatch(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - 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 ApiVersionSetClient) 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/apimanagement/2021-08-01/apiversionsets/client.go b/resource-manager/apimanagement/2021-08-01/apiversionsets/client.go index d927796792e..c9a60a4c6a0 100644 --- a/resource-manager/apimanagement/2021-08-01/apiversionsets/client.go +++ b/resource-manager/apimanagement/2021-08-01/apiversionsets/client.go @@ -1,18 +1,26 @@ package apiversionsets -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 ApiVersionSetsClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewApiVersionSetsClientWithBaseURI(endpoint string) ApiVersionSetsClient { - return ApiVersionSetsClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewApiVersionSetsClientWithBaseURI(api environments.Api) (*ApiVersionSetsClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "apiversionsets", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ApiVersionSetsClient: %+v", err) } + + return &ApiVersionSetsClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2021-08-01/apiversionsets/method_apiversionsetdelete.go b/resource-manager/apimanagement/2021-08-01/apiversionsets/method_apiversionsetdelete.go new file mode 100644 index 00000000000..f50800347d8 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/apiversionsets/method_apiversionsetdelete.go @@ -0,0 +1,76 @@ +package apiversionsets + +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 ApiVersionSetDeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +type ApiVersionSetDeleteOperationOptions struct { + IfMatch *string +} + +func DefaultApiVersionSetDeleteOperationOptions() ApiVersionSetDeleteOperationOptions { + return ApiVersionSetDeleteOperationOptions{} +} + +func (o ApiVersionSetDeleteOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o ApiVersionSetDeleteOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ApiVersionSetDeleteOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// ApiVersionSetDelete ... +func (c ApiVersionSetsClient) ApiVersionSetDelete(ctx context.Context, id ApiVersionSetId, options ApiVersionSetDeleteOperationOptions) (result ApiVersionSetDeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2021-08-01/apiversionsets/method_apiversionsetdelete_autorest.go b/resource-manager/apimanagement/2021-08-01/apiversionsets/method_apiversionsetdelete_autorest.go deleted file mode 100644 index 72a19648666..00000000000 --- a/resource-manager/apimanagement/2021-08-01/apiversionsets/method_apiversionsetdelete_autorest.go +++ /dev/null @@ -1,95 +0,0 @@ -package apiversionsets - -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 ApiVersionSetDeleteOperationResponse struct { - HttpResponse *http.Response -} - -type ApiVersionSetDeleteOperationOptions struct { - IfMatch *string -} - -func DefaultApiVersionSetDeleteOperationOptions() ApiVersionSetDeleteOperationOptions { - return ApiVersionSetDeleteOperationOptions{} -} - -func (o ApiVersionSetDeleteOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o ApiVersionSetDeleteOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// ApiVersionSetDelete ... -func (c ApiVersionSetsClient) ApiVersionSetDelete(ctx context.Context, id ApiVersionSetId, options ApiVersionSetDeleteOperationOptions) (result ApiVersionSetDeleteOperationResponse, err error) { - req, err := c.preparerForApiVersionSetDelete(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "apiversionsets.ApiVersionSetsClient", "ApiVersionSetDelete", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apiversionsets.ApiVersionSetsClient", "ApiVersionSetDelete", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForApiVersionSetDelete(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apiversionsets.ApiVersionSetsClient", "ApiVersionSetDelete", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForApiVersionSetDelete prepares the ApiVersionSetDelete request. -func (c ApiVersionSetsClient) preparerForApiVersionSetDelete(ctx context.Context, id ApiVersionSetId, options ApiVersionSetDeleteOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForApiVersionSetDelete handles the response to the ApiVersionSetDelete request. The method always -// closes the http.Response Body. -func (c ApiVersionSetsClient) responderForApiVersionSetDelete(resp *http.Response) (result ApiVersionSetDeleteOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2021-08-01/authorizationserver/client.go b/resource-manager/apimanagement/2021-08-01/authorizationserver/client.go index a0b4979583f..8467f21fe14 100644 --- a/resource-manager/apimanagement/2021-08-01/authorizationserver/client.go +++ b/resource-manager/apimanagement/2021-08-01/authorizationserver/client.go @@ -1,18 +1,26 @@ package authorizationserver -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 AuthorizationServerClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewAuthorizationServerClientWithBaseURI(endpoint string) AuthorizationServerClient { - return AuthorizationServerClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewAuthorizationServerClientWithBaseURI(api environments.Api) (*AuthorizationServerClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "authorizationserver", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating AuthorizationServerClient: %+v", err) } + + return &AuthorizationServerClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2021-08-01/authorizationserver/constants.go b/resource-manager/apimanagement/2021-08-01/authorizationserver/constants.go index e04f6ee15bd..135527703de 100644 --- a/resource-manager/apimanagement/2021-08-01/authorizationserver/constants.go +++ b/resource-manager/apimanagement/2021-08-01/authorizationserver/constants.go @@ -1,6 +1,10 @@ package authorizationserver -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. @@ -31,6 +35,19 @@ func PossibleValuesForAuthorizationMethod() []string { } } +func (s *AuthorizationMethod) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAuthorizationMethod(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseAuthorizationMethod(input string) (*AuthorizationMethod, error) { vals := map[string]AuthorizationMethod{ "delete": AuthorizationMethodDELETE, @@ -65,6 +82,19 @@ func PossibleValuesForBearerTokenSendingMethod() []string { } } +func (s *BearerTokenSendingMethod) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseBearerTokenSendingMethod(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseBearerTokenSendingMethod(input string) (*BearerTokenSendingMethod, error) { vals := map[string]BearerTokenSendingMethod{ "authorizationheader": BearerTokenSendingMethodAuthorizationHeader, @@ -93,6 +123,19 @@ func PossibleValuesForClientAuthenticationMethod() []string { } } +func (s *ClientAuthenticationMethod) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseClientAuthenticationMethod(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseClientAuthenticationMethod(input string) (*ClientAuthenticationMethod, error) { vals := map[string]ClientAuthenticationMethod{ "basic": ClientAuthenticationMethodBasic, @@ -125,6 +168,19 @@ func PossibleValuesForGrantType() []string { } } +func (s *GrantType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseGrantType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseGrantType(input string) (*GrantType, error) { vals := map[string]GrantType{ "authorizationcode": GrantTypeAuthorizationCode, diff --git a/resource-manager/apimanagement/2021-08-01/authorizationserver/method_createorupdate.go b/resource-manager/apimanagement/2021-08-01/authorizationserver/method_createorupdate.go new file mode 100644 index 00000000000..9c56c38cce1 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/authorizationserver/method_createorupdate.go @@ -0,0 +1,85 @@ +package authorizationserver + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *AuthorizationServerContract +} + +type CreateOrUpdateOperationOptions struct { + IfMatch *string +} + +func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { + return CreateOrUpdateOperationOptions{} +} + +func (o CreateOrUpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o CreateOrUpdateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o CreateOrUpdateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// CreateOrUpdate ... +func (c AuthorizationServerClient) CreateOrUpdate(ctx context.Context, id AuthorizationServerId, input AuthorizationServerContract, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + OptionsObject: options, + } + + 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/apimanagement/2021-08-01/authorizationserver/method_createorupdate_autorest.go b/resource-manager/apimanagement/2021-08-01/authorizationserver/method_createorupdate_autorest.go deleted file mode 100644 index 60a97c7646d..00000000000 --- a/resource-manager/apimanagement/2021-08-01/authorizationserver/method_createorupdate_autorest.go +++ /dev/null @@ -1,98 +0,0 @@ -package authorizationserver - -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 *AuthorizationServerContract -} - -type CreateOrUpdateOperationOptions struct { - IfMatch *string -} - -func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { - return CreateOrUpdateOperationOptions{} -} - -func (o CreateOrUpdateOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o CreateOrUpdateOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// CreateOrUpdate ... -func (c AuthorizationServerClient) CreateOrUpdate(ctx context.Context, id AuthorizationServerId, input AuthorizationServerContract, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdate(ctx, id, input, options) - if err != nil { - err = autorest.NewErrorWithError(err, "authorizationserver.AuthorizationServerClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "authorizationserver.AuthorizationServerClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCreateOrUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "authorizationserver.AuthorizationServerClient", "CreateOrUpdate", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCreateOrUpdate prepares the CreateOrUpdate request. -func (c AuthorizationServerClient) preparerForCreateOrUpdate(ctx context.Context, id AuthorizationServerId, input AuthorizationServerContract, options CreateOrUpdateOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - 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 AuthorizationServerClient) responderForCreateOrUpdate(resp *http.Response) (result CreateOrUpdateOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2021-08-01/authorizationserver/method_delete.go b/resource-manager/apimanagement/2021-08-01/authorizationserver/method_delete.go new file mode 100644 index 00000000000..ad1674315f1 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/authorizationserver/method_delete.go @@ -0,0 +1,76 @@ +package authorizationserver + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +type DeleteOperationOptions struct { + IfMatch *string +} + +func DefaultDeleteOperationOptions() DeleteOperationOptions { + return DeleteOperationOptions{} +} + +func (o DeleteOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o DeleteOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o DeleteOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// Delete ... +func (c AuthorizationServerClient) Delete(ctx context.Context, id AuthorizationServerId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2021-08-01/authorizationserver/method_delete_autorest.go b/resource-manager/apimanagement/2021-08-01/authorizationserver/method_delete_autorest.go deleted file mode 100644 index d7cc9dff660..00000000000 --- a/resource-manager/apimanagement/2021-08-01/authorizationserver/method_delete_autorest.go +++ /dev/null @@ -1,95 +0,0 @@ -package authorizationserver - -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 DeleteOperationResponse struct { - HttpResponse *http.Response -} - -type DeleteOperationOptions struct { - IfMatch *string -} - -func DefaultDeleteOperationOptions() DeleteOperationOptions { - return DeleteOperationOptions{} -} - -func (o DeleteOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o DeleteOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// Delete ... -func (c AuthorizationServerClient) Delete(ctx context.Context, id AuthorizationServerId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { - req, err := c.preparerForDelete(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "authorizationserver.AuthorizationServerClient", "Delete", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "authorizationserver.AuthorizationServerClient", "Delete", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForDelete(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "authorizationserver.AuthorizationServerClient", "Delete", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForDelete prepares the Delete request. -func (c AuthorizationServerClient) preparerForDelete(ctx context.Context, id AuthorizationServerId, options DeleteOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForDelete handles the response to the Delete request. The method always -// closes the http.Response Body. -func (c AuthorizationServerClient) responderForDelete(resp *http.Response) (result DeleteOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2021-08-01/authorizationserver/method_get.go b/resource-manager/apimanagement/2021-08-01/authorizationserver/method_get.go new file mode 100644 index 00000000000..35bc15341b9 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/authorizationserver/method_get.go @@ -0,0 +1,51 @@ +package authorizationserver + +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 *AuthorizationServerContract +} + +// Get ... +func (c AuthorizationServerClient) Get(ctx context.Context, id AuthorizationServerId) (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/apimanagement/2021-08-01/authorizationserver/method_get_autorest.go b/resource-manager/apimanagement/2021-08-01/authorizationserver/method_get_autorest.go deleted file mode 100644 index 4f6ec3d9ba4..00000000000 --- a/resource-manager/apimanagement/2021-08-01/authorizationserver/method_get_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package authorizationserver - -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 *AuthorizationServerContract -} - -// Get ... -func (c AuthorizationServerClient) Get(ctx context.Context, id AuthorizationServerId) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "authorizationserver.AuthorizationServerClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "authorizationserver.AuthorizationServerClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "authorizationserver.AuthorizationServerClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c AuthorizationServerClient) preparerForGet(ctx context.Context, id AuthorizationServerId) (*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 AuthorizationServerClient) 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/apimanagement/2021-08-01/authorizationserver/method_getentitytag.go b/resource-manager/apimanagement/2021-08-01/authorizationserver/method_getentitytag.go new file mode 100644 index 00000000000..4eb7f0abe34 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/authorizationserver/method_getentitytag.go @@ -0,0 +1,46 @@ +package authorizationserver + +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 GetEntityTagOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// GetEntityTag ... +func (c AuthorizationServerClient) GetEntityTag(ctx context.Context, id AuthorizationServerId) (result GetEntityTagOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodHead, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2021-08-01/authorizationserver/method_getentitytag_autorest.go b/resource-manager/apimanagement/2021-08-01/authorizationserver/method_getentitytag_autorest.go deleted file mode 100644 index 6ca77e2c3d7..00000000000 --- a/resource-manager/apimanagement/2021-08-01/authorizationserver/method_getentitytag_autorest.go +++ /dev/null @@ -1,66 +0,0 @@ -package authorizationserver - -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 GetEntityTagOperationResponse struct { - HttpResponse *http.Response -} - -// GetEntityTag ... -func (c AuthorizationServerClient) GetEntityTag(ctx context.Context, id AuthorizationServerId) (result GetEntityTagOperationResponse, err error) { - req, err := c.preparerForGetEntityTag(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "authorizationserver.AuthorizationServerClient", "GetEntityTag", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "authorizationserver.AuthorizationServerClient", "GetEntityTag", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetEntityTag(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "authorizationserver.AuthorizationServerClient", "GetEntityTag", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetEntityTag prepares the GetEntityTag request. -func (c AuthorizationServerClient) preparerForGetEntityTag(ctx context.Context, id AuthorizationServerId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsHead(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetEntityTag handles the response to the GetEntityTag request. The method always -// closes the http.Response Body. -func (c AuthorizationServerClient) responderForGetEntityTag(resp *http.Response) (result GetEntityTagOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2021-08-01/authorizationserver/method_listbyservice.go b/resource-manager/apimanagement/2021-08-01/authorizationserver/method_listbyservice.go new file mode 100644 index 00000000000..17a21580a93 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/authorizationserver/method_listbyservice.go @@ -0,0 +1,125 @@ +package authorizationserver + +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 ListByServiceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]AuthorizationServerContract +} + +type ListByServiceCompleteResult struct { + Items []AuthorizationServerContract +} + +type ListByServiceOperationOptions struct { + Filter *string + Skip *int64 + Top *int64 +} + +func DefaultListByServiceOperationOptions() ListByServiceOperationOptions { + return ListByServiceOperationOptions{} +} + +func (o ListByServiceOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListByServiceOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListByServiceOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.Skip != nil { + out.Append("$skip", fmt.Sprintf("%v", *o.Skip)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +// ListByService ... +func (c AuthorizationServerClient) ListByService(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (result ListByServiceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/authorizationServers", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]AuthorizationServerContract `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByServiceComplete retrieves all the results into a single object +func (c AuthorizationServerClient) ListByServiceComplete(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (ListByServiceCompleteResult, error) { + return c.ListByServiceCompleteMatchingPredicate(ctx, id, options, AuthorizationServerContractOperationPredicate{}) +} + +// ListByServiceCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AuthorizationServerClient) ListByServiceCompleteMatchingPredicate(ctx context.Context, id ServiceId, options ListByServiceOperationOptions, predicate AuthorizationServerContractOperationPredicate) (result ListByServiceCompleteResult, err error) { + items := make([]AuthorizationServerContract, 0) + + resp, err := c.ListByService(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByServiceCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/apimanagement/2021-08-01/authorizationserver/method_listbyservice_autorest.go b/resource-manager/apimanagement/2021-08-01/authorizationserver/method_listbyservice_autorest.go deleted file mode 100644 index 7d3c48d2ad9..00000000000 --- a/resource-manager/apimanagement/2021-08-01/authorizationserver/method_listbyservice_autorest.go +++ /dev/null @@ -1,225 +0,0 @@ -package authorizationserver - -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 ListByServiceOperationResponse struct { - HttpResponse *http.Response - Model *[]AuthorizationServerContract - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListByServiceOperationResponse, error) -} - -type ListByServiceCompleteResult struct { - Items []AuthorizationServerContract -} - -func (r ListByServiceOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListByServiceOperationResponse) LoadMore(ctx context.Context) (resp ListByServiceOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -type ListByServiceOperationOptions struct { - Filter *string - Skip *int64 - Top *int64 -} - -func DefaultListByServiceOperationOptions() ListByServiceOperationOptions { - return ListByServiceOperationOptions{} -} - -func (o ListByServiceOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o ListByServiceOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Filter != nil { - out["$filter"] = *o.Filter - } - - if o.Skip != nil { - out["$skip"] = *o.Skip - } - - if o.Top != nil { - out["$top"] = *o.Top - } - - return out -} - -// ListByService ... -func (c AuthorizationServerClient) ListByService(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (resp ListByServiceOperationResponse, err error) { - req, err := c.preparerForListByService(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "authorizationserver.AuthorizationServerClient", "ListByService", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "authorizationserver.AuthorizationServerClient", "ListByService", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListByService(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "authorizationserver.AuthorizationServerClient", "ListByService", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListByService prepares the ListByService request. -func (c AuthorizationServerClient) preparerForListByService(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/authorizationServers", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListByServiceWithNextLink prepares the ListByService request with the given nextLink token. -func (c AuthorizationServerClient) preparerForListByServiceWithNextLink(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)) -} - -// responderForListByService handles the response to the ListByService request. The method always -// closes the http.Response Body. -func (c AuthorizationServerClient) responderForListByService(resp *http.Response) (result ListByServiceOperationResponse, err error) { - type page struct { - Values []AuthorizationServerContract `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 ListByServiceOperationResponse, err error) { - req, err := c.preparerForListByServiceWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "authorizationserver.AuthorizationServerClient", "ListByService", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "authorizationserver.AuthorizationServerClient", "ListByService", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByService(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "authorizationserver.AuthorizationServerClient", "ListByService", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListByServiceComplete retrieves all of the results into a single object -func (c AuthorizationServerClient) ListByServiceComplete(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (ListByServiceCompleteResult, error) { - return c.ListByServiceCompleteMatchingPredicate(ctx, id, options, AuthorizationServerContractOperationPredicate{}) -} - -// ListByServiceCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c AuthorizationServerClient) ListByServiceCompleteMatchingPredicate(ctx context.Context, id ServiceId, options ListByServiceOperationOptions, predicate AuthorizationServerContractOperationPredicate) (resp ListByServiceCompleteResult, err error) { - items := make([]AuthorizationServerContract, 0) - - page, err := c.ListByService(ctx, id, options) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListByServiceCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/apimanagement/2021-08-01/authorizationserver/method_listsecrets.go b/resource-manager/apimanagement/2021-08-01/authorizationserver/method_listsecrets.go new file mode 100644 index 00000000000..e65f9582795 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/authorizationserver/method_listsecrets.go @@ -0,0 +1,52 @@ +package authorizationserver + +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 ListSecretsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *AuthorizationServerSecretsContract +} + +// ListSecrets ... +func (c AuthorizationServerClient) ListSecrets(ctx context.Context, id AuthorizationServerId) (result ListSecretsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/listSecrets", 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/apimanagement/2021-08-01/authorizationserver/method_listsecrets_autorest.go b/resource-manager/apimanagement/2021-08-01/authorizationserver/method_listsecrets_autorest.go deleted file mode 100644 index 246b21f3eb2..00000000000 --- a/resource-manager/apimanagement/2021-08-01/authorizationserver/method_listsecrets_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package authorizationserver - -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 ListSecretsOperationResponse struct { - HttpResponse *http.Response - Model *AuthorizationServerSecretsContract -} - -// ListSecrets ... -func (c AuthorizationServerClient) ListSecrets(ctx context.Context, id AuthorizationServerId) (result ListSecretsOperationResponse, err error) { - req, err := c.preparerForListSecrets(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "authorizationserver.AuthorizationServerClient", "ListSecrets", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "authorizationserver.AuthorizationServerClient", "ListSecrets", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListSecrets(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "authorizationserver.AuthorizationServerClient", "ListSecrets", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForListSecrets prepares the ListSecrets request. -func (c AuthorizationServerClient) preparerForListSecrets(ctx context.Context, id AuthorizationServerId) (*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/listSecrets", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListSecrets handles the response to the ListSecrets request. The method always -// closes the http.Response Body. -func (c AuthorizationServerClient) responderForListSecrets(resp *http.Response) (result ListSecretsOperationResponse, 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/apimanagement/2021-08-01/authorizationserver/method_update.go b/resource-manager/apimanagement/2021-08-01/authorizationserver/method_update.go new file mode 100644 index 00000000000..d92ea160b6f --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/authorizationserver/method_update.go @@ -0,0 +1,84 @@ +package authorizationserver + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *AuthorizationServerContract +} + +type UpdateOperationOptions struct { + IfMatch *string +} + +func DefaultUpdateOperationOptions() UpdateOperationOptions { + return UpdateOperationOptions{} +} + +func (o UpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o UpdateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o UpdateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// Update ... +func (c AuthorizationServerClient) Update(ctx context.Context, id AuthorizationServerId, input AuthorizationServerUpdateContract, options UpdateOperationOptions) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + OptionsObject: options, + } + + 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/apimanagement/2021-08-01/authorizationserver/method_update_autorest.go b/resource-manager/apimanagement/2021-08-01/authorizationserver/method_update_autorest.go deleted file mode 100644 index 7bb82b54e5f..00000000000 --- a/resource-manager/apimanagement/2021-08-01/authorizationserver/method_update_autorest.go +++ /dev/null @@ -1,98 +0,0 @@ -package authorizationserver - -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 *AuthorizationServerContract -} - -type UpdateOperationOptions struct { - IfMatch *string -} - -func DefaultUpdateOperationOptions() UpdateOperationOptions { - return UpdateOperationOptions{} -} - -func (o UpdateOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o UpdateOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// Update ... -func (c AuthorizationServerClient) Update(ctx context.Context, id AuthorizationServerId, input AuthorizationServerUpdateContract, options UpdateOperationOptions) (result UpdateOperationResponse, err error) { - req, err := c.preparerForUpdate(ctx, id, input, options) - if err != nil { - err = autorest.NewErrorWithError(err, "authorizationserver.AuthorizationServerClient", "Update", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "authorizationserver.AuthorizationServerClient", "Update", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "authorizationserver.AuthorizationServerClient", "Update", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForUpdate prepares the Update request. -func (c AuthorizationServerClient) preparerForUpdate(ctx context.Context, id AuthorizationServerId, input AuthorizationServerUpdateContract, options UpdateOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPatch(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - 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 AuthorizationServerClient) 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/apimanagement/2021-08-01/backend/client.go b/resource-manager/apimanagement/2021-08-01/backend/client.go index 6bfb57d9510..b942440b60a 100644 --- a/resource-manager/apimanagement/2021-08-01/backend/client.go +++ b/resource-manager/apimanagement/2021-08-01/backend/client.go @@ -1,18 +1,26 @@ package backend -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 BackendClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewBackendClientWithBaseURI(endpoint string) BackendClient { - return BackendClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewBackendClientWithBaseURI(api environments.Api) (*BackendClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "backend", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating BackendClient: %+v", err) } + + return &BackendClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2021-08-01/backend/constants.go b/resource-manager/apimanagement/2021-08-01/backend/constants.go index ea964ece6fb..fe71e64cb91 100644 --- a/resource-manager/apimanagement/2021-08-01/backend/constants.go +++ b/resource-manager/apimanagement/2021-08-01/backend/constants.go @@ -1,6 +1,10 @@ package backend -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 PossibleValuesForBackendProtocol() []string { } } +func (s *BackendProtocol) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseBackendProtocol(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseBackendProtocol(input string) (*BackendProtocol, error) { vals := map[string]BackendProtocol{ "http": BackendProtocolHTTP, diff --git a/resource-manager/apimanagement/2021-08-01/backend/method_createorupdate.go b/resource-manager/apimanagement/2021-08-01/backend/method_createorupdate.go new file mode 100644 index 00000000000..c999d10c186 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/backend/method_createorupdate.go @@ -0,0 +1,85 @@ +package backend + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *BackendContract +} + +type CreateOrUpdateOperationOptions struct { + IfMatch *string +} + +func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { + return CreateOrUpdateOperationOptions{} +} + +func (o CreateOrUpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o CreateOrUpdateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o CreateOrUpdateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// CreateOrUpdate ... +func (c BackendClient) CreateOrUpdate(ctx context.Context, id BackendId, input BackendContract, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + OptionsObject: options, + } + + 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/apimanagement/2021-08-01/backend/method_createorupdate_autorest.go b/resource-manager/apimanagement/2021-08-01/backend/method_createorupdate_autorest.go deleted file mode 100644 index 75dec17d56d..00000000000 --- a/resource-manager/apimanagement/2021-08-01/backend/method_createorupdate_autorest.go +++ /dev/null @@ -1,98 +0,0 @@ -package backend - -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 *BackendContract -} - -type CreateOrUpdateOperationOptions struct { - IfMatch *string -} - -func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { - return CreateOrUpdateOperationOptions{} -} - -func (o CreateOrUpdateOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o CreateOrUpdateOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// CreateOrUpdate ... -func (c BackendClient) CreateOrUpdate(ctx context.Context, id BackendId, input BackendContract, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdate(ctx, id, input, options) - if err != nil { - err = autorest.NewErrorWithError(err, "backend.BackendClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "backend.BackendClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCreateOrUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "backend.BackendClient", "CreateOrUpdate", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCreateOrUpdate prepares the CreateOrUpdate request. -func (c BackendClient) preparerForCreateOrUpdate(ctx context.Context, id BackendId, input BackendContract, options CreateOrUpdateOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - 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 BackendClient) responderForCreateOrUpdate(resp *http.Response) (result CreateOrUpdateOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2021-08-01/backend/method_delete.go b/resource-manager/apimanagement/2021-08-01/backend/method_delete.go new file mode 100644 index 00000000000..a8e6a5ab37b --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/backend/method_delete.go @@ -0,0 +1,76 @@ +package backend + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +type DeleteOperationOptions struct { + IfMatch *string +} + +func DefaultDeleteOperationOptions() DeleteOperationOptions { + return DeleteOperationOptions{} +} + +func (o DeleteOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o DeleteOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o DeleteOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// Delete ... +func (c BackendClient) Delete(ctx context.Context, id BackendId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2021-08-01/backend/method_delete_autorest.go b/resource-manager/apimanagement/2021-08-01/backend/method_delete_autorest.go deleted file mode 100644 index c1c6dc95ec7..00000000000 --- a/resource-manager/apimanagement/2021-08-01/backend/method_delete_autorest.go +++ /dev/null @@ -1,95 +0,0 @@ -package backend - -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 DeleteOperationResponse struct { - HttpResponse *http.Response -} - -type DeleteOperationOptions struct { - IfMatch *string -} - -func DefaultDeleteOperationOptions() DeleteOperationOptions { - return DeleteOperationOptions{} -} - -func (o DeleteOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o DeleteOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// Delete ... -func (c BackendClient) Delete(ctx context.Context, id BackendId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { - req, err := c.preparerForDelete(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "backend.BackendClient", "Delete", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "backend.BackendClient", "Delete", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForDelete(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "backend.BackendClient", "Delete", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForDelete prepares the Delete request. -func (c BackendClient) preparerForDelete(ctx context.Context, id BackendId, options DeleteOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForDelete handles the response to the Delete request. The method always -// closes the http.Response Body. -func (c BackendClient) responderForDelete(resp *http.Response) (result DeleteOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2021-08-01/backend/method_get.go b/resource-manager/apimanagement/2021-08-01/backend/method_get.go new file mode 100644 index 00000000000..2af01eaec6f --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/backend/method_get.go @@ -0,0 +1,51 @@ +package backend + +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 *BackendContract +} + +// Get ... +func (c BackendClient) Get(ctx context.Context, id BackendId) (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/apimanagement/2021-08-01/backend/method_get_autorest.go b/resource-manager/apimanagement/2021-08-01/backend/method_get_autorest.go deleted file mode 100644 index ad57ec2ac1f..00000000000 --- a/resource-manager/apimanagement/2021-08-01/backend/method_get_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package backend - -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 *BackendContract -} - -// Get ... -func (c BackendClient) Get(ctx context.Context, id BackendId) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "backend.BackendClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "backend.BackendClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "backend.BackendClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c BackendClient) preparerForGet(ctx context.Context, id BackendId) (*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 BackendClient) 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/apimanagement/2021-08-01/backend/method_getentitytag.go b/resource-manager/apimanagement/2021-08-01/backend/method_getentitytag.go new file mode 100644 index 00000000000..6bff18fa57d --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/backend/method_getentitytag.go @@ -0,0 +1,46 @@ +package backend + +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 GetEntityTagOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// GetEntityTag ... +func (c BackendClient) GetEntityTag(ctx context.Context, id BackendId) (result GetEntityTagOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodHead, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2021-08-01/backend/method_getentitytag_autorest.go b/resource-manager/apimanagement/2021-08-01/backend/method_getentitytag_autorest.go deleted file mode 100644 index 9d500b6b320..00000000000 --- a/resource-manager/apimanagement/2021-08-01/backend/method_getentitytag_autorest.go +++ /dev/null @@ -1,66 +0,0 @@ -package backend - -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 GetEntityTagOperationResponse struct { - HttpResponse *http.Response -} - -// GetEntityTag ... -func (c BackendClient) GetEntityTag(ctx context.Context, id BackendId) (result GetEntityTagOperationResponse, err error) { - req, err := c.preparerForGetEntityTag(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "backend.BackendClient", "GetEntityTag", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "backend.BackendClient", "GetEntityTag", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetEntityTag(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "backend.BackendClient", "GetEntityTag", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetEntityTag prepares the GetEntityTag request. -func (c BackendClient) preparerForGetEntityTag(ctx context.Context, id BackendId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsHead(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetEntityTag handles the response to the GetEntityTag request. The method always -// closes the http.Response Body. -func (c BackendClient) responderForGetEntityTag(resp *http.Response) (result GetEntityTagOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2021-08-01/backend/method_listbyservice.go b/resource-manager/apimanagement/2021-08-01/backend/method_listbyservice.go new file mode 100644 index 00000000000..1c0cb8aab20 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/backend/method_listbyservice.go @@ -0,0 +1,125 @@ +package backend + +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 ListByServiceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]BackendContract +} + +type ListByServiceCompleteResult struct { + Items []BackendContract +} + +type ListByServiceOperationOptions struct { + Filter *string + Skip *int64 + Top *int64 +} + +func DefaultListByServiceOperationOptions() ListByServiceOperationOptions { + return ListByServiceOperationOptions{} +} + +func (o ListByServiceOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListByServiceOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListByServiceOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.Skip != nil { + out.Append("$skip", fmt.Sprintf("%v", *o.Skip)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +// ListByService ... +func (c BackendClient) ListByService(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (result ListByServiceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/backends", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]BackendContract `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByServiceComplete retrieves all the results into a single object +func (c BackendClient) ListByServiceComplete(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (ListByServiceCompleteResult, error) { + return c.ListByServiceCompleteMatchingPredicate(ctx, id, options, BackendContractOperationPredicate{}) +} + +// ListByServiceCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c BackendClient) ListByServiceCompleteMatchingPredicate(ctx context.Context, id ServiceId, options ListByServiceOperationOptions, predicate BackendContractOperationPredicate) (result ListByServiceCompleteResult, err error) { + items := make([]BackendContract, 0) + + resp, err := c.ListByService(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByServiceCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/apimanagement/2021-08-01/backend/method_listbyservice_autorest.go b/resource-manager/apimanagement/2021-08-01/backend/method_listbyservice_autorest.go deleted file mode 100644 index d2c7a50b168..00000000000 --- a/resource-manager/apimanagement/2021-08-01/backend/method_listbyservice_autorest.go +++ /dev/null @@ -1,225 +0,0 @@ -package backend - -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 ListByServiceOperationResponse struct { - HttpResponse *http.Response - Model *[]BackendContract - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListByServiceOperationResponse, error) -} - -type ListByServiceCompleteResult struct { - Items []BackendContract -} - -func (r ListByServiceOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListByServiceOperationResponse) LoadMore(ctx context.Context) (resp ListByServiceOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -type ListByServiceOperationOptions struct { - Filter *string - Skip *int64 - Top *int64 -} - -func DefaultListByServiceOperationOptions() ListByServiceOperationOptions { - return ListByServiceOperationOptions{} -} - -func (o ListByServiceOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o ListByServiceOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Filter != nil { - out["$filter"] = *o.Filter - } - - if o.Skip != nil { - out["$skip"] = *o.Skip - } - - if o.Top != nil { - out["$top"] = *o.Top - } - - return out -} - -// ListByService ... -func (c BackendClient) ListByService(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (resp ListByServiceOperationResponse, err error) { - req, err := c.preparerForListByService(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "backend.BackendClient", "ListByService", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "backend.BackendClient", "ListByService", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListByService(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "backend.BackendClient", "ListByService", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListByService prepares the ListByService request. -func (c BackendClient) preparerForListByService(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/backends", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListByServiceWithNextLink prepares the ListByService request with the given nextLink token. -func (c BackendClient) preparerForListByServiceWithNextLink(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)) -} - -// responderForListByService handles the response to the ListByService request. The method always -// closes the http.Response Body. -func (c BackendClient) responderForListByService(resp *http.Response) (result ListByServiceOperationResponse, err error) { - type page struct { - Values []BackendContract `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 ListByServiceOperationResponse, err error) { - req, err := c.preparerForListByServiceWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "backend.BackendClient", "ListByService", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "backend.BackendClient", "ListByService", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByService(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "backend.BackendClient", "ListByService", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListByServiceComplete retrieves all of the results into a single object -func (c BackendClient) ListByServiceComplete(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (ListByServiceCompleteResult, error) { - return c.ListByServiceCompleteMatchingPredicate(ctx, id, options, BackendContractOperationPredicate{}) -} - -// ListByServiceCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c BackendClient) ListByServiceCompleteMatchingPredicate(ctx context.Context, id ServiceId, options ListByServiceOperationOptions, predicate BackendContractOperationPredicate) (resp ListByServiceCompleteResult, err error) { - items := make([]BackendContract, 0) - - page, err := c.ListByService(ctx, id, options) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListByServiceCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/apimanagement/2021-08-01/backend/method_update.go b/resource-manager/apimanagement/2021-08-01/backend/method_update.go new file mode 100644 index 00000000000..16ad3a5f0f9 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/backend/method_update.go @@ -0,0 +1,84 @@ +package backend + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *BackendContract +} + +type UpdateOperationOptions struct { + IfMatch *string +} + +func DefaultUpdateOperationOptions() UpdateOperationOptions { + return UpdateOperationOptions{} +} + +func (o UpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o UpdateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o UpdateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// Update ... +func (c BackendClient) Update(ctx context.Context, id BackendId, input BackendUpdateParameters, options UpdateOperationOptions) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + OptionsObject: options, + } + + 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/apimanagement/2021-08-01/backend/method_update_autorest.go b/resource-manager/apimanagement/2021-08-01/backend/method_update_autorest.go deleted file mode 100644 index 072e94d0e27..00000000000 --- a/resource-manager/apimanagement/2021-08-01/backend/method_update_autorest.go +++ /dev/null @@ -1,98 +0,0 @@ -package backend - -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 *BackendContract -} - -type UpdateOperationOptions struct { - IfMatch *string -} - -func DefaultUpdateOperationOptions() UpdateOperationOptions { - return UpdateOperationOptions{} -} - -func (o UpdateOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o UpdateOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// Update ... -func (c BackendClient) Update(ctx context.Context, id BackendId, input BackendUpdateParameters, options UpdateOperationOptions) (result UpdateOperationResponse, err error) { - req, err := c.preparerForUpdate(ctx, id, input, options) - if err != nil { - err = autorest.NewErrorWithError(err, "backend.BackendClient", "Update", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "backend.BackendClient", "Update", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "backend.BackendClient", "Update", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForUpdate prepares the Update request. -func (c BackendClient) preparerForUpdate(ctx context.Context, id BackendId, input BackendUpdateParameters, options UpdateOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPatch(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - 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 BackendClient) 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/apimanagement/2021-08-01/backendreconnect/client.go b/resource-manager/apimanagement/2021-08-01/backendreconnect/client.go index f4fd38d283c..c2932f63cad 100644 --- a/resource-manager/apimanagement/2021-08-01/backendreconnect/client.go +++ b/resource-manager/apimanagement/2021-08-01/backendreconnect/client.go @@ -1,18 +1,26 @@ package backendreconnect -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 BackendReconnectClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewBackendReconnectClientWithBaseURI(endpoint string) BackendReconnectClient { - return BackendReconnectClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewBackendReconnectClientWithBaseURI(api environments.Api) (*BackendReconnectClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "backendreconnect", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating BackendReconnectClient: %+v", err) } + + return &BackendReconnectClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2021-08-01/backendreconnect/method_backendreconnect.go b/resource-manager/apimanagement/2021-08-01/backendreconnect/method_backendreconnect.go new file mode 100644 index 00000000000..d75c5992fac --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/backendreconnect/method_backendreconnect.go @@ -0,0 +1,51 @@ +package backendreconnect + +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 BackendReconnectOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// BackendReconnect ... +func (c BackendReconnectClient) BackendReconnect(ctx context.Context, id BackendId, input BackendReconnectContract) (result BackendReconnectOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/reconnect", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2021-08-01/backendreconnect/method_backendreconnect_autorest.go b/resource-manager/apimanagement/2021-08-01/backendreconnect/method_backendreconnect_autorest.go deleted file mode 100644 index ae533c15f31..00000000000 --- a/resource-manager/apimanagement/2021-08-01/backendreconnect/method_backendreconnect_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package backendreconnect - -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 BackendReconnectOperationResponse struct { - HttpResponse *http.Response -} - -// BackendReconnect ... -func (c BackendReconnectClient) BackendReconnect(ctx context.Context, id BackendId, input BackendReconnectContract) (result BackendReconnectOperationResponse, err error) { - req, err := c.preparerForBackendReconnect(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "backendreconnect.BackendReconnectClient", "BackendReconnect", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "backendreconnect.BackendReconnectClient", "BackendReconnect", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForBackendReconnect(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "backendreconnect.BackendReconnectClient", "BackendReconnect", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForBackendReconnect prepares the BackendReconnect request. -func (c BackendReconnectClient) preparerForBackendReconnect(ctx context.Context, id BackendId, input BackendReconnectContract) (*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/reconnect", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForBackendReconnect handles the response to the BackendReconnect request. The method always -// closes the http.Response Body. -func (c BackendReconnectClient) responderForBackendReconnect(resp *http.Response) (result BackendReconnectOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusAccepted), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2021-08-01/cache/client.go b/resource-manager/apimanagement/2021-08-01/cache/client.go index 1d9fa5007ce..35d771e3d15 100644 --- a/resource-manager/apimanagement/2021-08-01/cache/client.go +++ b/resource-manager/apimanagement/2021-08-01/cache/client.go @@ -1,18 +1,26 @@ package cache -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 CacheClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewCacheClientWithBaseURI(endpoint string) CacheClient { - return CacheClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewCacheClientWithBaseURI(api environments.Api) (*CacheClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "cache", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating CacheClient: %+v", err) } + + return &CacheClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2021-08-01/cache/method_createorupdate.go b/resource-manager/apimanagement/2021-08-01/cache/method_createorupdate.go new file mode 100644 index 00000000000..ae370ba6bb9 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/cache/method_createorupdate.go @@ -0,0 +1,85 @@ +package cache + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *CacheContract +} + +type CreateOrUpdateOperationOptions struct { + IfMatch *string +} + +func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { + return CreateOrUpdateOperationOptions{} +} + +func (o CreateOrUpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o CreateOrUpdateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o CreateOrUpdateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// CreateOrUpdate ... +func (c CacheClient) CreateOrUpdate(ctx context.Context, id CacheId, input CacheContract, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + OptionsObject: options, + } + + 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/apimanagement/2021-08-01/cache/method_createorupdate_autorest.go b/resource-manager/apimanagement/2021-08-01/cache/method_createorupdate_autorest.go deleted file mode 100644 index 157b734abcf..00000000000 --- a/resource-manager/apimanagement/2021-08-01/cache/method_createorupdate_autorest.go +++ /dev/null @@ -1,98 +0,0 @@ -package cache - -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 *CacheContract -} - -type CreateOrUpdateOperationOptions struct { - IfMatch *string -} - -func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { - return CreateOrUpdateOperationOptions{} -} - -func (o CreateOrUpdateOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o CreateOrUpdateOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// CreateOrUpdate ... -func (c CacheClient) CreateOrUpdate(ctx context.Context, id CacheId, input CacheContract, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdate(ctx, id, input, options) - if err != nil { - err = autorest.NewErrorWithError(err, "cache.CacheClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "cache.CacheClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCreateOrUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "cache.CacheClient", "CreateOrUpdate", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCreateOrUpdate prepares the CreateOrUpdate request. -func (c CacheClient) preparerForCreateOrUpdate(ctx context.Context, id CacheId, input CacheContract, options CreateOrUpdateOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - 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 CacheClient) responderForCreateOrUpdate(resp *http.Response) (result CreateOrUpdateOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2021-08-01/cache/method_delete.go b/resource-manager/apimanagement/2021-08-01/cache/method_delete.go new file mode 100644 index 00000000000..4409902bb76 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/cache/method_delete.go @@ -0,0 +1,76 @@ +package cache + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +type DeleteOperationOptions struct { + IfMatch *string +} + +func DefaultDeleteOperationOptions() DeleteOperationOptions { + return DeleteOperationOptions{} +} + +func (o DeleteOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o DeleteOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o DeleteOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// Delete ... +func (c CacheClient) Delete(ctx context.Context, id CacheId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2021-08-01/cache/method_delete_autorest.go b/resource-manager/apimanagement/2021-08-01/cache/method_delete_autorest.go deleted file mode 100644 index d31981601b3..00000000000 --- a/resource-manager/apimanagement/2021-08-01/cache/method_delete_autorest.go +++ /dev/null @@ -1,95 +0,0 @@ -package cache - -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 DeleteOperationResponse struct { - HttpResponse *http.Response -} - -type DeleteOperationOptions struct { - IfMatch *string -} - -func DefaultDeleteOperationOptions() DeleteOperationOptions { - return DeleteOperationOptions{} -} - -func (o DeleteOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o DeleteOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// Delete ... -func (c CacheClient) Delete(ctx context.Context, id CacheId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { - req, err := c.preparerForDelete(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "cache.CacheClient", "Delete", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "cache.CacheClient", "Delete", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForDelete(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "cache.CacheClient", "Delete", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForDelete prepares the Delete request. -func (c CacheClient) preparerForDelete(ctx context.Context, id CacheId, options DeleteOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForDelete handles the response to the Delete request. The method always -// closes the http.Response Body. -func (c CacheClient) responderForDelete(resp *http.Response) (result DeleteOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2021-08-01/cache/method_get.go b/resource-manager/apimanagement/2021-08-01/cache/method_get.go new file mode 100644 index 00000000000..8108214f781 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/cache/method_get.go @@ -0,0 +1,51 @@ +package cache + +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 *CacheContract +} + +// Get ... +func (c CacheClient) Get(ctx context.Context, id CacheId) (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/apimanagement/2021-08-01/cache/method_get_autorest.go b/resource-manager/apimanagement/2021-08-01/cache/method_get_autorest.go deleted file mode 100644 index 3e001237bb8..00000000000 --- a/resource-manager/apimanagement/2021-08-01/cache/method_get_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package cache - -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 *CacheContract -} - -// Get ... -func (c CacheClient) Get(ctx context.Context, id CacheId) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "cache.CacheClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "cache.CacheClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "cache.CacheClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c CacheClient) preparerForGet(ctx context.Context, id CacheId) (*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 CacheClient) 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/apimanagement/2021-08-01/cache/method_getentitytag.go b/resource-manager/apimanagement/2021-08-01/cache/method_getentitytag.go new file mode 100644 index 00000000000..a221bde18d1 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/cache/method_getentitytag.go @@ -0,0 +1,46 @@ +package cache + +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 GetEntityTagOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// GetEntityTag ... +func (c CacheClient) GetEntityTag(ctx context.Context, id CacheId) (result GetEntityTagOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodHead, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2021-08-01/cache/method_getentitytag_autorest.go b/resource-manager/apimanagement/2021-08-01/cache/method_getentitytag_autorest.go deleted file mode 100644 index 5ac7d004001..00000000000 --- a/resource-manager/apimanagement/2021-08-01/cache/method_getentitytag_autorest.go +++ /dev/null @@ -1,66 +0,0 @@ -package cache - -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 GetEntityTagOperationResponse struct { - HttpResponse *http.Response -} - -// GetEntityTag ... -func (c CacheClient) GetEntityTag(ctx context.Context, id CacheId) (result GetEntityTagOperationResponse, err error) { - req, err := c.preparerForGetEntityTag(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "cache.CacheClient", "GetEntityTag", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "cache.CacheClient", "GetEntityTag", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetEntityTag(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "cache.CacheClient", "GetEntityTag", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetEntityTag prepares the GetEntityTag request. -func (c CacheClient) preparerForGetEntityTag(ctx context.Context, id CacheId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsHead(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetEntityTag handles the response to the GetEntityTag request. The method always -// closes the http.Response Body. -func (c CacheClient) responderForGetEntityTag(resp *http.Response) (result GetEntityTagOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2021-08-01/cache/method_listbyservice.go b/resource-manager/apimanagement/2021-08-01/cache/method_listbyservice.go new file mode 100644 index 00000000000..748d4374751 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/cache/method_listbyservice.go @@ -0,0 +1,121 @@ +package cache + +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 ListByServiceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]CacheContract +} + +type ListByServiceCompleteResult struct { + Items []CacheContract +} + +type ListByServiceOperationOptions struct { + Skip *int64 + Top *int64 +} + +func DefaultListByServiceOperationOptions() ListByServiceOperationOptions { + return ListByServiceOperationOptions{} +} + +func (o ListByServiceOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListByServiceOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListByServiceOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Skip != nil { + out.Append("$skip", fmt.Sprintf("%v", *o.Skip)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +// ListByService ... +func (c CacheClient) ListByService(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (result ListByServiceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/caches", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]CacheContract `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByServiceComplete retrieves all the results into a single object +func (c CacheClient) ListByServiceComplete(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (ListByServiceCompleteResult, error) { + return c.ListByServiceCompleteMatchingPredicate(ctx, id, options, CacheContractOperationPredicate{}) +} + +// ListByServiceCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c CacheClient) ListByServiceCompleteMatchingPredicate(ctx context.Context, id ServiceId, options ListByServiceOperationOptions, predicate CacheContractOperationPredicate) (result ListByServiceCompleteResult, err error) { + items := make([]CacheContract, 0) + + resp, err := c.ListByService(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByServiceCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/apimanagement/2021-08-01/cache/method_listbyservice_autorest.go b/resource-manager/apimanagement/2021-08-01/cache/method_listbyservice_autorest.go deleted file mode 100644 index 0bf37f6599c..00000000000 --- a/resource-manager/apimanagement/2021-08-01/cache/method_listbyservice_autorest.go +++ /dev/null @@ -1,220 +0,0 @@ -package cache - -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 ListByServiceOperationResponse struct { - HttpResponse *http.Response - Model *[]CacheContract - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListByServiceOperationResponse, error) -} - -type ListByServiceCompleteResult struct { - Items []CacheContract -} - -func (r ListByServiceOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListByServiceOperationResponse) LoadMore(ctx context.Context) (resp ListByServiceOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -type ListByServiceOperationOptions struct { - Skip *int64 - Top *int64 -} - -func DefaultListByServiceOperationOptions() ListByServiceOperationOptions { - return ListByServiceOperationOptions{} -} - -func (o ListByServiceOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o ListByServiceOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Skip != nil { - out["$skip"] = *o.Skip - } - - if o.Top != nil { - out["$top"] = *o.Top - } - - return out -} - -// ListByService ... -func (c CacheClient) ListByService(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (resp ListByServiceOperationResponse, err error) { - req, err := c.preparerForListByService(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "cache.CacheClient", "ListByService", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "cache.CacheClient", "ListByService", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListByService(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "cache.CacheClient", "ListByService", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListByService prepares the ListByService request. -func (c CacheClient) preparerForListByService(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/caches", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListByServiceWithNextLink prepares the ListByService request with the given nextLink token. -func (c CacheClient) preparerForListByServiceWithNextLink(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)) -} - -// responderForListByService handles the response to the ListByService request. The method always -// closes the http.Response Body. -func (c CacheClient) responderForListByService(resp *http.Response) (result ListByServiceOperationResponse, err error) { - type page struct { - Values []CacheContract `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 ListByServiceOperationResponse, err error) { - req, err := c.preparerForListByServiceWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "cache.CacheClient", "ListByService", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "cache.CacheClient", "ListByService", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByService(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "cache.CacheClient", "ListByService", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListByServiceComplete retrieves all of the results into a single object -func (c CacheClient) ListByServiceComplete(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (ListByServiceCompleteResult, error) { - return c.ListByServiceCompleteMatchingPredicate(ctx, id, options, CacheContractOperationPredicate{}) -} - -// ListByServiceCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c CacheClient) ListByServiceCompleteMatchingPredicate(ctx context.Context, id ServiceId, options ListByServiceOperationOptions, predicate CacheContractOperationPredicate) (resp ListByServiceCompleteResult, err error) { - items := make([]CacheContract, 0) - - page, err := c.ListByService(ctx, id, options) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListByServiceCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/apimanagement/2021-08-01/cache/method_update.go b/resource-manager/apimanagement/2021-08-01/cache/method_update.go new file mode 100644 index 00000000000..3aca9c35b36 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/cache/method_update.go @@ -0,0 +1,84 @@ +package cache + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *CacheContract +} + +type UpdateOperationOptions struct { + IfMatch *string +} + +func DefaultUpdateOperationOptions() UpdateOperationOptions { + return UpdateOperationOptions{} +} + +func (o UpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o UpdateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o UpdateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// Update ... +func (c CacheClient) Update(ctx context.Context, id CacheId, input CacheUpdateParameters, options UpdateOperationOptions) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + OptionsObject: options, + } + + 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/apimanagement/2021-08-01/cache/method_update_autorest.go b/resource-manager/apimanagement/2021-08-01/cache/method_update_autorest.go deleted file mode 100644 index 77f9a54c40b..00000000000 --- a/resource-manager/apimanagement/2021-08-01/cache/method_update_autorest.go +++ /dev/null @@ -1,98 +0,0 @@ -package cache - -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 *CacheContract -} - -type UpdateOperationOptions struct { - IfMatch *string -} - -func DefaultUpdateOperationOptions() UpdateOperationOptions { - return UpdateOperationOptions{} -} - -func (o UpdateOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o UpdateOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// Update ... -func (c CacheClient) Update(ctx context.Context, id CacheId, input CacheUpdateParameters, options UpdateOperationOptions) (result UpdateOperationResponse, err error) { - req, err := c.preparerForUpdate(ctx, id, input, options) - if err != nil { - err = autorest.NewErrorWithError(err, "cache.CacheClient", "Update", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "cache.CacheClient", "Update", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "cache.CacheClient", "Update", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForUpdate prepares the Update request. -func (c CacheClient) preparerForUpdate(ctx context.Context, id CacheId, input CacheUpdateParameters, options UpdateOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPatch(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - 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 CacheClient) 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/apimanagement/2021-08-01/certificate/client.go b/resource-manager/apimanagement/2021-08-01/certificate/client.go index f304bfc665d..d850a6c7fd7 100644 --- a/resource-manager/apimanagement/2021-08-01/certificate/client.go +++ b/resource-manager/apimanagement/2021-08-01/certificate/client.go @@ -1,18 +1,26 @@ package certificate -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 CertificateClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewCertificateClientWithBaseURI(endpoint string) CertificateClient { - return CertificateClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewCertificateClientWithBaseURI(api environments.Api) (*CertificateClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "certificate", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating CertificateClient: %+v", err) } + + return &CertificateClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2021-08-01/certificate/method_createorupdate.go b/resource-manager/apimanagement/2021-08-01/certificate/method_createorupdate.go new file mode 100644 index 00000000000..93fbccd7109 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/certificate/method_createorupdate.go @@ -0,0 +1,85 @@ +package certificate + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *CertificateContract +} + +type CreateOrUpdateOperationOptions struct { + IfMatch *string +} + +func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { + return CreateOrUpdateOperationOptions{} +} + +func (o CreateOrUpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o CreateOrUpdateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o CreateOrUpdateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// CreateOrUpdate ... +func (c CertificateClient) CreateOrUpdate(ctx context.Context, id CertificateId, input CertificateCreateOrUpdateParameters, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + OptionsObject: options, + } + + 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/apimanagement/2021-08-01/certificate/method_createorupdate_autorest.go b/resource-manager/apimanagement/2021-08-01/certificate/method_createorupdate_autorest.go deleted file mode 100644 index 3f9fa70c148..00000000000 --- a/resource-manager/apimanagement/2021-08-01/certificate/method_createorupdate_autorest.go +++ /dev/null @@ -1,98 +0,0 @@ -package certificate - -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 *CertificateContract -} - -type CreateOrUpdateOperationOptions struct { - IfMatch *string -} - -func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { - return CreateOrUpdateOperationOptions{} -} - -func (o CreateOrUpdateOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o CreateOrUpdateOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// CreateOrUpdate ... -func (c CertificateClient) CreateOrUpdate(ctx context.Context, id CertificateId, input CertificateCreateOrUpdateParameters, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdate(ctx, id, input, options) - if err != nil { - err = autorest.NewErrorWithError(err, "certificate.CertificateClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "certificate.CertificateClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCreateOrUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "certificate.CertificateClient", "CreateOrUpdate", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCreateOrUpdate prepares the CreateOrUpdate request. -func (c CertificateClient) preparerForCreateOrUpdate(ctx context.Context, id CertificateId, input CertificateCreateOrUpdateParameters, options CreateOrUpdateOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - 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 CertificateClient) responderForCreateOrUpdate(resp *http.Response) (result CreateOrUpdateOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2021-08-01/certificate/method_delete.go b/resource-manager/apimanagement/2021-08-01/certificate/method_delete.go new file mode 100644 index 00000000000..18be0e732de --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/certificate/method_delete.go @@ -0,0 +1,76 @@ +package certificate + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +type DeleteOperationOptions struct { + IfMatch *string +} + +func DefaultDeleteOperationOptions() DeleteOperationOptions { + return DeleteOperationOptions{} +} + +func (o DeleteOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o DeleteOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o DeleteOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// Delete ... +func (c CertificateClient) Delete(ctx context.Context, id CertificateId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2021-08-01/certificate/method_delete_autorest.go b/resource-manager/apimanagement/2021-08-01/certificate/method_delete_autorest.go deleted file mode 100644 index c5682ce3425..00000000000 --- a/resource-manager/apimanagement/2021-08-01/certificate/method_delete_autorest.go +++ /dev/null @@ -1,95 +0,0 @@ -package certificate - -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 DeleteOperationResponse struct { - HttpResponse *http.Response -} - -type DeleteOperationOptions struct { - IfMatch *string -} - -func DefaultDeleteOperationOptions() DeleteOperationOptions { - return DeleteOperationOptions{} -} - -func (o DeleteOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o DeleteOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// Delete ... -func (c CertificateClient) Delete(ctx context.Context, id CertificateId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { - req, err := c.preparerForDelete(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "certificate.CertificateClient", "Delete", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "certificate.CertificateClient", "Delete", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForDelete(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "certificate.CertificateClient", "Delete", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForDelete prepares the Delete request. -func (c CertificateClient) preparerForDelete(ctx context.Context, id CertificateId, options DeleteOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForDelete handles the response to the Delete request. The method always -// closes the http.Response Body. -func (c CertificateClient) responderForDelete(resp *http.Response) (result DeleteOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2021-08-01/certificate/method_get.go b/resource-manager/apimanagement/2021-08-01/certificate/method_get.go new file mode 100644 index 00000000000..27e5fbafdfa --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/certificate/method_get.go @@ -0,0 +1,51 @@ +package certificate + +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 *CertificateContract +} + +// Get ... +func (c CertificateClient) Get(ctx context.Context, id CertificateId) (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/apimanagement/2021-08-01/certificate/method_get_autorest.go b/resource-manager/apimanagement/2021-08-01/certificate/method_get_autorest.go deleted file mode 100644 index 9e737922fb6..00000000000 --- a/resource-manager/apimanagement/2021-08-01/certificate/method_get_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package certificate - -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 *CertificateContract -} - -// Get ... -func (c CertificateClient) Get(ctx context.Context, id CertificateId) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "certificate.CertificateClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "certificate.CertificateClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "certificate.CertificateClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c CertificateClient) preparerForGet(ctx context.Context, id CertificateId) (*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 CertificateClient) 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/apimanagement/2021-08-01/certificate/method_getentitytag.go b/resource-manager/apimanagement/2021-08-01/certificate/method_getentitytag.go new file mode 100644 index 00000000000..bcbd65b8f9b --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/certificate/method_getentitytag.go @@ -0,0 +1,46 @@ +package certificate + +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 GetEntityTagOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// GetEntityTag ... +func (c CertificateClient) GetEntityTag(ctx context.Context, id CertificateId) (result GetEntityTagOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodHead, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2021-08-01/certificate/method_getentitytag_autorest.go b/resource-manager/apimanagement/2021-08-01/certificate/method_getentitytag_autorest.go deleted file mode 100644 index 767706d23d9..00000000000 --- a/resource-manager/apimanagement/2021-08-01/certificate/method_getentitytag_autorest.go +++ /dev/null @@ -1,66 +0,0 @@ -package certificate - -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 GetEntityTagOperationResponse struct { - HttpResponse *http.Response -} - -// GetEntityTag ... -func (c CertificateClient) GetEntityTag(ctx context.Context, id CertificateId) (result GetEntityTagOperationResponse, err error) { - req, err := c.preparerForGetEntityTag(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "certificate.CertificateClient", "GetEntityTag", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "certificate.CertificateClient", "GetEntityTag", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetEntityTag(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "certificate.CertificateClient", "GetEntityTag", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetEntityTag prepares the GetEntityTag request. -func (c CertificateClient) preparerForGetEntityTag(ctx context.Context, id CertificateId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsHead(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetEntityTag handles the response to the GetEntityTag request. The method always -// closes the http.Response Body. -func (c CertificateClient) responderForGetEntityTag(resp *http.Response) (result GetEntityTagOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2021-08-01/certificate/method_listbyservice.go b/resource-manager/apimanagement/2021-08-01/certificate/method_listbyservice.go new file mode 100644 index 00000000000..cf5649185fc --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/certificate/method_listbyservice.go @@ -0,0 +1,129 @@ +package certificate + +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 ListByServiceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]CertificateContract +} + +type ListByServiceCompleteResult struct { + Items []CertificateContract +} + +type ListByServiceOperationOptions struct { + Filter *string + IsKeyVaultRefreshFailed *bool + Skip *int64 + Top *int64 +} + +func DefaultListByServiceOperationOptions() ListByServiceOperationOptions { + return ListByServiceOperationOptions{} +} + +func (o ListByServiceOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListByServiceOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListByServiceOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.IsKeyVaultRefreshFailed != nil { + out.Append("isKeyVaultRefreshFailed", fmt.Sprintf("%v", *o.IsKeyVaultRefreshFailed)) + } + if o.Skip != nil { + out.Append("$skip", fmt.Sprintf("%v", *o.Skip)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +// ListByService ... +func (c CertificateClient) ListByService(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (result ListByServiceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/certificates", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]CertificateContract `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByServiceComplete retrieves all the results into a single object +func (c CertificateClient) ListByServiceComplete(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (ListByServiceCompleteResult, error) { + return c.ListByServiceCompleteMatchingPredicate(ctx, id, options, CertificateContractOperationPredicate{}) +} + +// ListByServiceCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c CertificateClient) ListByServiceCompleteMatchingPredicate(ctx context.Context, id ServiceId, options ListByServiceOperationOptions, predicate CertificateContractOperationPredicate) (result ListByServiceCompleteResult, err error) { + items := make([]CertificateContract, 0) + + resp, err := c.ListByService(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByServiceCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/apimanagement/2021-08-01/certificate/method_listbyservice_autorest.go b/resource-manager/apimanagement/2021-08-01/certificate/method_listbyservice_autorest.go deleted file mode 100644 index b7ec6fe5728..00000000000 --- a/resource-manager/apimanagement/2021-08-01/certificate/method_listbyservice_autorest.go +++ /dev/null @@ -1,230 +0,0 @@ -package certificate - -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 ListByServiceOperationResponse struct { - HttpResponse *http.Response - Model *[]CertificateContract - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListByServiceOperationResponse, error) -} - -type ListByServiceCompleteResult struct { - Items []CertificateContract -} - -func (r ListByServiceOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListByServiceOperationResponse) LoadMore(ctx context.Context) (resp ListByServiceOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -type ListByServiceOperationOptions struct { - Filter *string - IsKeyVaultRefreshFailed *bool - Skip *int64 - Top *int64 -} - -func DefaultListByServiceOperationOptions() ListByServiceOperationOptions { - return ListByServiceOperationOptions{} -} - -func (o ListByServiceOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o ListByServiceOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Filter != nil { - out["$filter"] = *o.Filter - } - - if o.IsKeyVaultRefreshFailed != nil { - out["isKeyVaultRefreshFailed"] = *o.IsKeyVaultRefreshFailed - } - - if o.Skip != nil { - out["$skip"] = *o.Skip - } - - if o.Top != nil { - out["$top"] = *o.Top - } - - return out -} - -// ListByService ... -func (c CertificateClient) ListByService(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (resp ListByServiceOperationResponse, err error) { - req, err := c.preparerForListByService(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "certificate.CertificateClient", "ListByService", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "certificate.CertificateClient", "ListByService", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListByService(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "certificate.CertificateClient", "ListByService", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListByService prepares the ListByService request. -func (c CertificateClient) preparerForListByService(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/certificates", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListByServiceWithNextLink prepares the ListByService request with the given nextLink token. -func (c CertificateClient) preparerForListByServiceWithNextLink(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)) -} - -// responderForListByService handles the response to the ListByService request. The method always -// closes the http.Response Body. -func (c CertificateClient) responderForListByService(resp *http.Response) (result ListByServiceOperationResponse, err error) { - type page struct { - Values []CertificateContract `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 ListByServiceOperationResponse, err error) { - req, err := c.preparerForListByServiceWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "certificate.CertificateClient", "ListByService", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "certificate.CertificateClient", "ListByService", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByService(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "certificate.CertificateClient", "ListByService", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListByServiceComplete retrieves all of the results into a single object -func (c CertificateClient) ListByServiceComplete(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (ListByServiceCompleteResult, error) { - return c.ListByServiceCompleteMatchingPredicate(ctx, id, options, CertificateContractOperationPredicate{}) -} - -// ListByServiceCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c CertificateClient) ListByServiceCompleteMatchingPredicate(ctx context.Context, id ServiceId, options ListByServiceOperationOptions, predicate CertificateContractOperationPredicate) (resp ListByServiceCompleteResult, err error) { - items := make([]CertificateContract, 0) - - page, err := c.ListByService(ctx, id, options) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListByServiceCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/apimanagement/2021-08-01/certificate/method_refreshsecret.go b/resource-manager/apimanagement/2021-08-01/certificate/method_refreshsecret.go new file mode 100644 index 00000000000..8c7aaf79162 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/certificate/method_refreshsecret.go @@ -0,0 +1,52 @@ +package certificate + +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 RefreshSecretOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *CertificateContract +} + +// RefreshSecret ... +func (c CertificateClient) RefreshSecret(ctx context.Context, id CertificateId) (result RefreshSecretOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/refreshSecret", 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/apimanagement/2021-08-01/certificate/method_refreshsecret_autorest.go b/resource-manager/apimanagement/2021-08-01/certificate/method_refreshsecret_autorest.go deleted file mode 100644 index 8202c39a9c5..00000000000 --- a/resource-manager/apimanagement/2021-08-01/certificate/method_refreshsecret_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package certificate - -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 RefreshSecretOperationResponse struct { - HttpResponse *http.Response - Model *CertificateContract -} - -// RefreshSecret ... -func (c CertificateClient) RefreshSecret(ctx context.Context, id CertificateId) (result RefreshSecretOperationResponse, err error) { - req, err := c.preparerForRefreshSecret(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "certificate.CertificateClient", "RefreshSecret", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "certificate.CertificateClient", "RefreshSecret", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForRefreshSecret(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "certificate.CertificateClient", "RefreshSecret", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForRefreshSecret prepares the RefreshSecret request. -func (c CertificateClient) preparerForRefreshSecret(ctx context.Context, id CertificateId) (*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/refreshSecret", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForRefreshSecret handles the response to the RefreshSecret request. The method always -// closes the http.Response Body. -func (c CertificateClient) responderForRefreshSecret(resp *http.Response) (result RefreshSecretOperationResponse, 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/apimanagement/2021-08-01/client.go b/resource-manager/apimanagement/2021-08-01/client.go index 3128d58bf28..7f73ccbf6fa 100644 --- a/resource-manager/apimanagement/2021-08-01/client.go +++ b/resource-manager/apimanagement/2021-08-01/client.go @@ -4,7 +4,8 @@ package v2021_08_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/apimanagement/2021-08-01/api" "github.com/hashicorp/go-azure-sdk/resource-manager/apimanagement/2021-08-01/apidiagnostic" "github.com/hashicorp/go-azure-sdk/resource-manager/apimanagement/2021-08-01/apiissue" @@ -93,6 +94,8 @@ import ( "github.com/hashicorp/go-azure-sdk/resource-manager/apimanagement/2021-08-01/users" "github.com/hashicorp/go-azure-sdk/resource-manager/apimanagement/2021-08-01/usersubscription" "github.com/hashicorp/go-azure-sdk/resource-manager/apimanagement/2021-08-01/usertoken" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/environments" ) type Client struct { @@ -186,360 +189,623 @@ type Client struct { Users *users.UsersClient } -func NewClientWithBaseURI(endpoint string, configureAuthFunc func(c *autorest.Client)) Client { +func NewClientWithBaseURI(api environments.Api, configureFunc func(c *resourcemanager.Client)) (*Client, error) { + apiClient, err := api.NewApiClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building Api client: %+v", err) + } + configureFunc(apiClient.Client) - apiClient := api.NewApiClientWithBaseURI(endpoint) - configureAuthFunc(&apiClient.Client) + apiDiagnosticClient, err := apidiagnostic.NewApiDiagnosticClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building ApiDiagnostic client: %+v", err) + } + configureFunc(apiDiagnosticClient.Client) - apiDiagnosticClient := apidiagnostic.NewApiDiagnosticClientWithBaseURI(endpoint) - configureAuthFunc(&apiDiagnosticClient.Client) + apiIssueAttachmentClient, err := apiissueattachment.NewApiIssueAttachmentClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building ApiIssueAttachment client: %+v", err) + } + configureFunc(apiIssueAttachmentClient.Client) - apiIssueAttachmentClient := apiissueattachment.NewApiIssueAttachmentClientWithBaseURI(endpoint) - configureAuthFunc(&apiIssueAttachmentClient.Client) + apiIssueClient, err := apiissue.NewApiIssueClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building ApiIssue client: %+v", err) + } + configureFunc(apiIssueClient.Client) - apiIssueClient := apiissue.NewApiIssueClientWithBaseURI(endpoint) - configureAuthFunc(&apiIssueClient.Client) + apiIssueCommentClient, err := apiissuecomment.NewApiIssueCommentClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building ApiIssueComment client: %+v", err) + } + configureFunc(apiIssueCommentClient.Client) - apiIssueCommentClient := apiissuecomment.NewApiIssueCommentClientWithBaseURI(endpoint) - configureAuthFunc(&apiIssueCommentClient.Client) + apiManagementServiceClient, err := apimanagementservice.NewApiManagementServiceClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building ApiManagementService client: %+v", err) + } + configureFunc(apiManagementServiceClient.Client) - apiManagementServiceClient := apimanagementservice.NewApiManagementServiceClientWithBaseURI(endpoint) - configureAuthFunc(&apiManagementServiceClient.Client) + apiManagementServiceSkusClient, err := apimanagementserviceskus.NewApiManagementServiceSkusClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building ApiManagementServiceSkus client: %+v", err) + } + configureFunc(apiManagementServiceSkusClient.Client) + + apiOperationClient, err := apioperation.NewApiOperationClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building ApiOperation client: %+v", err) + } + configureFunc(apiOperationClient.Client) - apiManagementServiceSkusClient := apimanagementserviceskus.NewApiManagementServiceSkusClientWithBaseURI(endpoint) - configureAuthFunc(&apiManagementServiceSkusClient.Client) + apiOperationPolicyClient, err := apioperationpolicy.NewApiOperationPolicyClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building ApiOperationPolicy client: %+v", err) + } + configureFunc(apiOperationPolicyClient.Client) + + apiOperationTagClient, err := apioperationtag.NewApiOperationTagClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building ApiOperationTag client: %+v", err) + } + configureFunc(apiOperationTagClient.Client) - apiOperationClient := apioperation.NewApiOperationClientWithBaseURI(endpoint) - configureAuthFunc(&apiOperationClient.Client) + apiOperationsByTagClient, err := apioperationsbytag.NewApiOperationsByTagClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building ApiOperationsByTag client: %+v", err) + } + configureFunc(apiOperationsByTagClient.Client) - apiOperationPolicyClient := apioperationpolicy.NewApiOperationPolicyClientWithBaseURI(endpoint) - configureAuthFunc(&apiOperationPolicyClient.Client) + apiPolicyClient, err := apipolicy.NewApiPolicyClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building ApiPolicy client: %+v", err) + } + configureFunc(apiPolicyClient.Client) - apiOperationTagClient := apioperationtag.NewApiOperationTagClientWithBaseURI(endpoint) - configureAuthFunc(&apiOperationTagClient.Client) + apiProductClient, err := apiproduct.NewApiProductClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building ApiProduct client: %+v", err) + } + configureFunc(apiProductClient.Client) - apiOperationsByTagClient := apioperationsbytag.NewApiOperationsByTagClientWithBaseURI(endpoint) - configureAuthFunc(&apiOperationsByTagClient.Client) + apiReleaseClient, err := apirelease.NewApiReleaseClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building ApiRelease client: %+v", err) + } + configureFunc(apiReleaseClient.Client) - apiPolicyClient := apipolicy.NewApiPolicyClientWithBaseURI(endpoint) - configureAuthFunc(&apiPolicyClient.Client) + apiRevisionClient, err := apirevision.NewApiRevisionClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building ApiRevision client: %+v", err) + } + configureFunc(apiRevisionClient.Client) - apiProductClient := apiproduct.NewApiProductClientWithBaseURI(endpoint) - configureAuthFunc(&apiProductClient.Client) + apiSchemaClient, err := apischema.NewApiSchemaClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building ApiSchema client: %+v", err) + } + configureFunc(apiSchemaClient.Client) - apiReleaseClient := apirelease.NewApiReleaseClientWithBaseURI(endpoint) - configureAuthFunc(&apiReleaseClient.Client) + apiTagClient, err := apitag.NewApiTagClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building ApiTag client: %+v", err) + } + configureFunc(apiTagClient.Client) - apiRevisionClient := apirevision.NewApiRevisionClientWithBaseURI(endpoint) - configureAuthFunc(&apiRevisionClient.Client) + apiTagDescriptionClient, err := apitagdescription.NewApiTagDescriptionClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building ApiTagDescription client: %+v", err) + } + configureFunc(apiTagDescriptionClient.Client) - apiSchemaClient := apischema.NewApiSchemaClientWithBaseURI(endpoint) - configureAuthFunc(&apiSchemaClient.Client) + apiVersionSetClient, err := apiversionset.NewApiVersionSetClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building ApiVersionSet client: %+v", err) + } + configureFunc(apiVersionSetClient.Client) - apiTagClient := apitag.NewApiTagClientWithBaseURI(endpoint) - configureAuthFunc(&apiTagClient.Client) + apiVersionSetsClient, err := apiversionsets.NewApiVersionSetsClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building ApiVersionSets client: %+v", err) + } + configureFunc(apiVersionSetsClient.Client) - apiTagDescriptionClient := apitagdescription.NewApiTagDescriptionClientWithBaseURI(endpoint) - configureAuthFunc(&apiTagDescriptionClient.Client) + apisByTagClient, err := apisbytag.NewApisByTagClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building ApisByTag client: %+v", err) + } + configureFunc(apisByTagClient.Client) - apiVersionSetClient := apiversionset.NewApiVersionSetClientWithBaseURI(endpoint) - configureAuthFunc(&apiVersionSetClient.Client) + authorizationServerClient, err := authorizationserver.NewAuthorizationServerClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building AuthorizationServer client: %+v", err) + } + configureFunc(authorizationServerClient.Client) - apiVersionSetsClient := apiversionsets.NewApiVersionSetsClientWithBaseURI(endpoint) - configureAuthFunc(&apiVersionSetsClient.Client) + backendClient, err := backend.NewBackendClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building Backend client: %+v", err) + } + configureFunc(backendClient.Client) - apisByTagClient := apisbytag.NewApisByTagClientWithBaseURI(endpoint) - configureAuthFunc(&apisByTagClient.Client) + backendReconnectClient, err := backendreconnect.NewBackendReconnectClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building BackendReconnect client: %+v", err) + } + configureFunc(backendReconnectClient.Client) + + cacheClient, err := cache.NewCacheClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building Cache client: %+v", err) + } + configureFunc(cacheClient.Client) + + certificateClient, err := certificate.NewCertificateClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building Certificate client: %+v", err) + } + configureFunc(certificateClient.Client) + + contentTypeClient, err := contenttype.NewContentTypeClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building ContentType client: %+v", err) + } + configureFunc(contentTypeClient.Client) + + contentTypeContentItemClient, err := contenttypecontentitem.NewContentTypeContentItemClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building ContentTypeContentItem client: %+v", err) + } + configureFunc(contentTypeContentItemClient.Client) + + delegationSettingsClient, err := delegationsettings.NewDelegationSettingsClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building DelegationSettings client: %+v", err) + } + configureFunc(delegationSettingsClient.Client) + + deletedServiceClient, err := deletedservice.NewDeletedServiceClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building DeletedService client: %+v", err) + } + configureFunc(deletedServiceClient.Client) + + diagnosticClient, err := diagnostic.NewDiagnosticClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building Diagnostic client: %+v", err) + } + configureFunc(diagnosticClient.Client) + + emailTemplateClient, err := emailtemplate.NewEmailTemplateClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building EmailTemplate client: %+v", err) + } + configureFunc(emailTemplateClient.Client) + + emailTemplatesClient, err := emailtemplates.NewEmailTemplatesClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building EmailTemplates client: %+v", err) + } + configureFunc(emailTemplatesClient.Client) + + gatewayApiClient, err := gatewayapi.NewGatewayApiClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building GatewayApi client: %+v", err) + } + configureFunc(gatewayApiClient.Client) + + gatewayCertificateAuthorityClient, err := gatewaycertificateauthority.NewGatewayCertificateAuthorityClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building GatewayCertificateAuthority client: %+v", err) + } + configureFunc(gatewayCertificateAuthorityClient.Client) + + gatewayClient, err := gateway.NewGatewayClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building Gateway client: %+v", err) + } + configureFunc(gatewayClient.Client) - authorizationServerClient := authorizationserver.NewAuthorizationServerClientWithBaseURI(endpoint) - configureAuthFunc(&authorizationServerClient.Client) + gatewayGenerateTokenClient, err := gatewaygeneratetoken.NewGatewayGenerateTokenClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building GatewayGenerateToken client: %+v", err) + } + configureFunc(gatewayGenerateTokenClient.Client) - backendClient := backend.NewBackendClientWithBaseURI(endpoint) - configureAuthFunc(&backendClient.Client) + gatewayHostnameConfigurationClient, err := gatewayhostnameconfiguration.NewGatewayHostnameConfigurationClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building GatewayHostnameConfiguration client: %+v", err) + } + configureFunc(gatewayHostnameConfigurationClient.Client) - backendReconnectClient := backendreconnect.NewBackendReconnectClientWithBaseURI(endpoint) - configureAuthFunc(&backendReconnectClient.Client) + gatewayListKeysClient, err := gatewaylistkeys.NewGatewayListKeysClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building GatewayListKeys client: %+v", err) + } + configureFunc(gatewayListKeysClient.Client) - cacheClient := cache.NewCacheClientWithBaseURI(endpoint) - configureAuthFunc(&cacheClient.Client) + gatewayRegenerateKeyClient, err := gatewayregeneratekey.NewGatewayRegenerateKeyClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building GatewayRegenerateKey client: %+v", err) + } + configureFunc(gatewayRegenerateKeyClient.Client) - certificateClient := certificate.NewCertificateClientWithBaseURI(endpoint) - configureAuthFunc(&certificateClient.Client) + groupClient, err := group.NewGroupClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building Group client: %+v", err) + } + configureFunc(groupClient.Client) - contentTypeClient := contenttype.NewContentTypeClientWithBaseURI(endpoint) - configureAuthFunc(&contentTypeClient.Client) + groupUserClient, err := groupuser.NewGroupUserClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building GroupUser client: %+v", err) + } + configureFunc(groupUserClient.Client) - contentTypeContentItemClient := contenttypecontentitem.NewContentTypeContentItemClientWithBaseURI(endpoint) - configureAuthFunc(&contentTypeContentItemClient.Client) + identityProviderClient, err := identityprovider.NewIdentityProviderClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building IdentityProvider client: %+v", err) + } + configureFunc(identityProviderClient.Client) - delegationSettingsClient := delegationsettings.NewDelegationSettingsClientWithBaseURI(endpoint) - configureAuthFunc(&delegationSettingsClient.Client) + issueClient, err := issue.NewIssueClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building Issue client: %+v", err) + } + configureFunc(issueClient.Client) - deletedServiceClient := deletedservice.NewDeletedServiceClientWithBaseURI(endpoint) - configureAuthFunc(&deletedServiceClient.Client) + loggerClient, err := logger.NewLoggerClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building Logger client: %+v", err) + } + configureFunc(loggerClient.Client) - diagnosticClient := diagnostic.NewDiagnosticClientWithBaseURI(endpoint) - configureAuthFunc(&diagnosticClient.Client) + namedValueClient, err := namedvalue.NewNamedValueClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building NamedValue client: %+v", err) + } + configureFunc(namedValueClient.Client) - emailTemplateClient := emailtemplate.NewEmailTemplateClientWithBaseURI(endpoint) - configureAuthFunc(&emailTemplateClient.Client) + networkStatusClient, err := networkstatus.NewNetworkStatusClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building NetworkStatus client: %+v", err) + } + configureFunc(networkStatusClient.Client) - emailTemplatesClient := emailtemplates.NewEmailTemplatesClientWithBaseURI(endpoint) - configureAuthFunc(&emailTemplatesClient.Client) + notificationClient, err := notification.NewNotificationClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building Notification client: %+v", err) + } + configureFunc(notificationClient.Client) - gatewayApiClient := gatewayapi.NewGatewayApiClientWithBaseURI(endpoint) - configureAuthFunc(&gatewayApiClient.Client) + notificationRecipientEmailClient, err := notificationrecipientemail.NewNotificationRecipientEmailClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building NotificationRecipientEmail client: %+v", err) + } + configureFunc(notificationRecipientEmailClient.Client) - gatewayCertificateAuthorityClient := gatewaycertificateauthority.NewGatewayCertificateAuthorityClientWithBaseURI(endpoint) - configureAuthFunc(&gatewayCertificateAuthorityClient.Client) + notificationRecipientUserClient, err := notificationrecipientuser.NewNotificationRecipientUserClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building NotificationRecipientUser client: %+v", err) + } + configureFunc(notificationRecipientUserClient.Client) - gatewayClient := gateway.NewGatewayClientWithBaseURI(endpoint) - configureAuthFunc(&gatewayClient.Client) + openidConnectProviderClient, err := openidconnectprovider.NewOpenidConnectProviderClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building OpenidConnectProvider client: %+v", err) + } + configureFunc(openidConnectProviderClient.Client) - gatewayGenerateTokenClient := gatewaygeneratetoken.NewGatewayGenerateTokenClientWithBaseURI(endpoint) - configureAuthFunc(&gatewayGenerateTokenClient.Client) + outboundNetworkDependenciesEndpointsClient, err := outboundnetworkdependenciesendpoints.NewOutboundNetworkDependenciesEndpointsClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building OutboundNetworkDependenciesEndpoints client: %+v", err) + } + configureFunc(outboundNetworkDependenciesEndpointsClient.Client) - gatewayHostnameConfigurationClient := gatewayhostnameconfiguration.NewGatewayHostnameConfigurationClientWithBaseURI(endpoint) - configureAuthFunc(&gatewayHostnameConfigurationClient.Client) + performConnectivityCheckClient, err := performconnectivitycheck.NewPerformConnectivityCheckClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building PerformConnectivityCheck client: %+v", err) + } + configureFunc(performConnectivityCheckClient.Client) - gatewayListKeysClient := gatewaylistkeys.NewGatewayListKeysClientWithBaseURI(endpoint) - configureAuthFunc(&gatewayListKeysClient.Client) + policyClient, err := policy.NewPolicyClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building Policy client: %+v", err) + } + configureFunc(policyClient.Client) - gatewayRegenerateKeyClient := gatewayregeneratekey.NewGatewayRegenerateKeyClientWithBaseURI(endpoint) - configureAuthFunc(&gatewayRegenerateKeyClient.Client) + policyDescriptionClient, err := policydescription.NewPolicyDescriptionClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building PolicyDescription client: %+v", err) + } + configureFunc(policyDescriptionClient.Client) - groupClient := group.NewGroupClientWithBaseURI(endpoint) - configureAuthFunc(&groupClient.Client) + portalRevisionClient, err := portalrevision.NewPortalRevisionClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building PortalRevision client: %+v", err) + } + configureFunc(portalRevisionClient.Client) - groupUserClient := groupuser.NewGroupUserClientWithBaseURI(endpoint) - configureAuthFunc(&groupUserClient.Client) + portalSettingsClient, err := portalsettings.NewPortalSettingsClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building PortalSettings client: %+v", err) + } + configureFunc(portalSettingsClient.Client) - identityProviderClient := identityprovider.NewIdentityProviderClientWithBaseURI(endpoint) - configureAuthFunc(&identityProviderClient.Client) + privateEndpointConnectionsClient, err := privateendpointconnections.NewPrivateEndpointConnectionsClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building PrivateEndpointConnections client: %+v", err) + } + configureFunc(privateEndpointConnectionsClient.Client) - issueClient := issue.NewIssueClientWithBaseURI(endpoint) - configureAuthFunc(&issueClient.Client) + productApiClient, err := productapi.NewProductApiClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building ProductApi client: %+v", err) + } + configureFunc(productApiClient.Client) - loggerClient := logger.NewLoggerClientWithBaseURI(endpoint) - configureAuthFunc(&loggerClient.Client) + productClient, err := product.NewProductClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building Product client: %+v", err) + } + configureFunc(productClient.Client) - namedValueClient := namedvalue.NewNamedValueClientWithBaseURI(endpoint) - configureAuthFunc(&namedValueClient.Client) + productGroupClient, err := productgroup.NewProductGroupClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building ProductGroup client: %+v", err) + } + configureFunc(productGroupClient.Client) - networkStatusClient := networkstatus.NewNetworkStatusClientWithBaseURI(endpoint) - configureAuthFunc(&networkStatusClient.Client) + productPolicyClient, err := productpolicy.NewProductPolicyClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building ProductPolicy client: %+v", err) + } + configureFunc(productPolicyClient.Client) - notificationClient := notification.NewNotificationClientWithBaseURI(endpoint) - configureAuthFunc(¬ificationClient.Client) + productSubscriptionClient, err := productsubscription.NewProductSubscriptionClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building ProductSubscription client: %+v", err) + } + configureFunc(productSubscriptionClient.Client) - notificationRecipientEmailClient := notificationrecipientemail.NewNotificationRecipientEmailClientWithBaseURI(endpoint) - configureAuthFunc(¬ificationRecipientEmailClient.Client) + productTagClient, err := producttag.NewProductTagClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building ProductTag client: %+v", err) + } + configureFunc(productTagClient.Client) - notificationRecipientUserClient := notificationrecipientuser.NewNotificationRecipientUserClientWithBaseURI(endpoint) - configureAuthFunc(¬ificationRecipientUserClient.Client) + productsByTagClient, err := productsbytag.NewProductsByTagClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building ProductsByTag client: %+v", err) + } + configureFunc(productsByTagClient.Client) - openidConnectProviderClient := openidconnectprovider.NewOpenidConnectProviderClientWithBaseURI(endpoint) - configureAuthFunc(&openidConnectProviderClient.Client) + quotaByCounterKeysClient, err := quotabycounterkeys.NewQuotaByCounterKeysClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building QuotaByCounterKeys client: %+v", err) + } + configureFunc(quotaByCounterKeysClient.Client) - outboundNetworkDependenciesEndpointsClient := outboundnetworkdependenciesendpoints.NewOutboundNetworkDependenciesEndpointsClientWithBaseURI(endpoint) - configureAuthFunc(&outboundNetworkDependenciesEndpointsClient.Client) + quotaByPeriodKeysClient, err := quotabyperiodkeys.NewQuotaByPeriodKeysClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building QuotaByPeriodKeys client: %+v", err) + } + configureFunc(quotaByPeriodKeysClient.Client) - performConnectivityCheckClient := performconnectivitycheck.NewPerformConnectivityCheckClientWithBaseURI(endpoint) - configureAuthFunc(&performConnectivityCheckClient.Client) + regionClient, err := region.NewRegionClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building Region client: %+v", err) + } + configureFunc(regionClient.Client) - policyClient := policy.NewPolicyClientWithBaseURI(endpoint) - configureAuthFunc(&policyClient.Client) + reportsClient, err := reports.NewReportsClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building Reports client: %+v", err) + } + configureFunc(reportsClient.Client) - policyDescriptionClient := policydescription.NewPolicyDescriptionClientWithBaseURI(endpoint) - configureAuthFunc(&policyDescriptionClient.Client) + schemaClient, err := schema.NewSchemaClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building Schema client: %+v", err) + } + configureFunc(schemaClient.Client) - portalRevisionClient := portalrevision.NewPortalRevisionClientWithBaseURI(endpoint) - configureAuthFunc(&portalRevisionClient.Client) + signInSettingsClient, err := signinsettings.NewSignInSettingsClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building SignInSettings client: %+v", err) + } + configureFunc(signInSettingsClient.Client) - portalSettingsClient := portalsettings.NewPortalSettingsClientWithBaseURI(endpoint) - configureAuthFunc(&portalSettingsClient.Client) + signUpSettingsClient, err := signupsettings.NewSignUpSettingsClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building SignUpSettings client: %+v", err) + } + configureFunc(signUpSettingsClient.Client) - privateEndpointConnectionsClient := privateendpointconnections.NewPrivateEndpointConnectionsClientWithBaseURI(endpoint) - configureAuthFunc(&privateEndpointConnectionsClient.Client) + skusClient, err := skus.NewSkusClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building Skus client: %+v", err) + } + configureFunc(skusClient.Client) - productApiClient := productapi.NewProductApiClientWithBaseURI(endpoint) - configureAuthFunc(&productApiClient.Client) + subscriptionClient, err := subscription.NewSubscriptionClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building Subscription client: %+v", err) + } + configureFunc(subscriptionClient.Client) - productClient := product.NewProductClientWithBaseURI(endpoint) - configureAuthFunc(&productClient.Client) + tagClient, err := tag.NewTagClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building Tag client: %+v", err) + } + configureFunc(tagClient.Client) - productGroupClient := productgroup.NewProductGroupClientWithBaseURI(endpoint) - configureAuthFunc(&productGroupClient.Client) + tagResourceClient, err := tagresource.NewTagResourceClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building TagResource client: %+v", err) + } + configureFunc(tagResourceClient.Client) - productPolicyClient := productpolicy.NewProductPolicyClientWithBaseURI(endpoint) - configureAuthFunc(&productPolicyClient.Client) + tenantAccessClient, err := tenantaccess.NewTenantAccessClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building TenantAccess client: %+v", err) + } + configureFunc(tenantAccessClient.Client) - productSubscriptionClient := productsubscription.NewProductSubscriptionClientWithBaseURI(endpoint) - configureAuthFunc(&productSubscriptionClient.Client) + tenantAccessGitClient, err := tenantaccessgit.NewTenantAccessGitClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building TenantAccessGit client: %+v", err) + } + configureFunc(tenantAccessGitClient.Client) - productTagClient := producttag.NewProductTagClientWithBaseURI(endpoint) - configureAuthFunc(&productTagClient.Client) + tenantConfigurationClient, err := tenantconfiguration.NewTenantConfigurationClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building TenantConfiguration client: %+v", err) + } + configureFunc(tenantConfigurationClient.Client) - productsByTagClient := productsbytag.NewProductsByTagClientWithBaseURI(endpoint) - configureAuthFunc(&productsByTagClient.Client) + tenantConfigurationSyncStateClient, err := tenantconfigurationsyncstate.NewTenantConfigurationSyncStateClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building TenantConfigurationSyncState client: %+v", err) + } + configureFunc(tenantConfigurationSyncStateClient.Client) - quotaByCounterKeysClient := quotabycounterkeys.NewQuotaByCounterKeysClientWithBaseURI(endpoint) - configureAuthFunc("aByCounterKeysClient.Client) + tenantSettingsClient, err := tenantsettings.NewTenantSettingsClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building TenantSettings client: %+v", err) + } + configureFunc(tenantSettingsClient.Client) - quotaByPeriodKeysClient := quotabyperiodkeys.NewQuotaByPeriodKeysClientWithBaseURI(endpoint) - configureAuthFunc("aByPeriodKeysClient.Client) + userClient, err := user.NewUserClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building User client: %+v", err) + } + configureFunc(userClient.Client) - regionClient := region.NewRegionClientWithBaseURI(endpoint) - configureAuthFunc(®ionClient.Client) + userConfirmationPasswordSendClient, err := userconfirmationpasswordsend.NewUserConfirmationPasswordSendClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building UserConfirmationPasswordSend client: %+v", err) + } + configureFunc(userConfirmationPasswordSendClient.Client) - reportsClient := reports.NewReportsClientWithBaseURI(endpoint) - configureAuthFunc(&reportsClient.Client) + userGroupClient, err := usergroup.NewUserGroupClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building UserGroup client: %+v", err) + } + configureFunc(userGroupClient.Client) - schemaClient := schema.NewSchemaClientWithBaseURI(endpoint) - configureAuthFunc(&schemaClient.Client) + userIdentityClient, err := useridentity.NewUserIdentityClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building UserIdentity client: %+v", err) + } + configureFunc(userIdentityClient.Client) - signInSettingsClient := signinsettings.NewSignInSettingsClientWithBaseURI(endpoint) - configureAuthFunc(&signInSettingsClient.Client) + userSubscriptionClient, err := usersubscription.NewUserSubscriptionClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building UserSubscription client: %+v", err) + } + configureFunc(userSubscriptionClient.Client) - signUpSettingsClient := signupsettings.NewSignUpSettingsClientWithBaseURI(endpoint) - configureAuthFunc(&signUpSettingsClient.Client) + userTokenClient, err := usertoken.NewUserTokenClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building UserToken client: %+v", err) + } + configureFunc(userTokenClient.Client) - skusClient := skus.NewSkusClientWithBaseURI(endpoint) - configureAuthFunc(&skusClient.Client) - - subscriptionClient := subscription.NewSubscriptionClientWithBaseURI(endpoint) - configureAuthFunc(&subscriptionClient.Client) - - tagClient := tag.NewTagClientWithBaseURI(endpoint) - configureAuthFunc(&tagClient.Client) - - tagResourceClient := tagresource.NewTagResourceClientWithBaseURI(endpoint) - configureAuthFunc(&tagResourceClient.Client) - - tenantAccessClient := tenantaccess.NewTenantAccessClientWithBaseURI(endpoint) - configureAuthFunc(&tenantAccessClient.Client) - - tenantAccessGitClient := tenantaccessgit.NewTenantAccessGitClientWithBaseURI(endpoint) - configureAuthFunc(&tenantAccessGitClient.Client) - - tenantConfigurationClient := tenantconfiguration.NewTenantConfigurationClientWithBaseURI(endpoint) - configureAuthFunc(&tenantConfigurationClient.Client) - - tenantConfigurationSyncStateClient := tenantconfigurationsyncstate.NewTenantConfigurationSyncStateClientWithBaseURI(endpoint) - configureAuthFunc(&tenantConfigurationSyncStateClient.Client) - - tenantSettingsClient := tenantsettings.NewTenantSettingsClientWithBaseURI(endpoint) - configureAuthFunc(&tenantSettingsClient.Client) - - userClient := user.NewUserClientWithBaseURI(endpoint) - configureAuthFunc(&userClient.Client) - - userConfirmationPasswordSendClient := userconfirmationpasswordsend.NewUserConfirmationPasswordSendClientWithBaseURI(endpoint) - configureAuthFunc(&userConfirmationPasswordSendClient.Client) - - userGroupClient := usergroup.NewUserGroupClientWithBaseURI(endpoint) - configureAuthFunc(&userGroupClient.Client) - - userIdentityClient := useridentity.NewUserIdentityClientWithBaseURI(endpoint) - configureAuthFunc(&userIdentityClient.Client) - - userSubscriptionClient := usersubscription.NewUserSubscriptionClientWithBaseURI(endpoint) - configureAuthFunc(&userSubscriptionClient.Client) - - userTokenClient := usertoken.NewUserTokenClientWithBaseURI(endpoint) - configureAuthFunc(&userTokenClient.Client) - - usersClient := users.NewUsersClientWithBaseURI(endpoint) - configureAuthFunc(&usersClient.Client) - - return Client{ - Api: &apiClient, - ApiDiagnostic: &apiDiagnosticClient, - ApiIssue: &apiIssueClient, - ApiIssueAttachment: &apiIssueAttachmentClient, - ApiIssueComment: &apiIssueCommentClient, - ApiManagementService: &apiManagementServiceClient, - ApiManagementServiceSkus: &apiManagementServiceSkusClient, - ApiOperation: &apiOperationClient, - ApiOperationPolicy: &apiOperationPolicyClient, - ApiOperationTag: &apiOperationTagClient, - ApiOperationsByTag: &apiOperationsByTagClient, - ApiPolicy: &apiPolicyClient, - ApiProduct: &apiProductClient, - ApiRelease: &apiReleaseClient, - ApiRevision: &apiRevisionClient, - ApiSchema: &apiSchemaClient, - ApiTag: &apiTagClient, - ApiTagDescription: &apiTagDescriptionClient, - ApiVersionSet: &apiVersionSetClient, - ApiVersionSets: &apiVersionSetsClient, - ApisByTag: &apisByTagClient, - AuthorizationServer: &authorizationServerClient, - Backend: &backendClient, - BackendReconnect: &backendReconnectClient, - Cache: &cacheClient, - Certificate: &certificateClient, - ContentType: &contentTypeClient, - ContentTypeContentItem: &contentTypeContentItemClient, - DelegationSettings: &delegationSettingsClient, - DeletedService: &deletedServiceClient, - Diagnostic: &diagnosticClient, - EmailTemplate: &emailTemplateClient, - EmailTemplates: &emailTemplatesClient, - Gateway: &gatewayClient, - GatewayApi: &gatewayApiClient, - GatewayCertificateAuthority: &gatewayCertificateAuthorityClient, - GatewayGenerateToken: &gatewayGenerateTokenClient, - GatewayHostnameConfiguration: &gatewayHostnameConfigurationClient, - GatewayListKeys: &gatewayListKeysClient, - GatewayRegenerateKey: &gatewayRegenerateKeyClient, - Group: &groupClient, - GroupUser: &groupUserClient, - IdentityProvider: &identityProviderClient, - Issue: &issueClient, - Logger: &loggerClient, - NamedValue: &namedValueClient, - NetworkStatus: &networkStatusClient, - Notification: ¬ificationClient, - NotificationRecipientEmail: ¬ificationRecipientEmailClient, - NotificationRecipientUser: ¬ificationRecipientUserClient, - OpenidConnectProvider: &openidConnectProviderClient, - OutboundNetworkDependenciesEndpoints: &outboundNetworkDependenciesEndpointsClient, - PerformConnectivityCheck: &performConnectivityCheckClient, - Policy: &policyClient, - PolicyDescription: &policyDescriptionClient, - PortalRevision: &portalRevisionClient, - PortalSettings: &portalSettingsClient, - PrivateEndpointConnections: &privateEndpointConnectionsClient, - Product: &productClient, - ProductApi: &productApiClient, - ProductGroup: &productGroupClient, - ProductPolicy: &productPolicyClient, - ProductSubscription: &productSubscriptionClient, - ProductTag: &productTagClient, - ProductsByTag: &productsByTagClient, - QuotaByCounterKeys: "aByCounterKeysClient, - QuotaByPeriodKeys: "aByPeriodKeysClient, - Region: ®ionClient, - Reports: &reportsClient, - Schema: &schemaClient, - SignInSettings: &signInSettingsClient, - SignUpSettings: &signUpSettingsClient, - Skus: &skusClient, - Subscription: &subscriptionClient, - Tag: &tagClient, - TagResource: &tagResourceClient, - TenantAccess: &tenantAccessClient, - TenantAccessGit: &tenantAccessGitClient, - TenantConfiguration: &tenantConfigurationClient, - TenantConfigurationSyncState: &tenantConfigurationSyncStateClient, - TenantSettings: &tenantSettingsClient, - User: &userClient, - UserConfirmationPasswordSend: &userConfirmationPasswordSendClient, - UserGroup: &userGroupClient, - UserIdentity: &userIdentityClient, - UserSubscription: &userSubscriptionClient, - UserToken: &userTokenClient, - Users: &usersClient, + usersClient, err := users.NewUsersClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building Users client: %+v", err) } + configureFunc(usersClient.Client) + + return &Client{ + Api: apiClient, + ApiDiagnostic: apiDiagnosticClient, + ApiIssue: apiIssueClient, + ApiIssueAttachment: apiIssueAttachmentClient, + ApiIssueComment: apiIssueCommentClient, + ApiManagementService: apiManagementServiceClient, + ApiManagementServiceSkus: apiManagementServiceSkusClient, + ApiOperation: apiOperationClient, + ApiOperationPolicy: apiOperationPolicyClient, + ApiOperationTag: apiOperationTagClient, + ApiOperationsByTag: apiOperationsByTagClient, + ApiPolicy: apiPolicyClient, + ApiProduct: apiProductClient, + ApiRelease: apiReleaseClient, + ApiRevision: apiRevisionClient, + ApiSchema: apiSchemaClient, + ApiTag: apiTagClient, + ApiTagDescription: apiTagDescriptionClient, + ApiVersionSet: apiVersionSetClient, + ApiVersionSets: apiVersionSetsClient, + ApisByTag: apisByTagClient, + AuthorizationServer: authorizationServerClient, + Backend: backendClient, + BackendReconnect: backendReconnectClient, + Cache: cacheClient, + Certificate: certificateClient, + ContentType: contentTypeClient, + ContentTypeContentItem: contentTypeContentItemClient, + DelegationSettings: delegationSettingsClient, + DeletedService: deletedServiceClient, + Diagnostic: diagnosticClient, + EmailTemplate: emailTemplateClient, + EmailTemplates: emailTemplatesClient, + Gateway: gatewayClient, + GatewayApi: gatewayApiClient, + GatewayCertificateAuthority: gatewayCertificateAuthorityClient, + GatewayGenerateToken: gatewayGenerateTokenClient, + GatewayHostnameConfiguration: gatewayHostnameConfigurationClient, + GatewayListKeys: gatewayListKeysClient, + GatewayRegenerateKey: gatewayRegenerateKeyClient, + Group: groupClient, + GroupUser: groupUserClient, + IdentityProvider: identityProviderClient, + Issue: issueClient, + Logger: loggerClient, + NamedValue: namedValueClient, + NetworkStatus: networkStatusClient, + Notification: notificationClient, + NotificationRecipientEmail: notificationRecipientEmailClient, + NotificationRecipientUser: notificationRecipientUserClient, + OpenidConnectProvider: openidConnectProviderClient, + OutboundNetworkDependenciesEndpoints: outboundNetworkDependenciesEndpointsClient, + PerformConnectivityCheck: performConnectivityCheckClient, + Policy: policyClient, + PolicyDescription: policyDescriptionClient, + PortalRevision: portalRevisionClient, + PortalSettings: portalSettingsClient, + PrivateEndpointConnections: privateEndpointConnectionsClient, + Product: productClient, + ProductApi: productApiClient, + ProductGroup: productGroupClient, + ProductPolicy: productPolicyClient, + ProductSubscription: productSubscriptionClient, + ProductTag: productTagClient, + ProductsByTag: productsByTagClient, + QuotaByCounterKeys: quotaByCounterKeysClient, + QuotaByPeriodKeys: quotaByPeriodKeysClient, + Region: regionClient, + Reports: reportsClient, + Schema: schemaClient, + SignInSettings: signInSettingsClient, + SignUpSettings: signUpSettingsClient, + Skus: skusClient, + Subscription: subscriptionClient, + Tag: tagClient, + TagResource: tagResourceClient, + TenantAccess: tenantAccessClient, + TenantAccessGit: tenantAccessGitClient, + TenantConfiguration: tenantConfigurationClient, + TenantConfigurationSyncState: tenantConfigurationSyncStateClient, + TenantSettings: tenantSettingsClient, + User: userClient, + UserConfirmationPasswordSend: userConfirmationPasswordSendClient, + UserGroup: userGroupClient, + UserIdentity: userIdentityClient, + UserSubscription: userSubscriptionClient, + UserToken: userTokenClient, + Users: usersClient, + }, nil } diff --git a/resource-manager/apimanagement/2021-08-01/contenttype/client.go b/resource-manager/apimanagement/2021-08-01/contenttype/client.go index ad798035bab..b5de661e117 100644 --- a/resource-manager/apimanagement/2021-08-01/contenttype/client.go +++ b/resource-manager/apimanagement/2021-08-01/contenttype/client.go @@ -1,18 +1,26 @@ package contenttype -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 ContentTypeClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewContentTypeClientWithBaseURI(endpoint string) ContentTypeClient { - return ContentTypeClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewContentTypeClientWithBaseURI(api environments.Api) (*ContentTypeClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "contenttype", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ContentTypeClient: %+v", err) } + + return &ContentTypeClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2021-08-01/contenttype/method_createorupdate.go b/resource-manager/apimanagement/2021-08-01/contenttype/method_createorupdate.go new file mode 100644 index 00000000000..777eb60bb34 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/contenttype/method_createorupdate.go @@ -0,0 +1,85 @@ +package contenttype + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ContentTypeContract +} + +type CreateOrUpdateOperationOptions struct { + IfMatch *string +} + +func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { + return CreateOrUpdateOperationOptions{} +} + +func (o CreateOrUpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o CreateOrUpdateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o CreateOrUpdateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// CreateOrUpdate ... +func (c ContentTypeClient) CreateOrUpdate(ctx context.Context, id ContentTypeId, input ContentTypeContract, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + OptionsObject: options, + } + + 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/apimanagement/2021-08-01/contenttype/method_createorupdate_autorest.go b/resource-manager/apimanagement/2021-08-01/contenttype/method_createorupdate_autorest.go deleted file mode 100644 index 7e7af790b98..00000000000 --- a/resource-manager/apimanagement/2021-08-01/contenttype/method_createorupdate_autorest.go +++ /dev/null @@ -1,98 +0,0 @@ -package contenttype - -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 *ContentTypeContract -} - -type CreateOrUpdateOperationOptions struct { - IfMatch *string -} - -func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { - return CreateOrUpdateOperationOptions{} -} - -func (o CreateOrUpdateOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o CreateOrUpdateOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// CreateOrUpdate ... -func (c ContentTypeClient) CreateOrUpdate(ctx context.Context, id ContentTypeId, input ContentTypeContract, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdate(ctx, id, input, options) - if err != nil { - err = autorest.NewErrorWithError(err, "contenttype.ContentTypeClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "contenttype.ContentTypeClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCreateOrUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "contenttype.ContentTypeClient", "CreateOrUpdate", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCreateOrUpdate prepares the CreateOrUpdate request. -func (c ContentTypeClient) preparerForCreateOrUpdate(ctx context.Context, id ContentTypeId, input ContentTypeContract, options CreateOrUpdateOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - 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 ContentTypeClient) responderForCreateOrUpdate(resp *http.Response) (result CreateOrUpdateOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2021-08-01/contenttype/method_delete.go b/resource-manager/apimanagement/2021-08-01/contenttype/method_delete.go new file mode 100644 index 00000000000..5a87b291973 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/contenttype/method_delete.go @@ -0,0 +1,76 @@ +package contenttype + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +type DeleteOperationOptions struct { + IfMatch *string +} + +func DefaultDeleteOperationOptions() DeleteOperationOptions { + return DeleteOperationOptions{} +} + +func (o DeleteOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o DeleteOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o DeleteOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// Delete ... +func (c ContentTypeClient) Delete(ctx context.Context, id ContentTypeId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2021-08-01/contenttype/method_delete_autorest.go b/resource-manager/apimanagement/2021-08-01/contenttype/method_delete_autorest.go deleted file mode 100644 index c67c198a0f2..00000000000 --- a/resource-manager/apimanagement/2021-08-01/contenttype/method_delete_autorest.go +++ /dev/null @@ -1,95 +0,0 @@ -package contenttype - -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 DeleteOperationResponse struct { - HttpResponse *http.Response -} - -type DeleteOperationOptions struct { - IfMatch *string -} - -func DefaultDeleteOperationOptions() DeleteOperationOptions { - return DeleteOperationOptions{} -} - -func (o DeleteOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o DeleteOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// Delete ... -func (c ContentTypeClient) Delete(ctx context.Context, id ContentTypeId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { - req, err := c.preparerForDelete(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "contenttype.ContentTypeClient", "Delete", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "contenttype.ContentTypeClient", "Delete", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForDelete(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "contenttype.ContentTypeClient", "Delete", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForDelete prepares the Delete request. -func (c ContentTypeClient) preparerForDelete(ctx context.Context, id ContentTypeId, options DeleteOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForDelete handles the response to the Delete request. The method always -// closes the http.Response Body. -func (c ContentTypeClient) responderForDelete(resp *http.Response) (result DeleteOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2021-08-01/contenttype/method_get.go b/resource-manager/apimanagement/2021-08-01/contenttype/method_get.go new file mode 100644 index 00000000000..45f141d65b2 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/contenttype/method_get.go @@ -0,0 +1,51 @@ +package contenttype + +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 *ContentTypeContract +} + +// Get ... +func (c ContentTypeClient) Get(ctx context.Context, id ContentTypeId) (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/apimanagement/2021-08-01/contenttype/method_get_autorest.go b/resource-manager/apimanagement/2021-08-01/contenttype/method_get_autorest.go deleted file mode 100644 index ffff3ebdfb5..00000000000 --- a/resource-manager/apimanagement/2021-08-01/contenttype/method_get_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package contenttype - -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 *ContentTypeContract -} - -// Get ... -func (c ContentTypeClient) Get(ctx context.Context, id ContentTypeId) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "contenttype.ContentTypeClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "contenttype.ContentTypeClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "contenttype.ContentTypeClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c ContentTypeClient) preparerForGet(ctx context.Context, id ContentTypeId) (*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 ContentTypeClient) 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/apimanagement/2021-08-01/contenttype/method_listbyservice.go b/resource-manager/apimanagement/2021-08-01/contenttype/method_listbyservice.go new file mode 100644 index 00000000000..3a6d95c44ce --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/contenttype/method_listbyservice.go @@ -0,0 +1,89 @@ +package contenttype + +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 ListByServiceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ContentTypeContract +} + +type ListByServiceCompleteResult struct { + Items []ContentTypeContract +} + +// ListByService ... +func (c ContentTypeClient) ListByService(ctx context.Context, id ServiceId) (result ListByServiceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/contentTypes", 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 *[]ContentTypeContract `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByServiceComplete retrieves all the results into a single object +func (c ContentTypeClient) ListByServiceComplete(ctx context.Context, id ServiceId) (ListByServiceCompleteResult, error) { + return c.ListByServiceCompleteMatchingPredicate(ctx, id, ContentTypeContractOperationPredicate{}) +} + +// ListByServiceCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ContentTypeClient) ListByServiceCompleteMatchingPredicate(ctx context.Context, id ServiceId, predicate ContentTypeContractOperationPredicate) (result ListByServiceCompleteResult, err error) { + items := make([]ContentTypeContract, 0) + + resp, err := c.ListByService(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 = ListByServiceCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/apimanagement/2021-08-01/contenttype/method_listbyservice_autorest.go b/resource-manager/apimanagement/2021-08-01/contenttype/method_listbyservice_autorest.go deleted file mode 100644 index 80dfbe9830a..00000000000 --- a/resource-manager/apimanagement/2021-08-01/contenttype/method_listbyservice_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package contenttype - -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 ListByServiceOperationResponse struct { - HttpResponse *http.Response - Model *[]ContentTypeContract - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListByServiceOperationResponse, error) -} - -type ListByServiceCompleteResult struct { - Items []ContentTypeContract -} - -func (r ListByServiceOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListByServiceOperationResponse) LoadMore(ctx context.Context) (resp ListByServiceOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListByService ... -func (c ContentTypeClient) ListByService(ctx context.Context, id ServiceId) (resp ListByServiceOperationResponse, err error) { - req, err := c.preparerForListByService(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "contenttype.ContentTypeClient", "ListByService", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "contenttype.ContentTypeClient", "ListByService", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListByService(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "contenttype.ContentTypeClient", "ListByService", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListByService prepares the ListByService request. -func (c ContentTypeClient) preparerForListByService(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(fmt.Sprintf("%s/contentTypes", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListByServiceWithNextLink prepares the ListByService request with the given nextLink token. -func (c ContentTypeClient) preparerForListByServiceWithNextLink(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)) -} - -// responderForListByService handles the response to the ListByService request. The method always -// closes the http.Response Body. -func (c ContentTypeClient) responderForListByService(resp *http.Response) (result ListByServiceOperationResponse, err error) { - type page struct { - Values []ContentTypeContract `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 ListByServiceOperationResponse, err error) { - req, err := c.preparerForListByServiceWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "contenttype.ContentTypeClient", "ListByService", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "contenttype.ContentTypeClient", "ListByService", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByService(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "contenttype.ContentTypeClient", "ListByService", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListByServiceComplete retrieves all of the results into a single object -func (c ContentTypeClient) ListByServiceComplete(ctx context.Context, id ServiceId) (ListByServiceCompleteResult, error) { - return c.ListByServiceCompleteMatchingPredicate(ctx, id, ContentTypeContractOperationPredicate{}) -} - -// ListByServiceCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c ContentTypeClient) ListByServiceCompleteMatchingPredicate(ctx context.Context, id ServiceId, predicate ContentTypeContractOperationPredicate) (resp ListByServiceCompleteResult, err error) { - items := make([]ContentTypeContract, 0) - - page, err := c.ListByService(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 := ListByServiceCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/apimanagement/2021-08-01/contenttypecontentitem/client.go b/resource-manager/apimanagement/2021-08-01/contenttypecontentitem/client.go index 89ca6821ddb..c927b66bbf1 100644 --- a/resource-manager/apimanagement/2021-08-01/contenttypecontentitem/client.go +++ b/resource-manager/apimanagement/2021-08-01/contenttypecontentitem/client.go @@ -1,18 +1,26 @@ package contenttypecontentitem -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 ContentTypeContentItemClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewContentTypeContentItemClientWithBaseURI(endpoint string) ContentTypeContentItemClient { - return ContentTypeContentItemClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewContentTypeContentItemClientWithBaseURI(api environments.Api) (*ContentTypeContentItemClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "contenttypecontentitem", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ContentTypeContentItemClient: %+v", err) } + + return &ContentTypeContentItemClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2021-08-01/contenttypecontentitem/method_contentitemcreateorupdate.go b/resource-manager/apimanagement/2021-08-01/contenttypecontentitem/method_contentitemcreateorupdate.go new file mode 100644 index 00000000000..f64c33e51f2 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/contenttypecontentitem/method_contentitemcreateorupdate.go @@ -0,0 +1,85 @@ +package contenttypecontentitem + +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 ContentItemCreateOrUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ContentItemContract +} + +type ContentItemCreateOrUpdateOperationOptions struct { + IfMatch *string +} + +func DefaultContentItemCreateOrUpdateOperationOptions() ContentItemCreateOrUpdateOperationOptions { + return ContentItemCreateOrUpdateOperationOptions{} +} + +func (o ContentItemCreateOrUpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o ContentItemCreateOrUpdateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ContentItemCreateOrUpdateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// ContentItemCreateOrUpdate ... +func (c ContentTypeContentItemClient) ContentItemCreateOrUpdate(ctx context.Context, id ContentItemId, input ContentItemContract, options ContentItemCreateOrUpdateOperationOptions) (result ContentItemCreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + OptionsObject: options, + } + + 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/apimanagement/2021-08-01/contenttypecontentitem/method_contentitemcreateorupdate_autorest.go b/resource-manager/apimanagement/2021-08-01/contenttypecontentitem/method_contentitemcreateorupdate_autorest.go deleted file mode 100644 index 74712be0162..00000000000 --- a/resource-manager/apimanagement/2021-08-01/contenttypecontentitem/method_contentitemcreateorupdate_autorest.go +++ /dev/null @@ -1,98 +0,0 @@ -package contenttypecontentitem - -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 ContentItemCreateOrUpdateOperationResponse struct { - HttpResponse *http.Response - Model *ContentItemContract -} - -type ContentItemCreateOrUpdateOperationOptions struct { - IfMatch *string -} - -func DefaultContentItemCreateOrUpdateOperationOptions() ContentItemCreateOrUpdateOperationOptions { - return ContentItemCreateOrUpdateOperationOptions{} -} - -func (o ContentItemCreateOrUpdateOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o ContentItemCreateOrUpdateOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// ContentItemCreateOrUpdate ... -func (c ContentTypeContentItemClient) ContentItemCreateOrUpdate(ctx context.Context, id ContentItemId, input ContentItemContract, options ContentItemCreateOrUpdateOperationOptions) (result ContentItemCreateOrUpdateOperationResponse, err error) { - req, err := c.preparerForContentItemCreateOrUpdate(ctx, id, input, options) - if err != nil { - err = autorest.NewErrorWithError(err, "contenttypecontentitem.ContentTypeContentItemClient", "ContentItemCreateOrUpdate", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "contenttypecontentitem.ContentTypeContentItemClient", "ContentItemCreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForContentItemCreateOrUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "contenttypecontentitem.ContentTypeContentItemClient", "ContentItemCreateOrUpdate", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForContentItemCreateOrUpdate prepares the ContentItemCreateOrUpdate request. -func (c ContentTypeContentItemClient) preparerForContentItemCreateOrUpdate(ctx context.Context, id ContentItemId, input ContentItemContract, options ContentItemCreateOrUpdateOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForContentItemCreateOrUpdate handles the response to the ContentItemCreateOrUpdate request. The method always -// closes the http.Response Body. -func (c ContentTypeContentItemClient) responderForContentItemCreateOrUpdate(resp *http.Response) (result ContentItemCreateOrUpdateOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2021-08-01/contenttypecontentitem/method_contentitemdelete.go b/resource-manager/apimanagement/2021-08-01/contenttypecontentitem/method_contentitemdelete.go new file mode 100644 index 00000000000..5b8b348a02c --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/contenttypecontentitem/method_contentitemdelete.go @@ -0,0 +1,76 @@ +package contenttypecontentitem + +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 ContentItemDeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +type ContentItemDeleteOperationOptions struct { + IfMatch *string +} + +func DefaultContentItemDeleteOperationOptions() ContentItemDeleteOperationOptions { + return ContentItemDeleteOperationOptions{} +} + +func (o ContentItemDeleteOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o ContentItemDeleteOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ContentItemDeleteOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// ContentItemDelete ... +func (c ContentTypeContentItemClient) ContentItemDelete(ctx context.Context, id ContentItemId, options ContentItemDeleteOperationOptions) (result ContentItemDeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2021-08-01/contenttypecontentitem/method_contentitemdelete_autorest.go b/resource-manager/apimanagement/2021-08-01/contenttypecontentitem/method_contentitemdelete_autorest.go deleted file mode 100644 index 701903e5664..00000000000 --- a/resource-manager/apimanagement/2021-08-01/contenttypecontentitem/method_contentitemdelete_autorest.go +++ /dev/null @@ -1,95 +0,0 @@ -package contenttypecontentitem - -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 ContentItemDeleteOperationResponse struct { - HttpResponse *http.Response -} - -type ContentItemDeleteOperationOptions struct { - IfMatch *string -} - -func DefaultContentItemDeleteOperationOptions() ContentItemDeleteOperationOptions { - return ContentItemDeleteOperationOptions{} -} - -func (o ContentItemDeleteOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o ContentItemDeleteOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// ContentItemDelete ... -func (c ContentTypeContentItemClient) ContentItemDelete(ctx context.Context, id ContentItemId, options ContentItemDeleteOperationOptions) (result ContentItemDeleteOperationResponse, err error) { - req, err := c.preparerForContentItemDelete(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "contenttypecontentitem.ContentTypeContentItemClient", "ContentItemDelete", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "contenttypecontentitem.ContentTypeContentItemClient", "ContentItemDelete", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForContentItemDelete(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "contenttypecontentitem.ContentTypeContentItemClient", "ContentItemDelete", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForContentItemDelete prepares the ContentItemDelete request. -func (c ContentTypeContentItemClient) preparerForContentItemDelete(ctx context.Context, id ContentItemId, options ContentItemDeleteOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForContentItemDelete handles the response to the ContentItemDelete request. The method always -// closes the http.Response Body. -func (c ContentTypeContentItemClient) responderForContentItemDelete(resp *http.Response) (result ContentItemDeleteOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2021-08-01/contenttypecontentitem/method_contentitemget.go b/resource-manager/apimanagement/2021-08-01/contenttypecontentitem/method_contentitemget.go new file mode 100644 index 00000000000..8ea76ef555d --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/contenttypecontentitem/method_contentitemget.go @@ -0,0 +1,51 @@ +package contenttypecontentitem + +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 ContentItemGetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ContentItemContract +} + +// ContentItemGet ... +func (c ContentTypeContentItemClient) ContentItemGet(ctx context.Context, id ContentItemId) (result ContentItemGetOperationResponse, 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/apimanagement/2021-08-01/contenttypecontentitem/method_contentitemget_autorest.go b/resource-manager/apimanagement/2021-08-01/contenttypecontentitem/method_contentitemget_autorest.go deleted file mode 100644 index efbe49d07d9..00000000000 --- a/resource-manager/apimanagement/2021-08-01/contenttypecontentitem/method_contentitemget_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package contenttypecontentitem - -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 ContentItemGetOperationResponse struct { - HttpResponse *http.Response - Model *ContentItemContract -} - -// ContentItemGet ... -func (c ContentTypeContentItemClient) ContentItemGet(ctx context.Context, id ContentItemId) (result ContentItemGetOperationResponse, err error) { - req, err := c.preparerForContentItemGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "contenttypecontentitem.ContentTypeContentItemClient", "ContentItemGet", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "contenttypecontentitem.ContentTypeContentItemClient", "ContentItemGet", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForContentItemGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "contenttypecontentitem.ContentTypeContentItemClient", "ContentItemGet", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForContentItemGet prepares the ContentItemGet request. -func (c ContentTypeContentItemClient) preparerForContentItemGet(ctx context.Context, id ContentItemId) (*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)) -} - -// responderForContentItemGet handles the response to the ContentItemGet request. The method always -// closes the http.Response Body. -func (c ContentTypeContentItemClient) responderForContentItemGet(resp *http.Response) (result ContentItemGetOperationResponse, 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/apimanagement/2021-08-01/contenttypecontentitem/method_contentitemgetentitytag.go b/resource-manager/apimanagement/2021-08-01/contenttypecontentitem/method_contentitemgetentitytag.go new file mode 100644 index 00000000000..072a373e255 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/contenttypecontentitem/method_contentitemgetentitytag.go @@ -0,0 +1,46 @@ +package contenttypecontentitem + +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 ContentItemGetEntityTagOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// ContentItemGetEntityTag ... +func (c ContentTypeContentItemClient) ContentItemGetEntityTag(ctx context.Context, id ContentItemId) (result ContentItemGetEntityTagOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodHead, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2021-08-01/contenttypecontentitem/method_contentitemgetentitytag_autorest.go b/resource-manager/apimanagement/2021-08-01/contenttypecontentitem/method_contentitemgetentitytag_autorest.go deleted file mode 100644 index b6ba07420c2..00000000000 --- a/resource-manager/apimanagement/2021-08-01/contenttypecontentitem/method_contentitemgetentitytag_autorest.go +++ /dev/null @@ -1,66 +0,0 @@ -package contenttypecontentitem - -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 ContentItemGetEntityTagOperationResponse struct { - HttpResponse *http.Response -} - -// ContentItemGetEntityTag ... -func (c ContentTypeContentItemClient) ContentItemGetEntityTag(ctx context.Context, id ContentItemId) (result ContentItemGetEntityTagOperationResponse, err error) { - req, err := c.preparerForContentItemGetEntityTag(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "contenttypecontentitem.ContentTypeContentItemClient", "ContentItemGetEntityTag", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "contenttypecontentitem.ContentTypeContentItemClient", "ContentItemGetEntityTag", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForContentItemGetEntityTag(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "contenttypecontentitem.ContentTypeContentItemClient", "ContentItemGetEntityTag", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForContentItemGetEntityTag prepares the ContentItemGetEntityTag request. -func (c ContentTypeContentItemClient) preparerForContentItemGetEntityTag(ctx context.Context, id ContentItemId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsHead(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForContentItemGetEntityTag handles the response to the ContentItemGetEntityTag request. The method always -// closes the http.Response Body. -func (c ContentTypeContentItemClient) responderForContentItemGetEntityTag(resp *http.Response) (result ContentItemGetEntityTagOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2021-08-01/contenttypecontentitem/method_contentitemlistbyservice.go b/resource-manager/apimanagement/2021-08-01/contenttypecontentitem/method_contentitemlistbyservice.go new file mode 100644 index 00000000000..8e83525cd40 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/contenttypecontentitem/method_contentitemlistbyservice.go @@ -0,0 +1,89 @@ +package contenttypecontentitem + +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 ContentItemListByServiceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ContentItemContract +} + +type ContentItemListByServiceCompleteResult struct { + Items []ContentItemContract +} + +// ContentItemListByService ... +func (c ContentTypeContentItemClient) ContentItemListByService(ctx context.Context, id ContentTypeId) (result ContentItemListByServiceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/contentItems", 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 *[]ContentItemContract `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ContentItemListByServiceComplete retrieves all the results into a single object +func (c ContentTypeContentItemClient) ContentItemListByServiceComplete(ctx context.Context, id ContentTypeId) (ContentItemListByServiceCompleteResult, error) { + return c.ContentItemListByServiceCompleteMatchingPredicate(ctx, id, ContentItemContractOperationPredicate{}) +} + +// ContentItemListByServiceCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ContentTypeContentItemClient) ContentItemListByServiceCompleteMatchingPredicate(ctx context.Context, id ContentTypeId, predicate ContentItemContractOperationPredicate) (result ContentItemListByServiceCompleteResult, err error) { + items := make([]ContentItemContract, 0) + + resp, err := c.ContentItemListByService(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 = ContentItemListByServiceCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/apimanagement/2021-08-01/contenttypecontentitem/method_contentitemlistbyservice_autorest.go b/resource-manager/apimanagement/2021-08-01/contenttypecontentitem/method_contentitemlistbyservice_autorest.go deleted file mode 100644 index 4a4be76da22..00000000000 --- a/resource-manager/apimanagement/2021-08-01/contenttypecontentitem/method_contentitemlistbyservice_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package contenttypecontentitem - -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 ContentItemListByServiceOperationResponse struct { - HttpResponse *http.Response - Model *[]ContentItemContract - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ContentItemListByServiceOperationResponse, error) -} - -type ContentItemListByServiceCompleteResult struct { - Items []ContentItemContract -} - -func (r ContentItemListByServiceOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ContentItemListByServiceOperationResponse) LoadMore(ctx context.Context) (resp ContentItemListByServiceOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ContentItemListByService ... -func (c ContentTypeContentItemClient) ContentItemListByService(ctx context.Context, id ContentTypeId) (resp ContentItemListByServiceOperationResponse, err error) { - req, err := c.preparerForContentItemListByService(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "contenttypecontentitem.ContentTypeContentItemClient", "ContentItemListByService", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "contenttypecontentitem.ContentTypeContentItemClient", "ContentItemListByService", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForContentItemListByService(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "contenttypecontentitem.ContentTypeContentItemClient", "ContentItemListByService", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForContentItemListByService prepares the ContentItemListByService request. -func (c ContentTypeContentItemClient) preparerForContentItemListByService(ctx context.Context, id ContentTypeId) (*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/contentItems", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForContentItemListByServiceWithNextLink prepares the ContentItemListByService request with the given nextLink token. -func (c ContentTypeContentItemClient) preparerForContentItemListByServiceWithNextLink(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)) -} - -// responderForContentItemListByService handles the response to the ContentItemListByService request. The method always -// closes the http.Response Body. -func (c ContentTypeContentItemClient) responderForContentItemListByService(resp *http.Response) (result ContentItemListByServiceOperationResponse, err error) { - type page struct { - Values []ContentItemContract `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 ContentItemListByServiceOperationResponse, err error) { - req, err := c.preparerForContentItemListByServiceWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "contenttypecontentitem.ContentTypeContentItemClient", "ContentItemListByService", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "contenttypecontentitem.ContentTypeContentItemClient", "ContentItemListByService", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForContentItemListByService(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "contenttypecontentitem.ContentTypeContentItemClient", "ContentItemListByService", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ContentItemListByServiceComplete retrieves all of the results into a single object -func (c ContentTypeContentItemClient) ContentItemListByServiceComplete(ctx context.Context, id ContentTypeId) (ContentItemListByServiceCompleteResult, error) { - return c.ContentItemListByServiceCompleteMatchingPredicate(ctx, id, ContentItemContractOperationPredicate{}) -} - -// ContentItemListByServiceCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c ContentTypeContentItemClient) ContentItemListByServiceCompleteMatchingPredicate(ctx context.Context, id ContentTypeId, predicate ContentItemContractOperationPredicate) (resp ContentItemListByServiceCompleteResult, err error) { - items := make([]ContentItemContract, 0) - - page, err := c.ContentItemListByService(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 := ContentItemListByServiceCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/apimanagement/2021-08-01/delegationsettings/client.go b/resource-manager/apimanagement/2021-08-01/delegationsettings/client.go index 72c97b7519c..7feac89a16f 100644 --- a/resource-manager/apimanagement/2021-08-01/delegationsettings/client.go +++ b/resource-manager/apimanagement/2021-08-01/delegationsettings/client.go @@ -1,18 +1,26 @@ package delegationsettings -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 DelegationSettingsClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewDelegationSettingsClientWithBaseURI(endpoint string) DelegationSettingsClient { - return DelegationSettingsClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewDelegationSettingsClientWithBaseURI(api environments.Api) (*DelegationSettingsClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "delegationsettings", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating DelegationSettingsClient: %+v", err) } + + return &DelegationSettingsClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2021-08-01/delegationsettings/method_createorupdate.go b/resource-manager/apimanagement/2021-08-01/delegationsettings/method_createorupdate.go new file mode 100644 index 00000000000..798382faf25 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/delegationsettings/method_createorupdate.go @@ -0,0 +1,84 @@ +package delegationsettings + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PortalDelegationSettings +} + +type CreateOrUpdateOperationOptions struct { + IfMatch *string +} + +func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { + return CreateOrUpdateOperationOptions{} +} + +func (o CreateOrUpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o CreateOrUpdateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o CreateOrUpdateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// CreateOrUpdate ... +func (c DelegationSettingsClient) CreateOrUpdate(ctx context.Context, id ServiceId, input PortalDelegationSettings, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/portalsettings/delegation", id.ID()), + OptionsObject: options, + } + + 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/apimanagement/2021-08-01/delegationsettings/method_createorupdate_autorest.go b/resource-manager/apimanagement/2021-08-01/delegationsettings/method_createorupdate_autorest.go deleted file mode 100644 index 51373a1a8ce..00000000000 --- a/resource-manager/apimanagement/2021-08-01/delegationsettings/method_createorupdate_autorest.go +++ /dev/null @@ -1,99 +0,0 @@ -package delegationsettings - -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 CreateOrUpdateOperationResponse struct { - HttpResponse *http.Response - Model *PortalDelegationSettings -} - -type CreateOrUpdateOperationOptions struct { - IfMatch *string -} - -func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { - return CreateOrUpdateOperationOptions{} -} - -func (o CreateOrUpdateOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o CreateOrUpdateOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// CreateOrUpdate ... -func (c DelegationSettingsClient) CreateOrUpdate(ctx context.Context, id ServiceId, input PortalDelegationSettings, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdate(ctx, id, input, options) - if err != nil { - err = autorest.NewErrorWithError(err, "delegationsettings.DelegationSettingsClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "delegationsettings.DelegationSettingsClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCreateOrUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "delegationsettings.DelegationSettingsClient", "CreateOrUpdate", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCreateOrUpdate prepares the CreateOrUpdate request. -func (c DelegationSettingsClient) preparerForCreateOrUpdate(ctx context.Context, id ServiceId, input PortalDelegationSettings, options CreateOrUpdateOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/portalsettings/delegation", 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 DelegationSettingsClient) 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/apimanagement/2021-08-01/delegationsettings/method_get.go b/resource-manager/apimanagement/2021-08-01/delegationsettings/method_get.go new file mode 100644 index 00000000000..7e0f9378ef1 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/delegationsettings/method_get.go @@ -0,0 +1,52 @@ +package delegationsettings + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PortalDelegationSettings +} + +// Get ... +func (c DelegationSettingsClient) 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: fmt.Sprintf("%s/portalsettings/delegation", 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/apimanagement/2021-08-01/delegationsettings/method_get_autorest.go b/resource-manager/apimanagement/2021-08-01/delegationsettings/method_get_autorest.go deleted file mode 100644 index e2553b0753d..00000000000 --- a/resource-manager/apimanagement/2021-08-01/delegationsettings/method_get_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package delegationsettings - -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 GetOperationResponse struct { - HttpResponse *http.Response - Model *PortalDelegationSettings -} - -// Get ... -func (c DelegationSettingsClient) Get(ctx context.Context, id ServiceId) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "delegationsettings.DelegationSettingsClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "delegationsettings.DelegationSettingsClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "delegationsettings.DelegationSettingsClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c DelegationSettingsClient) 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(fmt.Sprintf("%s/portalsettings/delegation", 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 DelegationSettingsClient) 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/apimanagement/2021-08-01/delegationsettings/method_getentitytag.go b/resource-manager/apimanagement/2021-08-01/delegationsettings/method_getentitytag.go new file mode 100644 index 00000000000..6d1fc5745c7 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/delegationsettings/method_getentitytag.go @@ -0,0 +1,47 @@ +package delegationsettings + +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 GetEntityTagOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// GetEntityTag ... +func (c DelegationSettingsClient) GetEntityTag(ctx context.Context, id ServiceId) (result GetEntityTagOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodHead, + Path: fmt.Sprintf("%s/portalsettings/delegation", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2021-08-01/delegationsettings/method_getentitytag_autorest.go b/resource-manager/apimanagement/2021-08-01/delegationsettings/method_getentitytag_autorest.go deleted file mode 100644 index 7a92ab1b000..00000000000 --- a/resource-manager/apimanagement/2021-08-01/delegationsettings/method_getentitytag_autorest.go +++ /dev/null @@ -1,67 +0,0 @@ -package delegationsettings - -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 GetEntityTagOperationResponse struct { - HttpResponse *http.Response -} - -// GetEntityTag ... -func (c DelegationSettingsClient) GetEntityTag(ctx context.Context, id ServiceId) (result GetEntityTagOperationResponse, err error) { - req, err := c.preparerForGetEntityTag(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "delegationsettings.DelegationSettingsClient", "GetEntityTag", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "delegationsettings.DelegationSettingsClient", "GetEntityTag", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetEntityTag(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "delegationsettings.DelegationSettingsClient", "GetEntityTag", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetEntityTag prepares the GetEntityTag request. -func (c DelegationSettingsClient) preparerForGetEntityTag(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.AsHead(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/portalsettings/delegation", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetEntityTag handles the response to the GetEntityTag request. The method always -// closes the http.Response Body. -func (c DelegationSettingsClient) responderForGetEntityTag(resp *http.Response) (result GetEntityTagOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2021-08-01/delegationsettings/method_listsecrets.go b/resource-manager/apimanagement/2021-08-01/delegationsettings/method_listsecrets.go new file mode 100644 index 00000000000..baf7a240e3b --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/delegationsettings/method_listsecrets.go @@ -0,0 +1,52 @@ +package delegationsettings + +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 ListSecretsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PortalSettingValidationKeyContract +} + +// ListSecrets ... +func (c DelegationSettingsClient) ListSecrets(ctx context.Context, id ServiceId) (result ListSecretsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/portalsettings/delegation/listSecrets", 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/apimanagement/2021-08-01/delegationsettings/method_listsecrets_autorest.go b/resource-manager/apimanagement/2021-08-01/delegationsettings/method_listsecrets_autorest.go deleted file mode 100644 index 279c998cc3b..00000000000 --- a/resource-manager/apimanagement/2021-08-01/delegationsettings/method_listsecrets_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package delegationsettings - -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 ListSecretsOperationResponse struct { - HttpResponse *http.Response - Model *PortalSettingValidationKeyContract -} - -// ListSecrets ... -func (c DelegationSettingsClient) ListSecrets(ctx context.Context, id ServiceId) (result ListSecretsOperationResponse, err error) { - req, err := c.preparerForListSecrets(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "delegationsettings.DelegationSettingsClient", "ListSecrets", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "delegationsettings.DelegationSettingsClient", "ListSecrets", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListSecrets(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "delegationsettings.DelegationSettingsClient", "ListSecrets", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForListSecrets prepares the ListSecrets request. -func (c DelegationSettingsClient) preparerForListSecrets(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.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/portalsettings/delegation/listSecrets", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListSecrets handles the response to the ListSecrets request. The method always -// closes the http.Response Body. -func (c DelegationSettingsClient) responderForListSecrets(resp *http.Response) (result ListSecretsOperationResponse, 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/apimanagement/2021-08-01/delegationsettings/method_update.go b/resource-manager/apimanagement/2021-08-01/delegationsettings/method_update.go new file mode 100644 index 00000000000..924b296b5fa --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/delegationsettings/method_update.go @@ -0,0 +1,79 @@ +package delegationsettings + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +type UpdateOperationOptions struct { + IfMatch *string +} + +func DefaultUpdateOperationOptions() UpdateOperationOptions { + return UpdateOperationOptions{} +} + +func (o UpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o UpdateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o UpdateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// Update ... +func (c DelegationSettingsClient) Update(ctx context.Context, id ServiceId, input PortalDelegationSettings, options UpdateOperationOptions) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: http.MethodPatch, + Path: fmt.Sprintf("%s/portalsettings/delegation", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2021-08-01/delegationsettings/method_update_autorest.go b/resource-manager/apimanagement/2021-08-01/delegationsettings/method_update_autorest.go deleted file mode 100644 index c768645478b..00000000000 --- a/resource-manager/apimanagement/2021-08-01/delegationsettings/method_update_autorest.go +++ /dev/null @@ -1,97 +0,0 @@ -package delegationsettings - -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 UpdateOperationResponse struct { - HttpResponse *http.Response -} - -type UpdateOperationOptions struct { - IfMatch *string -} - -func DefaultUpdateOperationOptions() UpdateOperationOptions { - return UpdateOperationOptions{} -} - -func (o UpdateOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o UpdateOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// Update ... -func (c DelegationSettingsClient) Update(ctx context.Context, id ServiceId, input PortalDelegationSettings, options UpdateOperationOptions) (result UpdateOperationResponse, err error) { - req, err := c.preparerForUpdate(ctx, id, input, options) - if err != nil { - err = autorest.NewErrorWithError(err, "delegationsettings.DelegationSettingsClient", "Update", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "delegationsettings.DelegationSettingsClient", "Update", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "delegationsettings.DelegationSettingsClient", "Update", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForUpdate prepares the Update request. -func (c DelegationSettingsClient) preparerForUpdate(ctx context.Context, id ServiceId, input PortalDelegationSettings, options UpdateOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPatch(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/portalsettings/delegation", 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 DelegationSettingsClient) responderForUpdate(resp *http.Response) (result UpdateOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2021-08-01/deletedservice/client.go b/resource-manager/apimanagement/2021-08-01/deletedservice/client.go index 481a31f9a8a..95e9b5a5088 100644 --- a/resource-manager/apimanagement/2021-08-01/deletedservice/client.go +++ b/resource-manager/apimanagement/2021-08-01/deletedservice/client.go @@ -1,18 +1,26 @@ package deletedservice -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 DeletedServiceClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewDeletedServiceClientWithBaseURI(endpoint string) DeletedServiceClient { - return DeletedServiceClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewDeletedServiceClientWithBaseURI(api environments.Api) (*DeletedServiceClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "deletedservice", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating DeletedServiceClient: %+v", err) } + + return &DeletedServiceClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2021-08-01/deletedservice/method_getbyname.go b/resource-manager/apimanagement/2021-08-01/deletedservice/method_getbyname.go new file mode 100644 index 00000000000..f6404fd9b48 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/deletedservice/method_getbyname.go @@ -0,0 +1,51 @@ +package deletedservice + +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 GetByNameOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DeletedServiceContract +} + +// GetByName ... +func (c DeletedServiceClient) GetByName(ctx context.Context, id DeletedServiceId) (result GetByNameOperationResponse, 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/apimanagement/2021-08-01/deletedservice/method_getbyname_autorest.go b/resource-manager/apimanagement/2021-08-01/deletedservice/method_getbyname_autorest.go deleted file mode 100644 index f80305a22eb..00000000000 --- a/resource-manager/apimanagement/2021-08-01/deletedservice/method_getbyname_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package deletedservice - -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 GetByNameOperationResponse struct { - HttpResponse *http.Response - Model *DeletedServiceContract -} - -// GetByName ... -func (c DeletedServiceClient) GetByName(ctx context.Context, id DeletedServiceId) (result GetByNameOperationResponse, err error) { - req, err := c.preparerForGetByName(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "deletedservice.DeletedServiceClient", "GetByName", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "deletedservice.DeletedServiceClient", "GetByName", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetByName(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "deletedservice.DeletedServiceClient", "GetByName", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetByName prepares the GetByName request. -func (c DeletedServiceClient) preparerForGetByName(ctx context.Context, id DeletedServiceId) (*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)) -} - -// responderForGetByName handles the response to the GetByName request. The method always -// closes the http.Response Body. -func (c DeletedServiceClient) responderForGetByName(resp *http.Response) (result GetByNameOperationResponse, 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/apimanagement/2021-08-01/deletedservice/method_listbysubscription.go b/resource-manager/apimanagement/2021-08-01/deletedservice/method_listbysubscription.go new file mode 100644 index 00000000000..f6077a9e1f1 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/deletedservice/method_listbysubscription.go @@ -0,0 +1,90 @@ +package deletedservice + +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 *[]DeletedServiceContract +} + +type ListBySubscriptionCompleteResult struct { + Items []DeletedServiceContract +} + +// ListBySubscription ... +func (c DeletedServiceClient) 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.ApiManagement/deletedServices", 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 *[]DeletedServiceContract `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 DeletedServiceClient) ListBySubscriptionComplete(ctx context.Context, id commonids.SubscriptionId) (ListBySubscriptionCompleteResult, error) { + return c.ListBySubscriptionCompleteMatchingPredicate(ctx, id, DeletedServiceContractOperationPredicate{}) +} + +// ListBySubscriptionCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c DeletedServiceClient) ListBySubscriptionCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate DeletedServiceContractOperationPredicate) (result ListBySubscriptionCompleteResult, err error) { + items := make([]DeletedServiceContract, 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{ + Items: items, + } + return +} diff --git a/resource-manager/apimanagement/2021-08-01/deletedservice/method_listbysubscription_autorest.go b/resource-manager/apimanagement/2021-08-01/deletedservice/method_listbysubscription_autorest.go deleted file mode 100644 index 34e994381a2..00000000000 --- a/resource-manager/apimanagement/2021-08-01/deletedservice/method_listbysubscription_autorest.go +++ /dev/null @@ -1,187 +0,0 @@ -package deletedservice - -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 *[]DeletedServiceContract - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListBySubscriptionOperationResponse, error) -} - -type ListBySubscriptionCompleteResult struct { - Items []DeletedServiceContract -} - -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 DeletedServiceClient) ListBySubscription(ctx context.Context, id commonids.SubscriptionId) (resp ListBySubscriptionOperationResponse, err error) { - req, err := c.preparerForListBySubscription(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "deletedservice.DeletedServiceClient", "ListBySubscription", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "deletedservice.DeletedServiceClient", "ListBySubscription", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListBySubscription(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "deletedservice.DeletedServiceClient", "ListBySubscription", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListBySubscription prepares the ListBySubscription request. -func (c DeletedServiceClient) 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.ApiManagement/deletedServices", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListBySubscriptionWithNextLink prepares the ListBySubscription request with the given nextLink token. -func (c DeletedServiceClient) 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 DeletedServiceClient) responderForListBySubscription(resp *http.Response) (result ListBySubscriptionOperationResponse, err error) { - type page struct { - Values []DeletedServiceContract `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, "deletedservice.DeletedServiceClient", "ListBySubscription", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "deletedservice.DeletedServiceClient", "ListBySubscription", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListBySubscription(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "deletedservice.DeletedServiceClient", "ListBySubscription", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListBySubscriptionComplete retrieves all of the results into a single object -func (c DeletedServiceClient) ListBySubscriptionComplete(ctx context.Context, id commonids.SubscriptionId) (ListBySubscriptionCompleteResult, error) { - return c.ListBySubscriptionCompleteMatchingPredicate(ctx, id, DeletedServiceContractOperationPredicate{}) -} - -// ListBySubscriptionCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c DeletedServiceClient) ListBySubscriptionCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate DeletedServiceContractOperationPredicate) (resp ListBySubscriptionCompleteResult, err error) { - items := make([]DeletedServiceContract, 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/apimanagement/2021-08-01/deletedservice/method_purge.go b/resource-manager/apimanagement/2021-08-01/deletedservice/method_purge.go new file mode 100644 index 00000000000..0e5dcf28a3d --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/deletedservice/method_purge.go @@ -0,0 +1,71 @@ +package deletedservice + +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 PurgeOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Purge ... +func (c DeletedServiceClient) Purge(ctx context.Context, id DeletedServiceId) (result PurgeOperationResponse, 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 +} + +// PurgeThenPoll performs Purge then polls until it's completed +func (c DeletedServiceClient) PurgeThenPoll(ctx context.Context, id DeletedServiceId) error { + result, err := c.Purge(ctx, id) + if err != nil { + return fmt.Errorf("performing Purge: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Purge: %+v", err) + } + + return nil +} diff --git a/resource-manager/apimanagement/2021-08-01/deletedservice/method_purge_autorest.go b/resource-manager/apimanagement/2021-08-01/deletedservice/method_purge_autorest.go deleted file mode 100644 index 3494c6cdd2e..00000000000 --- a/resource-manager/apimanagement/2021-08-01/deletedservice/method_purge_autorest.go +++ /dev/null @@ -1,78 +0,0 @@ -package deletedservice - -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 PurgeOperationResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// Purge ... -func (c DeletedServiceClient) Purge(ctx context.Context, id DeletedServiceId) (result PurgeOperationResponse, err error) { - req, err := c.preparerForPurge(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "deletedservice.DeletedServiceClient", "Purge", nil, "Failure preparing request") - return - } - - result, err = c.senderForPurge(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "deletedservice.DeletedServiceClient", "Purge", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// PurgeThenPoll performs Purge then polls until it's completed -func (c DeletedServiceClient) PurgeThenPoll(ctx context.Context, id DeletedServiceId) error { - result, err := c.Purge(ctx, id) - if err != nil { - return fmt.Errorf("performing Purge: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after Purge: %+v", err) - } - - return nil -} - -// preparerForPurge prepares the Purge request. -func (c DeletedServiceClient) preparerForPurge(ctx context.Context, id DeletedServiceId) (*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)) -} - -// senderForPurge sends the Purge request. The method will close the -// http.Response Body if it receives an error. -func (c DeletedServiceClient) senderForPurge(ctx context.Context, req *http.Request) (future PurgeOperationResponse, 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/apimanagement/2021-08-01/diagnostic/client.go b/resource-manager/apimanagement/2021-08-01/diagnostic/client.go index 724671ed06e..c68f037e03e 100644 --- a/resource-manager/apimanagement/2021-08-01/diagnostic/client.go +++ b/resource-manager/apimanagement/2021-08-01/diagnostic/client.go @@ -1,18 +1,26 @@ package diagnostic -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 DiagnosticClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewDiagnosticClientWithBaseURI(endpoint string) DiagnosticClient { - return DiagnosticClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewDiagnosticClientWithBaseURI(api environments.Api) (*DiagnosticClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "diagnostic", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating DiagnosticClient: %+v", err) } + + return &DiagnosticClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2021-08-01/diagnostic/constants.go b/resource-manager/apimanagement/2021-08-01/diagnostic/constants.go index b75c24b4d61..cde4ab74afa 100644 --- a/resource-manager/apimanagement/2021-08-01/diagnostic/constants.go +++ b/resource-manager/apimanagement/2021-08-01/diagnostic/constants.go @@ -1,6 +1,10 @@ package diagnostic -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 PossibleValuesForAlwaysLog() []string { } } +func (s *AlwaysLog) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAlwaysLog(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseAlwaysLog(input string) (*AlwaysLog, error) { vals := map[string]AlwaysLog{ "allerrors": AlwaysLogAllErrors, @@ -44,6 +61,19 @@ func PossibleValuesForDataMaskingMode() []string { } } +func (s *DataMaskingMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDataMaskingMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseDataMaskingMode(input string) (*DataMaskingMode, error) { vals := map[string]DataMaskingMode{ "hide": DataMaskingModeHide, @@ -74,6 +104,19 @@ func PossibleValuesForHTTPCorrelationProtocol() []string { } } +func (s *HTTPCorrelationProtocol) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseHTTPCorrelationProtocol(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseHTTPCorrelationProtocol(input string) (*HTTPCorrelationProtocol, error) { vals := map[string]HTTPCorrelationProtocol{ "legacy": HTTPCorrelationProtocolLegacy, @@ -103,6 +146,19 @@ func PossibleValuesForOperationNameFormat() []string { } } +func (s *OperationNameFormat) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseOperationNameFormat(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseOperationNameFormat(input string) (*OperationNameFormat, error) { vals := map[string]OperationNameFormat{ "name": OperationNameFormatName, @@ -129,6 +185,19 @@ func PossibleValuesForSamplingType() []string { } } +func (s *SamplingType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSamplingType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseSamplingType(input string) (*SamplingType, error) { vals := map[string]SamplingType{ "fixed": SamplingTypeFixed, @@ -158,6 +227,19 @@ func PossibleValuesForVerbosity() []string { } } +func (s *Verbosity) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseVerbosity(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseVerbosity(input string) (*Verbosity, error) { vals := map[string]Verbosity{ "error": VerbosityError, diff --git a/resource-manager/apimanagement/2021-08-01/diagnostic/method_createorupdate.go b/resource-manager/apimanagement/2021-08-01/diagnostic/method_createorupdate.go new file mode 100644 index 00000000000..7b559f7022a --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/diagnostic/method_createorupdate.go @@ -0,0 +1,85 @@ +package diagnostic + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DiagnosticContract +} + +type CreateOrUpdateOperationOptions struct { + IfMatch *string +} + +func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { + return CreateOrUpdateOperationOptions{} +} + +func (o CreateOrUpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o CreateOrUpdateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o CreateOrUpdateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// CreateOrUpdate ... +func (c DiagnosticClient) CreateOrUpdate(ctx context.Context, id DiagnosticId, input DiagnosticContract, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + OptionsObject: options, + } + + 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/apimanagement/2021-08-01/diagnostic/method_createorupdate_autorest.go b/resource-manager/apimanagement/2021-08-01/diagnostic/method_createorupdate_autorest.go deleted file mode 100644 index b4c6a433f43..00000000000 --- a/resource-manager/apimanagement/2021-08-01/diagnostic/method_createorupdate_autorest.go +++ /dev/null @@ -1,98 +0,0 @@ -package diagnostic - -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 *DiagnosticContract -} - -type CreateOrUpdateOperationOptions struct { - IfMatch *string -} - -func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { - return CreateOrUpdateOperationOptions{} -} - -func (o CreateOrUpdateOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o CreateOrUpdateOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// CreateOrUpdate ... -func (c DiagnosticClient) CreateOrUpdate(ctx context.Context, id DiagnosticId, input DiagnosticContract, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdate(ctx, id, input, options) - if err != nil { - err = autorest.NewErrorWithError(err, "diagnostic.DiagnosticClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "diagnostic.DiagnosticClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCreateOrUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "diagnostic.DiagnosticClient", "CreateOrUpdate", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCreateOrUpdate prepares the CreateOrUpdate request. -func (c DiagnosticClient) preparerForCreateOrUpdate(ctx context.Context, id DiagnosticId, input DiagnosticContract, options CreateOrUpdateOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - 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 DiagnosticClient) responderForCreateOrUpdate(resp *http.Response) (result CreateOrUpdateOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2021-08-01/diagnostic/method_delete.go b/resource-manager/apimanagement/2021-08-01/diagnostic/method_delete.go new file mode 100644 index 00000000000..3cd08df2cd9 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/diagnostic/method_delete.go @@ -0,0 +1,76 @@ +package diagnostic + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +type DeleteOperationOptions struct { + IfMatch *string +} + +func DefaultDeleteOperationOptions() DeleteOperationOptions { + return DeleteOperationOptions{} +} + +func (o DeleteOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o DeleteOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o DeleteOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// Delete ... +func (c DiagnosticClient) Delete(ctx context.Context, id DiagnosticId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2021-08-01/diagnostic/method_delete_autorest.go b/resource-manager/apimanagement/2021-08-01/diagnostic/method_delete_autorest.go deleted file mode 100644 index e91965ee97f..00000000000 --- a/resource-manager/apimanagement/2021-08-01/diagnostic/method_delete_autorest.go +++ /dev/null @@ -1,95 +0,0 @@ -package diagnostic - -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 DeleteOperationResponse struct { - HttpResponse *http.Response -} - -type DeleteOperationOptions struct { - IfMatch *string -} - -func DefaultDeleteOperationOptions() DeleteOperationOptions { - return DeleteOperationOptions{} -} - -func (o DeleteOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o DeleteOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// Delete ... -func (c DiagnosticClient) Delete(ctx context.Context, id DiagnosticId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { - req, err := c.preparerForDelete(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "diagnostic.DiagnosticClient", "Delete", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "diagnostic.DiagnosticClient", "Delete", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForDelete(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "diagnostic.DiagnosticClient", "Delete", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForDelete prepares the Delete request. -func (c DiagnosticClient) preparerForDelete(ctx context.Context, id DiagnosticId, options DeleteOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForDelete handles the response to the Delete request. The method always -// closes the http.Response Body. -func (c DiagnosticClient) responderForDelete(resp *http.Response) (result DeleteOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2021-08-01/diagnostic/method_get.go b/resource-manager/apimanagement/2021-08-01/diagnostic/method_get.go new file mode 100644 index 00000000000..efc4cc74089 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/diagnostic/method_get.go @@ -0,0 +1,51 @@ +package diagnostic + +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 *DiagnosticContract +} + +// Get ... +func (c DiagnosticClient) Get(ctx context.Context, id DiagnosticId) (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/apimanagement/2021-08-01/diagnostic/method_get_autorest.go b/resource-manager/apimanagement/2021-08-01/diagnostic/method_get_autorest.go deleted file mode 100644 index c5725fba3fd..00000000000 --- a/resource-manager/apimanagement/2021-08-01/diagnostic/method_get_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package diagnostic - -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 *DiagnosticContract -} - -// Get ... -func (c DiagnosticClient) Get(ctx context.Context, id DiagnosticId) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "diagnostic.DiagnosticClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "diagnostic.DiagnosticClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "diagnostic.DiagnosticClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c DiagnosticClient) preparerForGet(ctx context.Context, id DiagnosticId) (*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 DiagnosticClient) 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/apimanagement/2021-08-01/diagnostic/method_getentitytag.go b/resource-manager/apimanagement/2021-08-01/diagnostic/method_getentitytag.go new file mode 100644 index 00000000000..8be53cb6cbf --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/diagnostic/method_getentitytag.go @@ -0,0 +1,46 @@ +package diagnostic + +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 GetEntityTagOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// GetEntityTag ... +func (c DiagnosticClient) GetEntityTag(ctx context.Context, id DiagnosticId) (result GetEntityTagOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodHead, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2021-08-01/diagnostic/method_getentitytag_autorest.go b/resource-manager/apimanagement/2021-08-01/diagnostic/method_getentitytag_autorest.go deleted file mode 100644 index f06e74665d8..00000000000 --- a/resource-manager/apimanagement/2021-08-01/diagnostic/method_getentitytag_autorest.go +++ /dev/null @@ -1,66 +0,0 @@ -package diagnostic - -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 GetEntityTagOperationResponse struct { - HttpResponse *http.Response -} - -// GetEntityTag ... -func (c DiagnosticClient) GetEntityTag(ctx context.Context, id DiagnosticId) (result GetEntityTagOperationResponse, err error) { - req, err := c.preparerForGetEntityTag(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "diagnostic.DiagnosticClient", "GetEntityTag", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "diagnostic.DiagnosticClient", "GetEntityTag", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetEntityTag(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "diagnostic.DiagnosticClient", "GetEntityTag", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetEntityTag prepares the GetEntityTag request. -func (c DiagnosticClient) preparerForGetEntityTag(ctx context.Context, id DiagnosticId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsHead(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetEntityTag handles the response to the GetEntityTag request. The method always -// closes the http.Response Body. -func (c DiagnosticClient) responderForGetEntityTag(resp *http.Response) (result GetEntityTagOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2021-08-01/diagnostic/method_listbyservice.go b/resource-manager/apimanagement/2021-08-01/diagnostic/method_listbyservice.go new file mode 100644 index 00000000000..591d81877f4 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/diagnostic/method_listbyservice.go @@ -0,0 +1,125 @@ +package diagnostic + +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 ListByServiceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]DiagnosticContract +} + +type ListByServiceCompleteResult struct { + Items []DiagnosticContract +} + +type ListByServiceOperationOptions struct { + Filter *string + Skip *int64 + Top *int64 +} + +func DefaultListByServiceOperationOptions() ListByServiceOperationOptions { + return ListByServiceOperationOptions{} +} + +func (o ListByServiceOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListByServiceOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListByServiceOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.Skip != nil { + out.Append("$skip", fmt.Sprintf("%v", *o.Skip)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +// ListByService ... +func (c DiagnosticClient) ListByService(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (result ListByServiceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/diagnostics", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]DiagnosticContract `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByServiceComplete retrieves all the results into a single object +func (c DiagnosticClient) ListByServiceComplete(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (ListByServiceCompleteResult, error) { + return c.ListByServiceCompleteMatchingPredicate(ctx, id, options, DiagnosticContractOperationPredicate{}) +} + +// ListByServiceCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c DiagnosticClient) ListByServiceCompleteMatchingPredicate(ctx context.Context, id ServiceId, options ListByServiceOperationOptions, predicate DiagnosticContractOperationPredicate) (result ListByServiceCompleteResult, err error) { + items := make([]DiagnosticContract, 0) + + resp, err := c.ListByService(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByServiceCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/apimanagement/2021-08-01/diagnostic/method_listbyservice_autorest.go b/resource-manager/apimanagement/2021-08-01/diagnostic/method_listbyservice_autorest.go deleted file mode 100644 index f02ef63c2c4..00000000000 --- a/resource-manager/apimanagement/2021-08-01/diagnostic/method_listbyservice_autorest.go +++ /dev/null @@ -1,225 +0,0 @@ -package diagnostic - -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 ListByServiceOperationResponse struct { - HttpResponse *http.Response - Model *[]DiagnosticContract - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListByServiceOperationResponse, error) -} - -type ListByServiceCompleteResult struct { - Items []DiagnosticContract -} - -func (r ListByServiceOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListByServiceOperationResponse) LoadMore(ctx context.Context) (resp ListByServiceOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -type ListByServiceOperationOptions struct { - Filter *string - Skip *int64 - Top *int64 -} - -func DefaultListByServiceOperationOptions() ListByServiceOperationOptions { - return ListByServiceOperationOptions{} -} - -func (o ListByServiceOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o ListByServiceOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Filter != nil { - out["$filter"] = *o.Filter - } - - if o.Skip != nil { - out["$skip"] = *o.Skip - } - - if o.Top != nil { - out["$top"] = *o.Top - } - - return out -} - -// ListByService ... -func (c DiagnosticClient) ListByService(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (resp ListByServiceOperationResponse, err error) { - req, err := c.preparerForListByService(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "diagnostic.DiagnosticClient", "ListByService", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "diagnostic.DiagnosticClient", "ListByService", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListByService(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "diagnostic.DiagnosticClient", "ListByService", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListByService prepares the ListByService request. -func (c DiagnosticClient) preparerForListByService(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/diagnostics", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListByServiceWithNextLink prepares the ListByService request with the given nextLink token. -func (c DiagnosticClient) preparerForListByServiceWithNextLink(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)) -} - -// responderForListByService handles the response to the ListByService request. The method always -// closes the http.Response Body. -func (c DiagnosticClient) responderForListByService(resp *http.Response) (result ListByServiceOperationResponse, err error) { - type page struct { - Values []DiagnosticContract `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 ListByServiceOperationResponse, err error) { - req, err := c.preparerForListByServiceWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "diagnostic.DiagnosticClient", "ListByService", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "diagnostic.DiagnosticClient", "ListByService", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByService(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "diagnostic.DiagnosticClient", "ListByService", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListByServiceComplete retrieves all of the results into a single object -func (c DiagnosticClient) ListByServiceComplete(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (ListByServiceCompleteResult, error) { - return c.ListByServiceCompleteMatchingPredicate(ctx, id, options, DiagnosticContractOperationPredicate{}) -} - -// ListByServiceCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c DiagnosticClient) ListByServiceCompleteMatchingPredicate(ctx context.Context, id ServiceId, options ListByServiceOperationOptions, predicate DiagnosticContractOperationPredicate) (resp ListByServiceCompleteResult, err error) { - items := make([]DiagnosticContract, 0) - - page, err := c.ListByService(ctx, id, options) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListByServiceCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/apimanagement/2021-08-01/diagnostic/method_update.go b/resource-manager/apimanagement/2021-08-01/diagnostic/method_update.go new file mode 100644 index 00000000000..cc36660c9e8 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/diagnostic/method_update.go @@ -0,0 +1,84 @@ +package diagnostic + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DiagnosticContract +} + +type UpdateOperationOptions struct { + IfMatch *string +} + +func DefaultUpdateOperationOptions() UpdateOperationOptions { + return UpdateOperationOptions{} +} + +func (o UpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o UpdateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o UpdateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// Update ... +func (c DiagnosticClient) Update(ctx context.Context, id DiagnosticId, input DiagnosticContract, options UpdateOperationOptions) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + OptionsObject: options, + } + + 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/apimanagement/2021-08-01/diagnostic/method_update_autorest.go b/resource-manager/apimanagement/2021-08-01/diagnostic/method_update_autorest.go deleted file mode 100644 index f0c0c3763a8..00000000000 --- a/resource-manager/apimanagement/2021-08-01/diagnostic/method_update_autorest.go +++ /dev/null @@ -1,98 +0,0 @@ -package diagnostic - -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 *DiagnosticContract -} - -type UpdateOperationOptions struct { - IfMatch *string -} - -func DefaultUpdateOperationOptions() UpdateOperationOptions { - return UpdateOperationOptions{} -} - -func (o UpdateOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o UpdateOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// Update ... -func (c DiagnosticClient) Update(ctx context.Context, id DiagnosticId, input DiagnosticContract, options UpdateOperationOptions) (result UpdateOperationResponse, err error) { - req, err := c.preparerForUpdate(ctx, id, input, options) - if err != nil { - err = autorest.NewErrorWithError(err, "diagnostic.DiagnosticClient", "Update", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "diagnostic.DiagnosticClient", "Update", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "diagnostic.DiagnosticClient", "Update", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForUpdate prepares the Update request. -func (c DiagnosticClient) preparerForUpdate(ctx context.Context, id DiagnosticId, input DiagnosticContract, options UpdateOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPatch(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - 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 DiagnosticClient) 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/apimanagement/2021-08-01/emailtemplate/client.go b/resource-manager/apimanagement/2021-08-01/emailtemplate/client.go index fcf62feaf0d..f33adb74866 100644 --- a/resource-manager/apimanagement/2021-08-01/emailtemplate/client.go +++ b/resource-manager/apimanagement/2021-08-01/emailtemplate/client.go @@ -1,18 +1,26 @@ package emailtemplate -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 EmailTemplateClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewEmailTemplateClientWithBaseURI(endpoint string) EmailTemplateClient { - return EmailTemplateClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewEmailTemplateClientWithBaseURI(api environments.Api) (*EmailTemplateClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "emailtemplate", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating EmailTemplateClient: %+v", err) } + + return &EmailTemplateClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2021-08-01/emailtemplate/method_listbyservice.go b/resource-manager/apimanagement/2021-08-01/emailtemplate/method_listbyservice.go new file mode 100644 index 00000000000..ece5fedb586 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/emailtemplate/method_listbyservice.go @@ -0,0 +1,125 @@ +package emailtemplate + +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 ListByServiceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]EmailTemplateContract +} + +type ListByServiceCompleteResult struct { + Items []EmailTemplateContract +} + +type ListByServiceOperationOptions struct { + Filter *string + Skip *int64 + Top *int64 +} + +func DefaultListByServiceOperationOptions() ListByServiceOperationOptions { + return ListByServiceOperationOptions{} +} + +func (o ListByServiceOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListByServiceOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListByServiceOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.Skip != nil { + out.Append("$skip", fmt.Sprintf("%v", *o.Skip)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +// ListByService ... +func (c EmailTemplateClient) ListByService(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (result ListByServiceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/templates", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]EmailTemplateContract `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByServiceComplete retrieves all the results into a single object +func (c EmailTemplateClient) ListByServiceComplete(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (ListByServiceCompleteResult, error) { + return c.ListByServiceCompleteMatchingPredicate(ctx, id, options, EmailTemplateContractOperationPredicate{}) +} + +// ListByServiceCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c EmailTemplateClient) ListByServiceCompleteMatchingPredicate(ctx context.Context, id ServiceId, options ListByServiceOperationOptions, predicate EmailTemplateContractOperationPredicate) (result ListByServiceCompleteResult, err error) { + items := make([]EmailTemplateContract, 0) + + resp, err := c.ListByService(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByServiceCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/apimanagement/2021-08-01/emailtemplate/method_listbyservice_autorest.go b/resource-manager/apimanagement/2021-08-01/emailtemplate/method_listbyservice_autorest.go deleted file mode 100644 index 69b66381ca2..00000000000 --- a/resource-manager/apimanagement/2021-08-01/emailtemplate/method_listbyservice_autorest.go +++ /dev/null @@ -1,225 +0,0 @@ -package emailtemplate - -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 ListByServiceOperationResponse struct { - HttpResponse *http.Response - Model *[]EmailTemplateContract - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListByServiceOperationResponse, error) -} - -type ListByServiceCompleteResult struct { - Items []EmailTemplateContract -} - -func (r ListByServiceOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListByServiceOperationResponse) LoadMore(ctx context.Context) (resp ListByServiceOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -type ListByServiceOperationOptions struct { - Filter *string - Skip *int64 - Top *int64 -} - -func DefaultListByServiceOperationOptions() ListByServiceOperationOptions { - return ListByServiceOperationOptions{} -} - -func (o ListByServiceOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o ListByServiceOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Filter != nil { - out["$filter"] = *o.Filter - } - - if o.Skip != nil { - out["$skip"] = *o.Skip - } - - if o.Top != nil { - out["$top"] = *o.Top - } - - return out -} - -// ListByService ... -func (c EmailTemplateClient) ListByService(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (resp ListByServiceOperationResponse, err error) { - req, err := c.preparerForListByService(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "emailtemplate.EmailTemplateClient", "ListByService", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "emailtemplate.EmailTemplateClient", "ListByService", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListByService(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "emailtemplate.EmailTemplateClient", "ListByService", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListByService prepares the ListByService request. -func (c EmailTemplateClient) preparerForListByService(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/templates", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListByServiceWithNextLink prepares the ListByService request with the given nextLink token. -func (c EmailTemplateClient) preparerForListByServiceWithNextLink(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)) -} - -// responderForListByService handles the response to the ListByService request. The method always -// closes the http.Response Body. -func (c EmailTemplateClient) responderForListByService(resp *http.Response) (result ListByServiceOperationResponse, err error) { - type page struct { - Values []EmailTemplateContract `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 ListByServiceOperationResponse, err error) { - req, err := c.preparerForListByServiceWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "emailtemplate.EmailTemplateClient", "ListByService", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "emailtemplate.EmailTemplateClient", "ListByService", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByService(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "emailtemplate.EmailTemplateClient", "ListByService", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListByServiceComplete retrieves all of the results into a single object -func (c EmailTemplateClient) ListByServiceComplete(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (ListByServiceCompleteResult, error) { - return c.ListByServiceCompleteMatchingPredicate(ctx, id, options, EmailTemplateContractOperationPredicate{}) -} - -// ListByServiceCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c EmailTemplateClient) ListByServiceCompleteMatchingPredicate(ctx context.Context, id ServiceId, options ListByServiceOperationOptions, predicate EmailTemplateContractOperationPredicate) (resp ListByServiceCompleteResult, err error) { - items := make([]EmailTemplateContract, 0) - - page, err := c.ListByService(ctx, id, options) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListByServiceCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/apimanagement/2021-08-01/emailtemplates/client.go b/resource-manager/apimanagement/2021-08-01/emailtemplates/client.go index 9794f3dc9e2..95f5deb2ef2 100644 --- a/resource-manager/apimanagement/2021-08-01/emailtemplates/client.go +++ b/resource-manager/apimanagement/2021-08-01/emailtemplates/client.go @@ -1,18 +1,26 @@ package emailtemplates -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 EmailTemplatesClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewEmailTemplatesClientWithBaseURI(endpoint string) EmailTemplatesClient { - return EmailTemplatesClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewEmailTemplatesClientWithBaseURI(api environments.Api) (*EmailTemplatesClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "emailtemplates", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating EmailTemplatesClient: %+v", err) } + + return &EmailTemplatesClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2021-08-01/emailtemplates/constants.go b/resource-manager/apimanagement/2021-08-01/emailtemplates/constants.go index 178c1c73651..19dadfefea4 100644 --- a/resource-manager/apimanagement/2021-08-01/emailtemplates/constants.go +++ b/resource-manager/apimanagement/2021-08-01/emailtemplates/constants.go @@ -1,6 +1,10 @@ package emailtemplates -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. @@ -43,6 +47,19 @@ func PossibleValuesForTemplateName() []string { } } +func (s *TemplateName) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseTemplateName(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseTemplateName(input string) (*TemplateName, error) { vals := map[string]TemplateName{ "accountcloseddeveloper": TemplateNameAccountClosedDeveloper, diff --git a/resource-manager/apimanagement/2021-08-01/emailtemplates/method_emailtemplatecreateorupdate.go b/resource-manager/apimanagement/2021-08-01/emailtemplates/method_emailtemplatecreateorupdate.go new file mode 100644 index 00000000000..80154b944bc --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/emailtemplates/method_emailtemplatecreateorupdate.go @@ -0,0 +1,85 @@ +package emailtemplates + +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 EmailTemplateCreateOrUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *EmailTemplateContract +} + +type EmailTemplateCreateOrUpdateOperationOptions struct { + IfMatch *string +} + +func DefaultEmailTemplateCreateOrUpdateOperationOptions() EmailTemplateCreateOrUpdateOperationOptions { + return EmailTemplateCreateOrUpdateOperationOptions{} +} + +func (o EmailTemplateCreateOrUpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o EmailTemplateCreateOrUpdateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o EmailTemplateCreateOrUpdateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// EmailTemplateCreateOrUpdate ... +func (c EmailTemplatesClient) EmailTemplateCreateOrUpdate(ctx context.Context, id TemplateId, input EmailTemplateUpdateParameters, options EmailTemplateCreateOrUpdateOperationOptions) (result EmailTemplateCreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + OptionsObject: options, + } + + 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/apimanagement/2021-08-01/emailtemplates/method_emailtemplatecreateorupdate_autorest.go b/resource-manager/apimanagement/2021-08-01/emailtemplates/method_emailtemplatecreateorupdate_autorest.go deleted file mode 100644 index 3a2c54ff109..00000000000 --- a/resource-manager/apimanagement/2021-08-01/emailtemplates/method_emailtemplatecreateorupdate_autorest.go +++ /dev/null @@ -1,98 +0,0 @@ -package emailtemplates - -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 EmailTemplateCreateOrUpdateOperationResponse struct { - HttpResponse *http.Response - Model *EmailTemplateContract -} - -type EmailTemplateCreateOrUpdateOperationOptions struct { - IfMatch *string -} - -func DefaultEmailTemplateCreateOrUpdateOperationOptions() EmailTemplateCreateOrUpdateOperationOptions { - return EmailTemplateCreateOrUpdateOperationOptions{} -} - -func (o EmailTemplateCreateOrUpdateOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o EmailTemplateCreateOrUpdateOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// EmailTemplateCreateOrUpdate ... -func (c EmailTemplatesClient) EmailTemplateCreateOrUpdate(ctx context.Context, id TemplateId, input EmailTemplateUpdateParameters, options EmailTemplateCreateOrUpdateOperationOptions) (result EmailTemplateCreateOrUpdateOperationResponse, err error) { - req, err := c.preparerForEmailTemplateCreateOrUpdate(ctx, id, input, options) - if err != nil { - err = autorest.NewErrorWithError(err, "emailtemplates.EmailTemplatesClient", "EmailTemplateCreateOrUpdate", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "emailtemplates.EmailTemplatesClient", "EmailTemplateCreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForEmailTemplateCreateOrUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "emailtemplates.EmailTemplatesClient", "EmailTemplateCreateOrUpdate", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForEmailTemplateCreateOrUpdate prepares the EmailTemplateCreateOrUpdate request. -func (c EmailTemplatesClient) preparerForEmailTemplateCreateOrUpdate(ctx context.Context, id TemplateId, input EmailTemplateUpdateParameters, options EmailTemplateCreateOrUpdateOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForEmailTemplateCreateOrUpdate handles the response to the EmailTemplateCreateOrUpdate request. The method always -// closes the http.Response Body. -func (c EmailTemplatesClient) responderForEmailTemplateCreateOrUpdate(resp *http.Response) (result EmailTemplateCreateOrUpdateOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2021-08-01/emailtemplates/method_emailtemplatedelete.go b/resource-manager/apimanagement/2021-08-01/emailtemplates/method_emailtemplatedelete.go new file mode 100644 index 00000000000..0edd892ed23 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/emailtemplates/method_emailtemplatedelete.go @@ -0,0 +1,76 @@ +package emailtemplates + +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 EmailTemplateDeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +type EmailTemplateDeleteOperationOptions struct { + IfMatch *string +} + +func DefaultEmailTemplateDeleteOperationOptions() EmailTemplateDeleteOperationOptions { + return EmailTemplateDeleteOperationOptions{} +} + +func (o EmailTemplateDeleteOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o EmailTemplateDeleteOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o EmailTemplateDeleteOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// EmailTemplateDelete ... +func (c EmailTemplatesClient) EmailTemplateDelete(ctx context.Context, id TemplateId, options EmailTemplateDeleteOperationOptions) (result EmailTemplateDeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2021-08-01/emailtemplates/method_emailtemplatedelete_autorest.go b/resource-manager/apimanagement/2021-08-01/emailtemplates/method_emailtemplatedelete_autorest.go deleted file mode 100644 index ec2f991850a..00000000000 --- a/resource-manager/apimanagement/2021-08-01/emailtemplates/method_emailtemplatedelete_autorest.go +++ /dev/null @@ -1,95 +0,0 @@ -package emailtemplates - -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 EmailTemplateDeleteOperationResponse struct { - HttpResponse *http.Response -} - -type EmailTemplateDeleteOperationOptions struct { - IfMatch *string -} - -func DefaultEmailTemplateDeleteOperationOptions() EmailTemplateDeleteOperationOptions { - return EmailTemplateDeleteOperationOptions{} -} - -func (o EmailTemplateDeleteOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o EmailTemplateDeleteOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// EmailTemplateDelete ... -func (c EmailTemplatesClient) EmailTemplateDelete(ctx context.Context, id TemplateId, options EmailTemplateDeleteOperationOptions) (result EmailTemplateDeleteOperationResponse, err error) { - req, err := c.preparerForEmailTemplateDelete(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "emailtemplates.EmailTemplatesClient", "EmailTemplateDelete", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "emailtemplates.EmailTemplatesClient", "EmailTemplateDelete", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForEmailTemplateDelete(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "emailtemplates.EmailTemplatesClient", "EmailTemplateDelete", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForEmailTemplateDelete prepares the EmailTemplateDelete request. -func (c EmailTemplatesClient) preparerForEmailTemplateDelete(ctx context.Context, id TemplateId, options EmailTemplateDeleteOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForEmailTemplateDelete handles the response to the EmailTemplateDelete request. The method always -// closes the http.Response Body. -func (c EmailTemplatesClient) responderForEmailTemplateDelete(resp *http.Response) (result EmailTemplateDeleteOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2021-08-01/emailtemplates/method_emailtemplateget.go b/resource-manager/apimanagement/2021-08-01/emailtemplates/method_emailtemplateget.go new file mode 100644 index 00000000000..91bd3f56c3a --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/emailtemplates/method_emailtemplateget.go @@ -0,0 +1,51 @@ +package emailtemplates + +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 EmailTemplateGetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *EmailTemplateContract +} + +// EmailTemplateGet ... +func (c EmailTemplatesClient) EmailTemplateGet(ctx context.Context, id TemplateId) (result EmailTemplateGetOperationResponse, 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/apimanagement/2021-08-01/emailtemplates/method_emailtemplateget_autorest.go b/resource-manager/apimanagement/2021-08-01/emailtemplates/method_emailtemplateget_autorest.go deleted file mode 100644 index 42f4ac52fc2..00000000000 --- a/resource-manager/apimanagement/2021-08-01/emailtemplates/method_emailtemplateget_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package emailtemplates - -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 EmailTemplateGetOperationResponse struct { - HttpResponse *http.Response - Model *EmailTemplateContract -} - -// EmailTemplateGet ... -func (c EmailTemplatesClient) EmailTemplateGet(ctx context.Context, id TemplateId) (result EmailTemplateGetOperationResponse, err error) { - req, err := c.preparerForEmailTemplateGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "emailtemplates.EmailTemplatesClient", "EmailTemplateGet", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "emailtemplates.EmailTemplatesClient", "EmailTemplateGet", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForEmailTemplateGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "emailtemplates.EmailTemplatesClient", "EmailTemplateGet", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForEmailTemplateGet prepares the EmailTemplateGet request. -func (c EmailTemplatesClient) preparerForEmailTemplateGet(ctx context.Context, id TemplateId) (*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)) -} - -// responderForEmailTemplateGet handles the response to the EmailTemplateGet request. The method always -// closes the http.Response Body. -func (c EmailTemplatesClient) responderForEmailTemplateGet(resp *http.Response) (result EmailTemplateGetOperationResponse, 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/apimanagement/2021-08-01/emailtemplates/method_emailtemplategetentitytag.go b/resource-manager/apimanagement/2021-08-01/emailtemplates/method_emailtemplategetentitytag.go new file mode 100644 index 00000000000..fd7e5616549 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/emailtemplates/method_emailtemplategetentitytag.go @@ -0,0 +1,46 @@ +package emailtemplates + +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 EmailTemplateGetEntityTagOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// EmailTemplateGetEntityTag ... +func (c EmailTemplatesClient) EmailTemplateGetEntityTag(ctx context.Context, id TemplateId) (result EmailTemplateGetEntityTagOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodHead, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2021-08-01/emailtemplates/method_emailtemplategetentitytag_autorest.go b/resource-manager/apimanagement/2021-08-01/emailtemplates/method_emailtemplategetentitytag_autorest.go deleted file mode 100644 index 81853d22c98..00000000000 --- a/resource-manager/apimanagement/2021-08-01/emailtemplates/method_emailtemplategetentitytag_autorest.go +++ /dev/null @@ -1,66 +0,0 @@ -package emailtemplates - -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 EmailTemplateGetEntityTagOperationResponse struct { - HttpResponse *http.Response -} - -// EmailTemplateGetEntityTag ... -func (c EmailTemplatesClient) EmailTemplateGetEntityTag(ctx context.Context, id TemplateId) (result EmailTemplateGetEntityTagOperationResponse, err error) { - req, err := c.preparerForEmailTemplateGetEntityTag(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "emailtemplates.EmailTemplatesClient", "EmailTemplateGetEntityTag", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "emailtemplates.EmailTemplatesClient", "EmailTemplateGetEntityTag", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForEmailTemplateGetEntityTag(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "emailtemplates.EmailTemplatesClient", "EmailTemplateGetEntityTag", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForEmailTemplateGetEntityTag prepares the EmailTemplateGetEntityTag request. -func (c EmailTemplatesClient) preparerForEmailTemplateGetEntityTag(ctx context.Context, id TemplateId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsHead(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForEmailTemplateGetEntityTag handles the response to the EmailTemplateGetEntityTag request. The method always -// closes the http.Response Body. -func (c EmailTemplatesClient) responderForEmailTemplateGetEntityTag(resp *http.Response) (result EmailTemplateGetEntityTagOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2021-08-01/emailtemplates/method_emailtemplateupdate.go b/resource-manager/apimanagement/2021-08-01/emailtemplates/method_emailtemplateupdate.go new file mode 100644 index 00000000000..5e5c6f703f2 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/emailtemplates/method_emailtemplateupdate.go @@ -0,0 +1,84 @@ +package emailtemplates + +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 EmailTemplateUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *EmailTemplateContract +} + +type EmailTemplateUpdateOperationOptions struct { + IfMatch *string +} + +func DefaultEmailTemplateUpdateOperationOptions() EmailTemplateUpdateOperationOptions { + return EmailTemplateUpdateOperationOptions{} +} + +func (o EmailTemplateUpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o EmailTemplateUpdateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o EmailTemplateUpdateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// EmailTemplateUpdate ... +func (c EmailTemplatesClient) EmailTemplateUpdate(ctx context.Context, id TemplateId, input EmailTemplateUpdateParameters, options EmailTemplateUpdateOperationOptions) (result EmailTemplateUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + OptionsObject: options, + } + + 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/apimanagement/2021-08-01/emailtemplates/method_emailtemplateupdate_autorest.go b/resource-manager/apimanagement/2021-08-01/emailtemplates/method_emailtemplateupdate_autorest.go deleted file mode 100644 index c53ed3c1cf7..00000000000 --- a/resource-manager/apimanagement/2021-08-01/emailtemplates/method_emailtemplateupdate_autorest.go +++ /dev/null @@ -1,98 +0,0 @@ -package emailtemplates - -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 EmailTemplateUpdateOperationResponse struct { - HttpResponse *http.Response - Model *EmailTemplateContract -} - -type EmailTemplateUpdateOperationOptions struct { - IfMatch *string -} - -func DefaultEmailTemplateUpdateOperationOptions() EmailTemplateUpdateOperationOptions { - return EmailTemplateUpdateOperationOptions{} -} - -func (o EmailTemplateUpdateOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o EmailTemplateUpdateOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// EmailTemplateUpdate ... -func (c EmailTemplatesClient) EmailTemplateUpdate(ctx context.Context, id TemplateId, input EmailTemplateUpdateParameters, options EmailTemplateUpdateOperationOptions) (result EmailTemplateUpdateOperationResponse, err error) { - req, err := c.preparerForEmailTemplateUpdate(ctx, id, input, options) - if err != nil { - err = autorest.NewErrorWithError(err, "emailtemplates.EmailTemplatesClient", "EmailTemplateUpdate", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "emailtemplates.EmailTemplatesClient", "EmailTemplateUpdate", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForEmailTemplateUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "emailtemplates.EmailTemplatesClient", "EmailTemplateUpdate", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForEmailTemplateUpdate prepares the EmailTemplateUpdate request. -func (c EmailTemplatesClient) preparerForEmailTemplateUpdate(ctx context.Context, id TemplateId, input EmailTemplateUpdateParameters, options EmailTemplateUpdateOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPatch(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForEmailTemplateUpdate handles the response to the EmailTemplateUpdate request. The method always -// closes the http.Response Body. -func (c EmailTemplatesClient) responderForEmailTemplateUpdate(resp *http.Response) (result EmailTemplateUpdateOperationResponse, 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/apimanagement/2021-08-01/gateway/client.go b/resource-manager/apimanagement/2021-08-01/gateway/client.go index a88c9cdaf70..03f53b2017c 100644 --- a/resource-manager/apimanagement/2021-08-01/gateway/client.go +++ b/resource-manager/apimanagement/2021-08-01/gateway/client.go @@ -1,18 +1,26 @@ package gateway -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 GatewayClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewGatewayClientWithBaseURI(endpoint string) GatewayClient { - return GatewayClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewGatewayClientWithBaseURI(api environments.Api) (*GatewayClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "gateway", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating GatewayClient: %+v", err) } + + return &GatewayClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2021-08-01/gateway/method_createorupdate.go b/resource-manager/apimanagement/2021-08-01/gateway/method_createorupdate.go new file mode 100644 index 00000000000..b166d062bf3 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/gateway/method_createorupdate.go @@ -0,0 +1,85 @@ +package gateway + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *GatewayContract +} + +type CreateOrUpdateOperationOptions struct { + IfMatch *string +} + +func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { + return CreateOrUpdateOperationOptions{} +} + +func (o CreateOrUpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o CreateOrUpdateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o CreateOrUpdateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// CreateOrUpdate ... +func (c GatewayClient) CreateOrUpdate(ctx context.Context, id GatewayId, input GatewayContract, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + OptionsObject: options, + } + + 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/apimanagement/2021-08-01/gateway/method_createorupdate_autorest.go b/resource-manager/apimanagement/2021-08-01/gateway/method_createorupdate_autorest.go deleted file mode 100644 index 6dd5cff75d6..00000000000 --- a/resource-manager/apimanagement/2021-08-01/gateway/method_createorupdate_autorest.go +++ /dev/null @@ -1,98 +0,0 @@ -package gateway - -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 *GatewayContract -} - -type CreateOrUpdateOperationOptions struct { - IfMatch *string -} - -func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { - return CreateOrUpdateOperationOptions{} -} - -func (o CreateOrUpdateOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o CreateOrUpdateOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// CreateOrUpdate ... -func (c GatewayClient) CreateOrUpdate(ctx context.Context, id GatewayId, input GatewayContract, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdate(ctx, id, input, options) - if err != nil { - err = autorest.NewErrorWithError(err, "gateway.GatewayClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "gateway.GatewayClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCreateOrUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "gateway.GatewayClient", "CreateOrUpdate", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCreateOrUpdate prepares the CreateOrUpdate request. -func (c GatewayClient) preparerForCreateOrUpdate(ctx context.Context, id GatewayId, input GatewayContract, options CreateOrUpdateOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - 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 GatewayClient) responderForCreateOrUpdate(resp *http.Response) (result CreateOrUpdateOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2021-08-01/gateway/method_delete.go b/resource-manager/apimanagement/2021-08-01/gateway/method_delete.go new file mode 100644 index 00000000000..34c8698ad34 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/gateway/method_delete.go @@ -0,0 +1,76 @@ +package gateway + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +type DeleteOperationOptions struct { + IfMatch *string +} + +func DefaultDeleteOperationOptions() DeleteOperationOptions { + return DeleteOperationOptions{} +} + +func (o DeleteOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o DeleteOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o DeleteOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// Delete ... +func (c GatewayClient) Delete(ctx context.Context, id GatewayId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2021-08-01/gateway/method_delete_autorest.go b/resource-manager/apimanagement/2021-08-01/gateway/method_delete_autorest.go deleted file mode 100644 index 1f3f99da15b..00000000000 --- a/resource-manager/apimanagement/2021-08-01/gateway/method_delete_autorest.go +++ /dev/null @@ -1,95 +0,0 @@ -package gateway - -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 DeleteOperationResponse struct { - HttpResponse *http.Response -} - -type DeleteOperationOptions struct { - IfMatch *string -} - -func DefaultDeleteOperationOptions() DeleteOperationOptions { - return DeleteOperationOptions{} -} - -func (o DeleteOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o DeleteOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// Delete ... -func (c GatewayClient) Delete(ctx context.Context, id GatewayId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { - req, err := c.preparerForDelete(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "gateway.GatewayClient", "Delete", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "gateway.GatewayClient", "Delete", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForDelete(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "gateway.GatewayClient", "Delete", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForDelete prepares the Delete request. -func (c GatewayClient) preparerForDelete(ctx context.Context, id GatewayId, options DeleteOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForDelete handles the response to the Delete request. The method always -// closes the http.Response Body. -func (c GatewayClient) responderForDelete(resp *http.Response) (result DeleteOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2021-08-01/gateway/method_get.go b/resource-manager/apimanagement/2021-08-01/gateway/method_get.go new file mode 100644 index 00000000000..73393157e02 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/gateway/method_get.go @@ -0,0 +1,51 @@ +package gateway + +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 *GatewayContract +} + +// Get ... +func (c GatewayClient) Get(ctx context.Context, id GatewayId) (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/apimanagement/2021-08-01/gateway/method_get_autorest.go b/resource-manager/apimanagement/2021-08-01/gateway/method_get_autorest.go deleted file mode 100644 index 516262b26c0..00000000000 --- a/resource-manager/apimanagement/2021-08-01/gateway/method_get_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package gateway - -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 *GatewayContract -} - -// Get ... -func (c GatewayClient) Get(ctx context.Context, id GatewayId) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "gateway.GatewayClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "gateway.GatewayClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "gateway.GatewayClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c GatewayClient) preparerForGet(ctx context.Context, id GatewayId) (*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 GatewayClient) 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/apimanagement/2021-08-01/gateway/method_getentitytag.go b/resource-manager/apimanagement/2021-08-01/gateway/method_getentitytag.go new file mode 100644 index 00000000000..34c8cd8439b --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/gateway/method_getentitytag.go @@ -0,0 +1,46 @@ +package gateway + +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 GetEntityTagOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// GetEntityTag ... +func (c GatewayClient) GetEntityTag(ctx context.Context, id GatewayId) (result GetEntityTagOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodHead, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2021-08-01/gateway/method_getentitytag_autorest.go b/resource-manager/apimanagement/2021-08-01/gateway/method_getentitytag_autorest.go deleted file mode 100644 index 023b4dd2c1b..00000000000 --- a/resource-manager/apimanagement/2021-08-01/gateway/method_getentitytag_autorest.go +++ /dev/null @@ -1,66 +0,0 @@ -package gateway - -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 GetEntityTagOperationResponse struct { - HttpResponse *http.Response -} - -// GetEntityTag ... -func (c GatewayClient) GetEntityTag(ctx context.Context, id GatewayId) (result GetEntityTagOperationResponse, err error) { - req, err := c.preparerForGetEntityTag(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "gateway.GatewayClient", "GetEntityTag", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "gateway.GatewayClient", "GetEntityTag", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetEntityTag(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "gateway.GatewayClient", "GetEntityTag", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetEntityTag prepares the GetEntityTag request. -func (c GatewayClient) preparerForGetEntityTag(ctx context.Context, id GatewayId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsHead(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetEntityTag handles the response to the GetEntityTag request. The method always -// closes the http.Response Body. -func (c GatewayClient) responderForGetEntityTag(resp *http.Response) (result GetEntityTagOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2021-08-01/gateway/method_listbyservice.go b/resource-manager/apimanagement/2021-08-01/gateway/method_listbyservice.go new file mode 100644 index 00000000000..2e1953f23da --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/gateway/method_listbyservice.go @@ -0,0 +1,125 @@ +package gateway + +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 ListByServiceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]GatewayContract +} + +type ListByServiceCompleteResult struct { + Items []GatewayContract +} + +type ListByServiceOperationOptions struct { + Filter *string + Skip *int64 + Top *int64 +} + +func DefaultListByServiceOperationOptions() ListByServiceOperationOptions { + return ListByServiceOperationOptions{} +} + +func (o ListByServiceOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListByServiceOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListByServiceOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.Skip != nil { + out.Append("$skip", fmt.Sprintf("%v", *o.Skip)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +// ListByService ... +func (c GatewayClient) ListByService(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (result ListByServiceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/gateways", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]GatewayContract `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByServiceComplete retrieves all the results into a single object +func (c GatewayClient) ListByServiceComplete(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (ListByServiceCompleteResult, error) { + return c.ListByServiceCompleteMatchingPredicate(ctx, id, options, GatewayContractOperationPredicate{}) +} + +// ListByServiceCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c GatewayClient) ListByServiceCompleteMatchingPredicate(ctx context.Context, id ServiceId, options ListByServiceOperationOptions, predicate GatewayContractOperationPredicate) (result ListByServiceCompleteResult, err error) { + items := make([]GatewayContract, 0) + + resp, err := c.ListByService(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByServiceCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/apimanagement/2021-08-01/gateway/method_listbyservice_autorest.go b/resource-manager/apimanagement/2021-08-01/gateway/method_listbyservice_autorest.go deleted file mode 100644 index 6bef69b64f7..00000000000 --- a/resource-manager/apimanagement/2021-08-01/gateway/method_listbyservice_autorest.go +++ /dev/null @@ -1,225 +0,0 @@ -package gateway - -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 ListByServiceOperationResponse struct { - HttpResponse *http.Response - Model *[]GatewayContract - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListByServiceOperationResponse, error) -} - -type ListByServiceCompleteResult struct { - Items []GatewayContract -} - -func (r ListByServiceOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListByServiceOperationResponse) LoadMore(ctx context.Context) (resp ListByServiceOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -type ListByServiceOperationOptions struct { - Filter *string - Skip *int64 - Top *int64 -} - -func DefaultListByServiceOperationOptions() ListByServiceOperationOptions { - return ListByServiceOperationOptions{} -} - -func (o ListByServiceOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o ListByServiceOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Filter != nil { - out["$filter"] = *o.Filter - } - - if o.Skip != nil { - out["$skip"] = *o.Skip - } - - if o.Top != nil { - out["$top"] = *o.Top - } - - return out -} - -// ListByService ... -func (c GatewayClient) ListByService(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (resp ListByServiceOperationResponse, err error) { - req, err := c.preparerForListByService(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "gateway.GatewayClient", "ListByService", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "gateway.GatewayClient", "ListByService", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListByService(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "gateway.GatewayClient", "ListByService", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListByService prepares the ListByService request. -func (c GatewayClient) preparerForListByService(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/gateways", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListByServiceWithNextLink prepares the ListByService request with the given nextLink token. -func (c GatewayClient) preparerForListByServiceWithNextLink(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)) -} - -// responderForListByService handles the response to the ListByService request. The method always -// closes the http.Response Body. -func (c GatewayClient) responderForListByService(resp *http.Response) (result ListByServiceOperationResponse, err error) { - type page struct { - Values []GatewayContract `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 ListByServiceOperationResponse, err error) { - req, err := c.preparerForListByServiceWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "gateway.GatewayClient", "ListByService", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "gateway.GatewayClient", "ListByService", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByService(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "gateway.GatewayClient", "ListByService", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListByServiceComplete retrieves all of the results into a single object -func (c GatewayClient) ListByServiceComplete(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (ListByServiceCompleteResult, error) { - return c.ListByServiceCompleteMatchingPredicate(ctx, id, options, GatewayContractOperationPredicate{}) -} - -// ListByServiceCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c GatewayClient) ListByServiceCompleteMatchingPredicate(ctx context.Context, id ServiceId, options ListByServiceOperationOptions, predicate GatewayContractOperationPredicate) (resp ListByServiceCompleteResult, err error) { - items := make([]GatewayContract, 0) - - page, err := c.ListByService(ctx, id, options) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListByServiceCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/apimanagement/2021-08-01/gateway/method_update.go b/resource-manager/apimanagement/2021-08-01/gateway/method_update.go new file mode 100644 index 00000000000..fcf2126f5bd --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/gateway/method_update.go @@ -0,0 +1,84 @@ +package gateway + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *GatewayContract +} + +type UpdateOperationOptions struct { + IfMatch *string +} + +func DefaultUpdateOperationOptions() UpdateOperationOptions { + return UpdateOperationOptions{} +} + +func (o UpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o UpdateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o UpdateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// Update ... +func (c GatewayClient) Update(ctx context.Context, id GatewayId, input GatewayContract, options UpdateOperationOptions) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + OptionsObject: options, + } + + 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/apimanagement/2021-08-01/gateway/method_update_autorest.go b/resource-manager/apimanagement/2021-08-01/gateway/method_update_autorest.go deleted file mode 100644 index f307a2b614f..00000000000 --- a/resource-manager/apimanagement/2021-08-01/gateway/method_update_autorest.go +++ /dev/null @@ -1,98 +0,0 @@ -package gateway - -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 *GatewayContract -} - -type UpdateOperationOptions struct { - IfMatch *string -} - -func DefaultUpdateOperationOptions() UpdateOperationOptions { - return UpdateOperationOptions{} -} - -func (o UpdateOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o UpdateOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// Update ... -func (c GatewayClient) Update(ctx context.Context, id GatewayId, input GatewayContract, options UpdateOperationOptions) (result UpdateOperationResponse, err error) { - req, err := c.preparerForUpdate(ctx, id, input, options) - if err != nil { - err = autorest.NewErrorWithError(err, "gateway.GatewayClient", "Update", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "gateway.GatewayClient", "Update", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "gateway.GatewayClient", "Update", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForUpdate prepares the Update request. -func (c GatewayClient) preparerForUpdate(ctx context.Context, id GatewayId, input GatewayContract, options UpdateOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPatch(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - 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 GatewayClient) 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/apimanagement/2021-08-01/gatewayapi/client.go b/resource-manager/apimanagement/2021-08-01/gatewayapi/client.go index 46a46094cd5..e697610f2b9 100644 --- a/resource-manager/apimanagement/2021-08-01/gatewayapi/client.go +++ b/resource-manager/apimanagement/2021-08-01/gatewayapi/client.go @@ -1,18 +1,26 @@ package gatewayapi -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 GatewayApiClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewGatewayApiClientWithBaseURI(endpoint string) GatewayApiClient { - return GatewayApiClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewGatewayApiClientWithBaseURI(api environments.Api) (*GatewayApiClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "gatewayapi", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating GatewayApiClient: %+v", err) } + + return &GatewayApiClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2021-08-01/gatewayapi/constants.go b/resource-manager/apimanagement/2021-08-01/gatewayapi/constants.go index 0be8c860d66..0da8f569039 100644 --- a/resource-manager/apimanagement/2021-08-01/gatewayapi/constants.go +++ b/resource-manager/apimanagement/2021-08-01/gatewayapi/constants.go @@ -1,6 +1,10 @@ package gatewayapi -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 PossibleValuesForApiType() []string { } } +func (s *ApiType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseApiType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseApiType(input string) (*ApiType, error) { vals := map[string]ApiType{ "graphql": ApiTypeGraphql, @@ -53,6 +70,19 @@ func PossibleValuesForBearerTokenSendingMethods() []string { } } +func (s *BearerTokenSendingMethods) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseBearerTokenSendingMethods(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseBearerTokenSendingMethods(input string) (*BearerTokenSendingMethods, error) { vals := map[string]BearerTokenSendingMethods{ "authorizationheader": BearerTokenSendingMethodsAuthorizationHeader, @@ -85,6 +115,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{ "http": ProtocolHTTP, @@ -113,6 +156,19 @@ func PossibleValuesForProvisioningState() []string { } } +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseProvisioningState(input string) (*ProvisioningState, error) { vals := map[string]ProvisioningState{ "created": ProvisioningStateCreated, @@ -142,6 +198,19 @@ func PossibleValuesForVersioningScheme() []string { } } +func (s *VersioningScheme) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseVersioningScheme(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseVersioningScheme(input string) (*VersioningScheme, error) { vals := map[string]VersioningScheme{ "header": VersioningSchemeHeader, diff --git a/resource-manager/apimanagement/2021-08-01/gatewayapi/method_createorupdate.go b/resource-manager/apimanagement/2021-08-01/gatewayapi/method_createorupdate.go new file mode 100644 index 00000000000..8fd635de876 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/gatewayapi/method_createorupdate.go @@ -0,0 +1,56 @@ +package gatewayapi + +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 *ApiContract +} + +// CreateOrUpdate ... +func (c GatewayApiClient) CreateOrUpdate(ctx context.Context, id GatewayApiId, input AssociationContract) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + if err = resp.Unmarshal(&result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2021-08-01/gatewayapi/method_createorupdate_autorest.go b/resource-manager/apimanagement/2021-08-01/gatewayapi/method_createorupdate_autorest.go deleted file mode 100644 index e8e7ed2c7aa..00000000000 --- a/resource-manager/apimanagement/2021-08-01/gatewayapi/method_createorupdate_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package gatewayapi - -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 *ApiContract -} - -// CreateOrUpdate ... -func (c GatewayApiClient) CreateOrUpdate(ctx context.Context, id GatewayApiId, input AssociationContract) (result CreateOrUpdateOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "gatewayapi.GatewayApiClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "gatewayapi.GatewayApiClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCreateOrUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "gatewayapi.GatewayApiClient", "CreateOrUpdate", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCreateOrUpdate prepares the CreateOrUpdate request. -func (c GatewayApiClient) preparerForCreateOrUpdate(ctx context.Context, id GatewayApiId, input AssociationContract) (*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 GatewayApiClient) responderForCreateOrUpdate(resp *http.Response) (result CreateOrUpdateOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2021-08-01/gatewayapi/method_delete.go b/resource-manager/apimanagement/2021-08-01/gatewayapi/method_delete.go new file mode 100644 index 00000000000..293176f784a --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/gatewayapi/method_delete.go @@ -0,0 +1,47 @@ +package gatewayapi + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c GatewayApiClient) Delete(ctx context.Context, id GatewayApiId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2021-08-01/gatewayapi/method_delete_autorest.go b/resource-manager/apimanagement/2021-08-01/gatewayapi/method_delete_autorest.go deleted file mode 100644 index 5da91051687..00000000000 --- a/resource-manager/apimanagement/2021-08-01/gatewayapi/method_delete_autorest.go +++ /dev/null @@ -1,66 +0,0 @@ -package gatewayapi - -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 DeleteOperationResponse struct { - HttpResponse *http.Response -} - -// Delete ... -func (c GatewayApiClient) Delete(ctx context.Context, id GatewayApiId) (result DeleteOperationResponse, err error) { - req, err := c.preparerForDelete(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "gatewayapi.GatewayApiClient", "Delete", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "gatewayapi.GatewayApiClient", "Delete", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForDelete(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "gatewayapi.GatewayApiClient", "Delete", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForDelete prepares the Delete request. -func (c GatewayApiClient) preparerForDelete(ctx context.Context, id GatewayApiId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForDelete handles the response to the Delete request. The method always -// closes the http.Response Body. -func (c GatewayApiClient) responderForDelete(resp *http.Response) (result DeleteOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2021-08-01/gatewayapi/method_getentitytag.go b/resource-manager/apimanagement/2021-08-01/gatewayapi/method_getentitytag.go new file mode 100644 index 00000000000..e14c0b61f72 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/gatewayapi/method_getentitytag.go @@ -0,0 +1,46 @@ +package gatewayapi + +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 GetEntityTagOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// GetEntityTag ... +func (c GatewayApiClient) GetEntityTag(ctx context.Context, id GatewayApiId) (result GetEntityTagOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodHead, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2021-08-01/gatewayapi/method_getentitytag_autorest.go b/resource-manager/apimanagement/2021-08-01/gatewayapi/method_getentitytag_autorest.go deleted file mode 100644 index 9d658fd84a6..00000000000 --- a/resource-manager/apimanagement/2021-08-01/gatewayapi/method_getentitytag_autorest.go +++ /dev/null @@ -1,66 +0,0 @@ -package gatewayapi - -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 GetEntityTagOperationResponse struct { - HttpResponse *http.Response -} - -// GetEntityTag ... -func (c GatewayApiClient) GetEntityTag(ctx context.Context, id GatewayApiId) (result GetEntityTagOperationResponse, err error) { - req, err := c.preparerForGetEntityTag(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "gatewayapi.GatewayApiClient", "GetEntityTag", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "gatewayapi.GatewayApiClient", "GetEntityTag", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetEntityTag(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "gatewayapi.GatewayApiClient", "GetEntityTag", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetEntityTag prepares the GetEntityTag request. -func (c GatewayApiClient) preparerForGetEntityTag(ctx context.Context, id GatewayApiId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsHead(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetEntityTag handles the response to the GetEntityTag request. The method always -// closes the http.Response Body. -func (c GatewayApiClient) responderForGetEntityTag(resp *http.Response) (result GetEntityTagOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2021-08-01/gatewayapi/method_listbyservice.go b/resource-manager/apimanagement/2021-08-01/gatewayapi/method_listbyservice.go new file mode 100644 index 00000000000..478f87c8195 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/gatewayapi/method_listbyservice.go @@ -0,0 +1,125 @@ +package gatewayapi + +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 ListByServiceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ApiContract +} + +type ListByServiceCompleteResult struct { + Items []ApiContract +} + +type ListByServiceOperationOptions struct { + Filter *string + Skip *int64 + Top *int64 +} + +func DefaultListByServiceOperationOptions() ListByServiceOperationOptions { + return ListByServiceOperationOptions{} +} + +func (o ListByServiceOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListByServiceOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListByServiceOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.Skip != nil { + out.Append("$skip", fmt.Sprintf("%v", *o.Skip)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +// ListByService ... +func (c GatewayApiClient) ListByService(ctx context.Context, id GatewayId, options ListByServiceOperationOptions) (result ListByServiceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/apis", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ApiContract `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByServiceComplete retrieves all the results into a single object +func (c GatewayApiClient) ListByServiceComplete(ctx context.Context, id GatewayId, options ListByServiceOperationOptions) (ListByServiceCompleteResult, error) { + return c.ListByServiceCompleteMatchingPredicate(ctx, id, options, ApiContractOperationPredicate{}) +} + +// ListByServiceCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c GatewayApiClient) ListByServiceCompleteMatchingPredicate(ctx context.Context, id GatewayId, options ListByServiceOperationOptions, predicate ApiContractOperationPredicate) (result ListByServiceCompleteResult, err error) { + items := make([]ApiContract, 0) + + resp, err := c.ListByService(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByServiceCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/apimanagement/2021-08-01/gatewayapi/method_listbyservice_autorest.go b/resource-manager/apimanagement/2021-08-01/gatewayapi/method_listbyservice_autorest.go deleted file mode 100644 index d219bb643d7..00000000000 --- a/resource-manager/apimanagement/2021-08-01/gatewayapi/method_listbyservice_autorest.go +++ /dev/null @@ -1,225 +0,0 @@ -package gatewayapi - -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 ListByServiceOperationResponse struct { - HttpResponse *http.Response - Model *[]ApiContract - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListByServiceOperationResponse, error) -} - -type ListByServiceCompleteResult struct { - Items []ApiContract -} - -func (r ListByServiceOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListByServiceOperationResponse) LoadMore(ctx context.Context) (resp ListByServiceOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -type ListByServiceOperationOptions struct { - Filter *string - Skip *int64 - Top *int64 -} - -func DefaultListByServiceOperationOptions() ListByServiceOperationOptions { - return ListByServiceOperationOptions{} -} - -func (o ListByServiceOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o ListByServiceOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Filter != nil { - out["$filter"] = *o.Filter - } - - if o.Skip != nil { - out["$skip"] = *o.Skip - } - - if o.Top != nil { - out["$top"] = *o.Top - } - - return out -} - -// ListByService ... -func (c GatewayApiClient) ListByService(ctx context.Context, id GatewayId, options ListByServiceOperationOptions) (resp ListByServiceOperationResponse, err error) { - req, err := c.preparerForListByService(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "gatewayapi.GatewayApiClient", "ListByService", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "gatewayapi.GatewayApiClient", "ListByService", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListByService(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "gatewayapi.GatewayApiClient", "ListByService", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListByService prepares the ListByService request. -func (c GatewayApiClient) preparerForListByService(ctx context.Context, id GatewayId, options ListByServiceOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/apis", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListByServiceWithNextLink prepares the ListByService request with the given nextLink token. -func (c GatewayApiClient) preparerForListByServiceWithNextLink(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)) -} - -// responderForListByService handles the response to the ListByService request. The method always -// closes the http.Response Body. -func (c GatewayApiClient) responderForListByService(resp *http.Response) (result ListByServiceOperationResponse, err error) { - type page struct { - Values []ApiContract `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 ListByServiceOperationResponse, err error) { - req, err := c.preparerForListByServiceWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "gatewayapi.GatewayApiClient", "ListByService", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "gatewayapi.GatewayApiClient", "ListByService", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByService(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "gatewayapi.GatewayApiClient", "ListByService", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListByServiceComplete retrieves all of the results into a single object -func (c GatewayApiClient) ListByServiceComplete(ctx context.Context, id GatewayId, options ListByServiceOperationOptions) (ListByServiceCompleteResult, error) { - return c.ListByServiceCompleteMatchingPredicate(ctx, id, options, ApiContractOperationPredicate{}) -} - -// ListByServiceCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c GatewayApiClient) ListByServiceCompleteMatchingPredicate(ctx context.Context, id GatewayId, options ListByServiceOperationOptions, predicate ApiContractOperationPredicate) (resp ListByServiceCompleteResult, err error) { - items := make([]ApiContract, 0) - - page, err := c.ListByService(ctx, id, options) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListByServiceCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/apimanagement/2021-08-01/gatewaycertificateauthority/client.go b/resource-manager/apimanagement/2021-08-01/gatewaycertificateauthority/client.go index 05f22b3b215..43210db9dbb 100644 --- a/resource-manager/apimanagement/2021-08-01/gatewaycertificateauthority/client.go +++ b/resource-manager/apimanagement/2021-08-01/gatewaycertificateauthority/client.go @@ -1,18 +1,26 @@ package gatewaycertificateauthority -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 GatewayCertificateAuthorityClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewGatewayCertificateAuthorityClientWithBaseURI(endpoint string) GatewayCertificateAuthorityClient { - return GatewayCertificateAuthorityClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewGatewayCertificateAuthorityClientWithBaseURI(api environments.Api) (*GatewayCertificateAuthorityClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "gatewaycertificateauthority", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating GatewayCertificateAuthorityClient: %+v", err) } + + return &GatewayCertificateAuthorityClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2021-08-01/gatewaycertificateauthority/method_createorupdate.go b/resource-manager/apimanagement/2021-08-01/gatewaycertificateauthority/method_createorupdate.go new file mode 100644 index 00000000000..a982aaf94c4 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/gatewaycertificateauthority/method_createorupdate.go @@ -0,0 +1,85 @@ +package gatewaycertificateauthority + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *GatewayCertificateAuthorityContract +} + +type CreateOrUpdateOperationOptions struct { + IfMatch *string +} + +func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { + return CreateOrUpdateOperationOptions{} +} + +func (o CreateOrUpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o CreateOrUpdateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o CreateOrUpdateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// CreateOrUpdate ... +func (c GatewayCertificateAuthorityClient) CreateOrUpdate(ctx context.Context, id CertificateAuthorityId, input GatewayCertificateAuthorityContract, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + OptionsObject: options, + } + + 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/apimanagement/2021-08-01/gatewaycertificateauthority/method_createorupdate_autorest.go b/resource-manager/apimanagement/2021-08-01/gatewaycertificateauthority/method_createorupdate_autorest.go deleted file mode 100644 index 4e7230468d3..00000000000 --- a/resource-manager/apimanagement/2021-08-01/gatewaycertificateauthority/method_createorupdate_autorest.go +++ /dev/null @@ -1,98 +0,0 @@ -package gatewaycertificateauthority - -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 *GatewayCertificateAuthorityContract -} - -type CreateOrUpdateOperationOptions struct { - IfMatch *string -} - -func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { - return CreateOrUpdateOperationOptions{} -} - -func (o CreateOrUpdateOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o CreateOrUpdateOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// CreateOrUpdate ... -func (c GatewayCertificateAuthorityClient) CreateOrUpdate(ctx context.Context, id CertificateAuthorityId, input GatewayCertificateAuthorityContract, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdate(ctx, id, input, options) - if err != nil { - err = autorest.NewErrorWithError(err, "gatewaycertificateauthority.GatewayCertificateAuthorityClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "gatewaycertificateauthority.GatewayCertificateAuthorityClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCreateOrUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "gatewaycertificateauthority.GatewayCertificateAuthorityClient", "CreateOrUpdate", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCreateOrUpdate prepares the CreateOrUpdate request. -func (c GatewayCertificateAuthorityClient) preparerForCreateOrUpdate(ctx context.Context, id CertificateAuthorityId, input GatewayCertificateAuthorityContract, options CreateOrUpdateOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - 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 GatewayCertificateAuthorityClient) responderForCreateOrUpdate(resp *http.Response) (result CreateOrUpdateOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2021-08-01/gatewaycertificateauthority/method_delete.go b/resource-manager/apimanagement/2021-08-01/gatewaycertificateauthority/method_delete.go new file mode 100644 index 00000000000..ee1deb63010 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/gatewaycertificateauthority/method_delete.go @@ -0,0 +1,76 @@ +package gatewaycertificateauthority + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +type DeleteOperationOptions struct { + IfMatch *string +} + +func DefaultDeleteOperationOptions() DeleteOperationOptions { + return DeleteOperationOptions{} +} + +func (o DeleteOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o DeleteOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o DeleteOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// Delete ... +func (c GatewayCertificateAuthorityClient) Delete(ctx context.Context, id CertificateAuthorityId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2021-08-01/gatewaycertificateauthority/method_delete_autorest.go b/resource-manager/apimanagement/2021-08-01/gatewaycertificateauthority/method_delete_autorest.go deleted file mode 100644 index 0f9df6ed8a0..00000000000 --- a/resource-manager/apimanagement/2021-08-01/gatewaycertificateauthority/method_delete_autorest.go +++ /dev/null @@ -1,95 +0,0 @@ -package gatewaycertificateauthority - -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 DeleteOperationResponse struct { - HttpResponse *http.Response -} - -type DeleteOperationOptions struct { - IfMatch *string -} - -func DefaultDeleteOperationOptions() DeleteOperationOptions { - return DeleteOperationOptions{} -} - -func (o DeleteOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o DeleteOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// Delete ... -func (c GatewayCertificateAuthorityClient) Delete(ctx context.Context, id CertificateAuthorityId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { - req, err := c.preparerForDelete(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "gatewaycertificateauthority.GatewayCertificateAuthorityClient", "Delete", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "gatewaycertificateauthority.GatewayCertificateAuthorityClient", "Delete", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForDelete(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "gatewaycertificateauthority.GatewayCertificateAuthorityClient", "Delete", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForDelete prepares the Delete request. -func (c GatewayCertificateAuthorityClient) preparerForDelete(ctx context.Context, id CertificateAuthorityId, options DeleteOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForDelete handles the response to the Delete request. The method always -// closes the http.Response Body. -func (c GatewayCertificateAuthorityClient) responderForDelete(resp *http.Response) (result DeleteOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2021-08-01/gatewaycertificateauthority/method_get.go b/resource-manager/apimanagement/2021-08-01/gatewaycertificateauthority/method_get.go new file mode 100644 index 00000000000..12ff864df7c --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/gatewaycertificateauthority/method_get.go @@ -0,0 +1,51 @@ +package gatewaycertificateauthority + +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 *GatewayCertificateAuthorityContract +} + +// Get ... +func (c GatewayCertificateAuthorityClient) Get(ctx context.Context, id CertificateAuthorityId) (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/apimanagement/2021-08-01/gatewaycertificateauthority/method_get_autorest.go b/resource-manager/apimanagement/2021-08-01/gatewaycertificateauthority/method_get_autorest.go deleted file mode 100644 index c858b3b46b5..00000000000 --- a/resource-manager/apimanagement/2021-08-01/gatewaycertificateauthority/method_get_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package gatewaycertificateauthority - -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 *GatewayCertificateAuthorityContract -} - -// Get ... -func (c GatewayCertificateAuthorityClient) Get(ctx context.Context, id CertificateAuthorityId) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "gatewaycertificateauthority.GatewayCertificateAuthorityClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "gatewaycertificateauthority.GatewayCertificateAuthorityClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "gatewaycertificateauthority.GatewayCertificateAuthorityClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c GatewayCertificateAuthorityClient) preparerForGet(ctx context.Context, id CertificateAuthorityId) (*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 GatewayCertificateAuthorityClient) 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/apimanagement/2021-08-01/gatewaycertificateauthority/method_getentitytag.go b/resource-manager/apimanagement/2021-08-01/gatewaycertificateauthority/method_getentitytag.go new file mode 100644 index 00000000000..cc382dbb6d8 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/gatewaycertificateauthority/method_getentitytag.go @@ -0,0 +1,46 @@ +package gatewaycertificateauthority + +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 GetEntityTagOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// GetEntityTag ... +func (c GatewayCertificateAuthorityClient) GetEntityTag(ctx context.Context, id CertificateAuthorityId) (result GetEntityTagOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodHead, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2021-08-01/gatewaycertificateauthority/method_getentitytag_autorest.go b/resource-manager/apimanagement/2021-08-01/gatewaycertificateauthority/method_getentitytag_autorest.go deleted file mode 100644 index 642eee2277d..00000000000 --- a/resource-manager/apimanagement/2021-08-01/gatewaycertificateauthority/method_getentitytag_autorest.go +++ /dev/null @@ -1,66 +0,0 @@ -package gatewaycertificateauthority - -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 GetEntityTagOperationResponse struct { - HttpResponse *http.Response -} - -// GetEntityTag ... -func (c GatewayCertificateAuthorityClient) GetEntityTag(ctx context.Context, id CertificateAuthorityId) (result GetEntityTagOperationResponse, err error) { - req, err := c.preparerForGetEntityTag(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "gatewaycertificateauthority.GatewayCertificateAuthorityClient", "GetEntityTag", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "gatewaycertificateauthority.GatewayCertificateAuthorityClient", "GetEntityTag", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetEntityTag(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "gatewaycertificateauthority.GatewayCertificateAuthorityClient", "GetEntityTag", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetEntityTag prepares the GetEntityTag request. -func (c GatewayCertificateAuthorityClient) preparerForGetEntityTag(ctx context.Context, id CertificateAuthorityId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsHead(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetEntityTag handles the response to the GetEntityTag request. The method always -// closes the http.Response Body. -func (c GatewayCertificateAuthorityClient) responderForGetEntityTag(resp *http.Response) (result GetEntityTagOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2021-08-01/gatewaycertificateauthority/method_listbyservice.go b/resource-manager/apimanagement/2021-08-01/gatewaycertificateauthority/method_listbyservice.go new file mode 100644 index 00000000000..3b24a4a53a6 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/gatewaycertificateauthority/method_listbyservice.go @@ -0,0 +1,125 @@ +package gatewaycertificateauthority + +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 ListByServiceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]GatewayCertificateAuthorityContract +} + +type ListByServiceCompleteResult struct { + Items []GatewayCertificateAuthorityContract +} + +type ListByServiceOperationOptions struct { + Filter *string + Skip *int64 + Top *int64 +} + +func DefaultListByServiceOperationOptions() ListByServiceOperationOptions { + return ListByServiceOperationOptions{} +} + +func (o ListByServiceOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListByServiceOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListByServiceOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.Skip != nil { + out.Append("$skip", fmt.Sprintf("%v", *o.Skip)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +// ListByService ... +func (c GatewayCertificateAuthorityClient) ListByService(ctx context.Context, id GatewayId, options ListByServiceOperationOptions) (result ListByServiceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/certificateAuthorities", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]GatewayCertificateAuthorityContract `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByServiceComplete retrieves all the results into a single object +func (c GatewayCertificateAuthorityClient) ListByServiceComplete(ctx context.Context, id GatewayId, options ListByServiceOperationOptions) (ListByServiceCompleteResult, error) { + return c.ListByServiceCompleteMatchingPredicate(ctx, id, options, GatewayCertificateAuthorityContractOperationPredicate{}) +} + +// ListByServiceCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c GatewayCertificateAuthorityClient) ListByServiceCompleteMatchingPredicate(ctx context.Context, id GatewayId, options ListByServiceOperationOptions, predicate GatewayCertificateAuthorityContractOperationPredicate) (result ListByServiceCompleteResult, err error) { + items := make([]GatewayCertificateAuthorityContract, 0) + + resp, err := c.ListByService(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByServiceCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/apimanagement/2021-08-01/gatewaycertificateauthority/method_listbyservice_autorest.go b/resource-manager/apimanagement/2021-08-01/gatewaycertificateauthority/method_listbyservice_autorest.go deleted file mode 100644 index e629cd90912..00000000000 --- a/resource-manager/apimanagement/2021-08-01/gatewaycertificateauthority/method_listbyservice_autorest.go +++ /dev/null @@ -1,225 +0,0 @@ -package gatewaycertificateauthority - -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 ListByServiceOperationResponse struct { - HttpResponse *http.Response - Model *[]GatewayCertificateAuthorityContract - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListByServiceOperationResponse, error) -} - -type ListByServiceCompleteResult struct { - Items []GatewayCertificateAuthorityContract -} - -func (r ListByServiceOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListByServiceOperationResponse) LoadMore(ctx context.Context) (resp ListByServiceOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -type ListByServiceOperationOptions struct { - Filter *string - Skip *int64 - Top *int64 -} - -func DefaultListByServiceOperationOptions() ListByServiceOperationOptions { - return ListByServiceOperationOptions{} -} - -func (o ListByServiceOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o ListByServiceOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Filter != nil { - out["$filter"] = *o.Filter - } - - if o.Skip != nil { - out["$skip"] = *o.Skip - } - - if o.Top != nil { - out["$top"] = *o.Top - } - - return out -} - -// ListByService ... -func (c GatewayCertificateAuthorityClient) ListByService(ctx context.Context, id GatewayId, options ListByServiceOperationOptions) (resp ListByServiceOperationResponse, err error) { - req, err := c.preparerForListByService(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "gatewaycertificateauthority.GatewayCertificateAuthorityClient", "ListByService", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "gatewaycertificateauthority.GatewayCertificateAuthorityClient", "ListByService", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListByService(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "gatewaycertificateauthority.GatewayCertificateAuthorityClient", "ListByService", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListByService prepares the ListByService request. -func (c GatewayCertificateAuthorityClient) preparerForListByService(ctx context.Context, id GatewayId, options ListByServiceOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/certificateAuthorities", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListByServiceWithNextLink prepares the ListByService request with the given nextLink token. -func (c GatewayCertificateAuthorityClient) preparerForListByServiceWithNextLink(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)) -} - -// responderForListByService handles the response to the ListByService request. The method always -// closes the http.Response Body. -func (c GatewayCertificateAuthorityClient) responderForListByService(resp *http.Response) (result ListByServiceOperationResponse, err error) { - type page struct { - Values []GatewayCertificateAuthorityContract `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 ListByServiceOperationResponse, err error) { - req, err := c.preparerForListByServiceWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "gatewaycertificateauthority.GatewayCertificateAuthorityClient", "ListByService", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "gatewaycertificateauthority.GatewayCertificateAuthorityClient", "ListByService", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByService(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "gatewaycertificateauthority.GatewayCertificateAuthorityClient", "ListByService", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListByServiceComplete retrieves all of the results into a single object -func (c GatewayCertificateAuthorityClient) ListByServiceComplete(ctx context.Context, id GatewayId, options ListByServiceOperationOptions) (ListByServiceCompleteResult, error) { - return c.ListByServiceCompleteMatchingPredicate(ctx, id, options, GatewayCertificateAuthorityContractOperationPredicate{}) -} - -// ListByServiceCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c GatewayCertificateAuthorityClient) ListByServiceCompleteMatchingPredicate(ctx context.Context, id GatewayId, options ListByServiceOperationOptions, predicate GatewayCertificateAuthorityContractOperationPredicate) (resp ListByServiceCompleteResult, err error) { - items := make([]GatewayCertificateAuthorityContract, 0) - - page, err := c.ListByService(ctx, id, options) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListByServiceCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/apimanagement/2021-08-01/gatewaygeneratetoken/client.go b/resource-manager/apimanagement/2021-08-01/gatewaygeneratetoken/client.go index 5eef6f835aa..d2ebe3b89b3 100644 --- a/resource-manager/apimanagement/2021-08-01/gatewaygeneratetoken/client.go +++ b/resource-manager/apimanagement/2021-08-01/gatewaygeneratetoken/client.go @@ -1,18 +1,26 @@ package gatewaygeneratetoken -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 GatewayGenerateTokenClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewGatewayGenerateTokenClientWithBaseURI(endpoint string) GatewayGenerateTokenClient { - return GatewayGenerateTokenClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewGatewayGenerateTokenClientWithBaseURI(api environments.Api) (*GatewayGenerateTokenClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "gatewaygeneratetoken", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating GatewayGenerateTokenClient: %+v", err) } + + return &GatewayGenerateTokenClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2021-08-01/gatewaygeneratetoken/constants.go b/resource-manager/apimanagement/2021-08-01/gatewaygeneratetoken/constants.go index 2b5b29d0556..23e4c225a32 100644 --- a/resource-manager/apimanagement/2021-08-01/gatewaygeneratetoken/constants.go +++ b/resource-manager/apimanagement/2021-08-01/gatewaygeneratetoken/constants.go @@ -1,6 +1,10 @@ package gatewaygeneratetoken -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 PossibleValuesForKeyType() []string { } } +func (s *KeyType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseKeyType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseKeyType(input string) (*KeyType, error) { vals := map[string]KeyType{ "primary": KeyTypePrimary, diff --git a/resource-manager/apimanagement/2021-08-01/gatewaygeneratetoken/method_gatewaygeneratetoken.go b/resource-manager/apimanagement/2021-08-01/gatewaygeneratetoken/method_gatewaygeneratetoken.go new file mode 100644 index 00000000000..3c75500bfd1 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/gatewaygeneratetoken/method_gatewaygeneratetoken.go @@ -0,0 +1,56 @@ +package gatewaygeneratetoken + +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 GatewayGenerateTokenOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *GatewayTokenContract +} + +// GatewayGenerateToken ... +func (c GatewayGenerateTokenClient) GatewayGenerateToken(ctx context.Context, id GatewayId, input GatewayTokenRequestContract) (result GatewayGenerateTokenOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/generateToken", 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/apimanagement/2021-08-01/gatewaygeneratetoken/method_gatewaygeneratetoken_autorest.go b/resource-manager/apimanagement/2021-08-01/gatewaygeneratetoken/method_gatewaygeneratetoken_autorest.go deleted file mode 100644 index cec0cc96400..00000000000 --- a/resource-manager/apimanagement/2021-08-01/gatewaygeneratetoken/method_gatewaygeneratetoken_autorest.go +++ /dev/null @@ -1,70 +0,0 @@ -package gatewaygeneratetoken - -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 GatewayGenerateTokenOperationResponse struct { - HttpResponse *http.Response - Model *GatewayTokenContract -} - -// GatewayGenerateToken ... -func (c GatewayGenerateTokenClient) GatewayGenerateToken(ctx context.Context, id GatewayId, input GatewayTokenRequestContract) (result GatewayGenerateTokenOperationResponse, err error) { - req, err := c.preparerForGatewayGenerateToken(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "gatewaygeneratetoken.GatewayGenerateTokenClient", "GatewayGenerateToken", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "gatewaygeneratetoken.GatewayGenerateTokenClient", "GatewayGenerateToken", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGatewayGenerateToken(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "gatewaygeneratetoken.GatewayGenerateTokenClient", "GatewayGenerateToken", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGatewayGenerateToken prepares the GatewayGenerateToken request. -func (c GatewayGenerateTokenClient) preparerForGatewayGenerateToken(ctx context.Context, id GatewayId, input GatewayTokenRequestContract) (*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/generateToken", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGatewayGenerateToken handles the response to the GatewayGenerateToken request. The method always -// closes the http.Response Body. -func (c GatewayGenerateTokenClient) responderForGatewayGenerateToken(resp *http.Response) (result GatewayGenerateTokenOperationResponse, 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/apimanagement/2021-08-01/gatewayhostnameconfiguration/client.go b/resource-manager/apimanagement/2021-08-01/gatewayhostnameconfiguration/client.go index d6e83f1d02e..652c5e5e27d 100644 --- a/resource-manager/apimanagement/2021-08-01/gatewayhostnameconfiguration/client.go +++ b/resource-manager/apimanagement/2021-08-01/gatewayhostnameconfiguration/client.go @@ -1,18 +1,26 @@ package gatewayhostnameconfiguration -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 GatewayHostnameConfigurationClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewGatewayHostnameConfigurationClientWithBaseURI(endpoint string) GatewayHostnameConfigurationClient { - return GatewayHostnameConfigurationClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewGatewayHostnameConfigurationClientWithBaseURI(api environments.Api) (*GatewayHostnameConfigurationClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "gatewayhostnameconfiguration", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating GatewayHostnameConfigurationClient: %+v", err) } + + return &GatewayHostnameConfigurationClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2021-08-01/gatewayhostnameconfiguration/method_createorupdate.go b/resource-manager/apimanagement/2021-08-01/gatewayhostnameconfiguration/method_createorupdate.go new file mode 100644 index 00000000000..1a362be1c96 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/gatewayhostnameconfiguration/method_createorupdate.go @@ -0,0 +1,85 @@ +package gatewayhostnameconfiguration + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *GatewayHostnameConfigurationContract +} + +type CreateOrUpdateOperationOptions struct { + IfMatch *string +} + +func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { + return CreateOrUpdateOperationOptions{} +} + +func (o CreateOrUpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o CreateOrUpdateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o CreateOrUpdateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// CreateOrUpdate ... +func (c GatewayHostnameConfigurationClient) CreateOrUpdate(ctx context.Context, id HostnameConfigurationId, input GatewayHostnameConfigurationContract, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + OptionsObject: options, + } + + 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/apimanagement/2021-08-01/gatewayhostnameconfiguration/method_createorupdate_autorest.go b/resource-manager/apimanagement/2021-08-01/gatewayhostnameconfiguration/method_createorupdate_autorest.go deleted file mode 100644 index 1636e17ebb1..00000000000 --- a/resource-manager/apimanagement/2021-08-01/gatewayhostnameconfiguration/method_createorupdate_autorest.go +++ /dev/null @@ -1,98 +0,0 @@ -package gatewayhostnameconfiguration - -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 *GatewayHostnameConfigurationContract -} - -type CreateOrUpdateOperationOptions struct { - IfMatch *string -} - -func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { - return CreateOrUpdateOperationOptions{} -} - -func (o CreateOrUpdateOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o CreateOrUpdateOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// CreateOrUpdate ... -func (c GatewayHostnameConfigurationClient) CreateOrUpdate(ctx context.Context, id HostnameConfigurationId, input GatewayHostnameConfigurationContract, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdate(ctx, id, input, options) - if err != nil { - err = autorest.NewErrorWithError(err, "gatewayhostnameconfiguration.GatewayHostnameConfigurationClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "gatewayhostnameconfiguration.GatewayHostnameConfigurationClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCreateOrUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "gatewayhostnameconfiguration.GatewayHostnameConfigurationClient", "CreateOrUpdate", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCreateOrUpdate prepares the CreateOrUpdate request. -func (c GatewayHostnameConfigurationClient) preparerForCreateOrUpdate(ctx context.Context, id HostnameConfigurationId, input GatewayHostnameConfigurationContract, options CreateOrUpdateOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - 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 GatewayHostnameConfigurationClient) responderForCreateOrUpdate(resp *http.Response) (result CreateOrUpdateOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2021-08-01/gatewayhostnameconfiguration/method_delete.go b/resource-manager/apimanagement/2021-08-01/gatewayhostnameconfiguration/method_delete.go new file mode 100644 index 00000000000..d36e0d55e20 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/gatewayhostnameconfiguration/method_delete.go @@ -0,0 +1,76 @@ +package gatewayhostnameconfiguration + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +type DeleteOperationOptions struct { + IfMatch *string +} + +func DefaultDeleteOperationOptions() DeleteOperationOptions { + return DeleteOperationOptions{} +} + +func (o DeleteOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o DeleteOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o DeleteOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// Delete ... +func (c GatewayHostnameConfigurationClient) Delete(ctx context.Context, id HostnameConfigurationId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2021-08-01/gatewayhostnameconfiguration/method_delete_autorest.go b/resource-manager/apimanagement/2021-08-01/gatewayhostnameconfiguration/method_delete_autorest.go deleted file mode 100644 index 64f4fa809d7..00000000000 --- a/resource-manager/apimanagement/2021-08-01/gatewayhostnameconfiguration/method_delete_autorest.go +++ /dev/null @@ -1,95 +0,0 @@ -package gatewayhostnameconfiguration - -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 DeleteOperationResponse struct { - HttpResponse *http.Response -} - -type DeleteOperationOptions struct { - IfMatch *string -} - -func DefaultDeleteOperationOptions() DeleteOperationOptions { - return DeleteOperationOptions{} -} - -func (o DeleteOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o DeleteOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// Delete ... -func (c GatewayHostnameConfigurationClient) Delete(ctx context.Context, id HostnameConfigurationId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { - req, err := c.preparerForDelete(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "gatewayhostnameconfiguration.GatewayHostnameConfigurationClient", "Delete", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "gatewayhostnameconfiguration.GatewayHostnameConfigurationClient", "Delete", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForDelete(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "gatewayhostnameconfiguration.GatewayHostnameConfigurationClient", "Delete", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForDelete prepares the Delete request. -func (c GatewayHostnameConfigurationClient) preparerForDelete(ctx context.Context, id HostnameConfigurationId, options DeleteOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForDelete handles the response to the Delete request. The method always -// closes the http.Response Body. -func (c GatewayHostnameConfigurationClient) responderForDelete(resp *http.Response) (result DeleteOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2021-08-01/gatewayhostnameconfiguration/method_get.go b/resource-manager/apimanagement/2021-08-01/gatewayhostnameconfiguration/method_get.go new file mode 100644 index 00000000000..f1f5ec6b270 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/gatewayhostnameconfiguration/method_get.go @@ -0,0 +1,51 @@ +package gatewayhostnameconfiguration + +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 *GatewayHostnameConfigurationContract +} + +// Get ... +func (c GatewayHostnameConfigurationClient) Get(ctx context.Context, id HostnameConfigurationId) (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/apimanagement/2021-08-01/gatewayhostnameconfiguration/method_get_autorest.go b/resource-manager/apimanagement/2021-08-01/gatewayhostnameconfiguration/method_get_autorest.go deleted file mode 100644 index be5cbec23ca..00000000000 --- a/resource-manager/apimanagement/2021-08-01/gatewayhostnameconfiguration/method_get_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package gatewayhostnameconfiguration - -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 *GatewayHostnameConfigurationContract -} - -// Get ... -func (c GatewayHostnameConfigurationClient) Get(ctx context.Context, id HostnameConfigurationId) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "gatewayhostnameconfiguration.GatewayHostnameConfigurationClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "gatewayhostnameconfiguration.GatewayHostnameConfigurationClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "gatewayhostnameconfiguration.GatewayHostnameConfigurationClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c GatewayHostnameConfigurationClient) preparerForGet(ctx context.Context, id HostnameConfigurationId) (*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 GatewayHostnameConfigurationClient) 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/apimanagement/2021-08-01/gatewayhostnameconfiguration/method_getentitytag.go b/resource-manager/apimanagement/2021-08-01/gatewayhostnameconfiguration/method_getentitytag.go new file mode 100644 index 00000000000..76b08b4e076 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/gatewayhostnameconfiguration/method_getentitytag.go @@ -0,0 +1,46 @@ +package gatewayhostnameconfiguration + +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 GetEntityTagOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// GetEntityTag ... +func (c GatewayHostnameConfigurationClient) GetEntityTag(ctx context.Context, id HostnameConfigurationId) (result GetEntityTagOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodHead, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2021-08-01/gatewayhostnameconfiguration/method_getentitytag_autorest.go b/resource-manager/apimanagement/2021-08-01/gatewayhostnameconfiguration/method_getentitytag_autorest.go deleted file mode 100644 index 424ecbb64c0..00000000000 --- a/resource-manager/apimanagement/2021-08-01/gatewayhostnameconfiguration/method_getentitytag_autorest.go +++ /dev/null @@ -1,66 +0,0 @@ -package gatewayhostnameconfiguration - -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 GetEntityTagOperationResponse struct { - HttpResponse *http.Response -} - -// GetEntityTag ... -func (c GatewayHostnameConfigurationClient) GetEntityTag(ctx context.Context, id HostnameConfigurationId) (result GetEntityTagOperationResponse, err error) { - req, err := c.preparerForGetEntityTag(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "gatewayhostnameconfiguration.GatewayHostnameConfigurationClient", "GetEntityTag", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "gatewayhostnameconfiguration.GatewayHostnameConfigurationClient", "GetEntityTag", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetEntityTag(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "gatewayhostnameconfiguration.GatewayHostnameConfigurationClient", "GetEntityTag", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetEntityTag prepares the GetEntityTag request. -func (c GatewayHostnameConfigurationClient) preparerForGetEntityTag(ctx context.Context, id HostnameConfigurationId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsHead(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetEntityTag handles the response to the GetEntityTag request. The method always -// closes the http.Response Body. -func (c GatewayHostnameConfigurationClient) responderForGetEntityTag(resp *http.Response) (result GetEntityTagOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2021-08-01/gatewayhostnameconfiguration/method_listbyservice.go b/resource-manager/apimanagement/2021-08-01/gatewayhostnameconfiguration/method_listbyservice.go new file mode 100644 index 00000000000..6842b2c14d3 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/gatewayhostnameconfiguration/method_listbyservice.go @@ -0,0 +1,125 @@ +package gatewayhostnameconfiguration + +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 ListByServiceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]GatewayHostnameConfigurationContract +} + +type ListByServiceCompleteResult struct { + Items []GatewayHostnameConfigurationContract +} + +type ListByServiceOperationOptions struct { + Filter *string + Skip *int64 + Top *int64 +} + +func DefaultListByServiceOperationOptions() ListByServiceOperationOptions { + return ListByServiceOperationOptions{} +} + +func (o ListByServiceOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListByServiceOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListByServiceOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.Skip != nil { + out.Append("$skip", fmt.Sprintf("%v", *o.Skip)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +// ListByService ... +func (c GatewayHostnameConfigurationClient) ListByService(ctx context.Context, id GatewayId, options ListByServiceOperationOptions) (result ListByServiceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/hostnameConfigurations", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]GatewayHostnameConfigurationContract `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByServiceComplete retrieves all the results into a single object +func (c GatewayHostnameConfigurationClient) ListByServiceComplete(ctx context.Context, id GatewayId, options ListByServiceOperationOptions) (ListByServiceCompleteResult, error) { + return c.ListByServiceCompleteMatchingPredicate(ctx, id, options, GatewayHostnameConfigurationContractOperationPredicate{}) +} + +// ListByServiceCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c GatewayHostnameConfigurationClient) ListByServiceCompleteMatchingPredicate(ctx context.Context, id GatewayId, options ListByServiceOperationOptions, predicate GatewayHostnameConfigurationContractOperationPredicate) (result ListByServiceCompleteResult, err error) { + items := make([]GatewayHostnameConfigurationContract, 0) + + resp, err := c.ListByService(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByServiceCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/apimanagement/2021-08-01/gatewayhostnameconfiguration/method_listbyservice_autorest.go b/resource-manager/apimanagement/2021-08-01/gatewayhostnameconfiguration/method_listbyservice_autorest.go deleted file mode 100644 index ce7ed9c80f0..00000000000 --- a/resource-manager/apimanagement/2021-08-01/gatewayhostnameconfiguration/method_listbyservice_autorest.go +++ /dev/null @@ -1,225 +0,0 @@ -package gatewayhostnameconfiguration - -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 ListByServiceOperationResponse struct { - HttpResponse *http.Response - Model *[]GatewayHostnameConfigurationContract - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListByServiceOperationResponse, error) -} - -type ListByServiceCompleteResult struct { - Items []GatewayHostnameConfigurationContract -} - -func (r ListByServiceOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListByServiceOperationResponse) LoadMore(ctx context.Context) (resp ListByServiceOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -type ListByServiceOperationOptions struct { - Filter *string - Skip *int64 - Top *int64 -} - -func DefaultListByServiceOperationOptions() ListByServiceOperationOptions { - return ListByServiceOperationOptions{} -} - -func (o ListByServiceOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o ListByServiceOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Filter != nil { - out["$filter"] = *o.Filter - } - - if o.Skip != nil { - out["$skip"] = *o.Skip - } - - if o.Top != nil { - out["$top"] = *o.Top - } - - return out -} - -// ListByService ... -func (c GatewayHostnameConfigurationClient) ListByService(ctx context.Context, id GatewayId, options ListByServiceOperationOptions) (resp ListByServiceOperationResponse, err error) { - req, err := c.preparerForListByService(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "gatewayhostnameconfiguration.GatewayHostnameConfigurationClient", "ListByService", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "gatewayhostnameconfiguration.GatewayHostnameConfigurationClient", "ListByService", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListByService(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "gatewayhostnameconfiguration.GatewayHostnameConfigurationClient", "ListByService", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListByService prepares the ListByService request. -func (c GatewayHostnameConfigurationClient) preparerForListByService(ctx context.Context, id GatewayId, options ListByServiceOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/hostnameConfigurations", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListByServiceWithNextLink prepares the ListByService request with the given nextLink token. -func (c GatewayHostnameConfigurationClient) preparerForListByServiceWithNextLink(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)) -} - -// responderForListByService handles the response to the ListByService request. The method always -// closes the http.Response Body. -func (c GatewayHostnameConfigurationClient) responderForListByService(resp *http.Response) (result ListByServiceOperationResponse, err error) { - type page struct { - Values []GatewayHostnameConfigurationContract `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 ListByServiceOperationResponse, err error) { - req, err := c.preparerForListByServiceWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "gatewayhostnameconfiguration.GatewayHostnameConfigurationClient", "ListByService", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "gatewayhostnameconfiguration.GatewayHostnameConfigurationClient", "ListByService", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByService(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "gatewayhostnameconfiguration.GatewayHostnameConfigurationClient", "ListByService", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListByServiceComplete retrieves all of the results into a single object -func (c GatewayHostnameConfigurationClient) ListByServiceComplete(ctx context.Context, id GatewayId, options ListByServiceOperationOptions) (ListByServiceCompleteResult, error) { - return c.ListByServiceCompleteMatchingPredicate(ctx, id, options, GatewayHostnameConfigurationContractOperationPredicate{}) -} - -// ListByServiceCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c GatewayHostnameConfigurationClient) ListByServiceCompleteMatchingPredicate(ctx context.Context, id GatewayId, options ListByServiceOperationOptions, predicate GatewayHostnameConfigurationContractOperationPredicate) (resp ListByServiceCompleteResult, err error) { - items := make([]GatewayHostnameConfigurationContract, 0) - - page, err := c.ListByService(ctx, id, options) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListByServiceCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/apimanagement/2021-08-01/gatewaylistkeys/client.go b/resource-manager/apimanagement/2021-08-01/gatewaylistkeys/client.go index 01978a51eaa..fb1f3f83c7a 100644 --- a/resource-manager/apimanagement/2021-08-01/gatewaylistkeys/client.go +++ b/resource-manager/apimanagement/2021-08-01/gatewaylistkeys/client.go @@ -1,18 +1,26 @@ package gatewaylistkeys -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 GatewayListKeysClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewGatewayListKeysClientWithBaseURI(endpoint string) GatewayListKeysClient { - return GatewayListKeysClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewGatewayListKeysClientWithBaseURI(api environments.Api) (*GatewayListKeysClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "gatewaylistkeys", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating GatewayListKeysClient: %+v", err) } + + return &GatewayListKeysClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2021-08-01/gatewaylistkeys/method_gatewaylistkeys.go b/resource-manager/apimanagement/2021-08-01/gatewaylistkeys/method_gatewaylistkeys.go new file mode 100644 index 00000000000..8fc1104a3b3 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/gatewaylistkeys/method_gatewaylistkeys.go @@ -0,0 +1,52 @@ +package gatewaylistkeys + +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 GatewayListKeysOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *GatewayKeysContract +} + +// GatewayListKeys ... +func (c GatewayListKeysClient) GatewayListKeys(ctx context.Context, id GatewayId) (result GatewayListKeysOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/listKeys", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + if err = resp.Unmarshal(&result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2021-08-01/gatewaylistkeys/method_gatewaylistkeys_autorest.go b/resource-manager/apimanagement/2021-08-01/gatewaylistkeys/method_gatewaylistkeys_autorest.go deleted file mode 100644 index 3ad468fa9f9..00000000000 --- a/resource-manager/apimanagement/2021-08-01/gatewaylistkeys/method_gatewaylistkeys_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package gatewaylistkeys - -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 GatewayListKeysOperationResponse struct { - HttpResponse *http.Response - Model *GatewayKeysContract -} - -// GatewayListKeys ... -func (c GatewayListKeysClient) GatewayListKeys(ctx context.Context, id GatewayId) (result GatewayListKeysOperationResponse, err error) { - req, err := c.preparerForGatewayListKeys(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "gatewaylistkeys.GatewayListKeysClient", "GatewayListKeys", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "gatewaylistkeys.GatewayListKeysClient", "GatewayListKeys", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGatewayListKeys(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "gatewaylistkeys.GatewayListKeysClient", "GatewayListKeys", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGatewayListKeys prepares the GatewayListKeys request. -func (c GatewayListKeysClient) preparerForGatewayListKeys(ctx context.Context, id GatewayId) (*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/listKeys", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGatewayListKeys handles the response to the GatewayListKeys request. The method always -// closes the http.Response Body. -func (c GatewayListKeysClient) responderForGatewayListKeys(resp *http.Response) (result GatewayListKeysOperationResponse, 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/apimanagement/2021-08-01/gatewayregeneratekey/client.go b/resource-manager/apimanagement/2021-08-01/gatewayregeneratekey/client.go index 68eee704676..53b506f50c1 100644 --- a/resource-manager/apimanagement/2021-08-01/gatewayregeneratekey/client.go +++ b/resource-manager/apimanagement/2021-08-01/gatewayregeneratekey/client.go @@ -1,18 +1,26 @@ package gatewayregeneratekey -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 GatewayRegenerateKeyClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewGatewayRegenerateKeyClientWithBaseURI(endpoint string) GatewayRegenerateKeyClient { - return GatewayRegenerateKeyClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewGatewayRegenerateKeyClientWithBaseURI(api environments.Api) (*GatewayRegenerateKeyClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "gatewayregeneratekey", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating GatewayRegenerateKeyClient: %+v", err) } + + return &GatewayRegenerateKeyClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2021-08-01/gatewayregeneratekey/constants.go b/resource-manager/apimanagement/2021-08-01/gatewayregeneratekey/constants.go index e69fb786bb4..f8762636760 100644 --- a/resource-manager/apimanagement/2021-08-01/gatewayregeneratekey/constants.go +++ b/resource-manager/apimanagement/2021-08-01/gatewayregeneratekey/constants.go @@ -1,6 +1,10 @@ package gatewayregeneratekey -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 PossibleValuesForKeyType() []string { } } +func (s *KeyType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseKeyType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseKeyType(input string) (*KeyType, error) { vals := map[string]KeyType{ "primary": KeyTypePrimary, diff --git a/resource-manager/apimanagement/2021-08-01/gatewayregeneratekey/method_gatewayregeneratekey.go b/resource-manager/apimanagement/2021-08-01/gatewayregeneratekey/method_gatewayregeneratekey.go new file mode 100644 index 00000000000..8783e036af9 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/gatewayregeneratekey/method_gatewayregeneratekey.go @@ -0,0 +1,51 @@ +package gatewayregeneratekey + +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 GatewayRegenerateKeyOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// GatewayRegenerateKey ... +func (c GatewayRegenerateKeyClient) GatewayRegenerateKey(ctx context.Context, id GatewayId, input GatewayKeyRegenerationRequestContract) (result GatewayRegenerateKeyOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/regenerateKey", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2021-08-01/gatewayregeneratekey/method_gatewayregeneratekey_autorest.go b/resource-manager/apimanagement/2021-08-01/gatewayregeneratekey/method_gatewayregeneratekey_autorest.go deleted file mode 100644 index 944a561ab8b..00000000000 --- a/resource-manager/apimanagement/2021-08-01/gatewayregeneratekey/method_gatewayregeneratekey_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package gatewayregeneratekey - -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 GatewayRegenerateKeyOperationResponse struct { - HttpResponse *http.Response -} - -// GatewayRegenerateKey ... -func (c GatewayRegenerateKeyClient) GatewayRegenerateKey(ctx context.Context, id GatewayId, input GatewayKeyRegenerationRequestContract) (result GatewayRegenerateKeyOperationResponse, err error) { - req, err := c.preparerForGatewayRegenerateKey(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "gatewayregeneratekey.GatewayRegenerateKeyClient", "GatewayRegenerateKey", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "gatewayregeneratekey.GatewayRegenerateKeyClient", "GatewayRegenerateKey", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGatewayRegenerateKey(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "gatewayregeneratekey.GatewayRegenerateKeyClient", "GatewayRegenerateKey", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGatewayRegenerateKey prepares the GatewayRegenerateKey request. -func (c GatewayRegenerateKeyClient) preparerForGatewayRegenerateKey(ctx context.Context, id GatewayId, input GatewayKeyRegenerationRequestContract) (*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/regenerateKey", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGatewayRegenerateKey handles the response to the GatewayRegenerateKey request. The method always -// closes the http.Response Body. -func (c GatewayRegenerateKeyClient) responderForGatewayRegenerateKey(resp *http.Response) (result GatewayRegenerateKeyOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2021-08-01/group/client.go b/resource-manager/apimanagement/2021-08-01/group/client.go index 78b8515c749..8103ac936d5 100644 --- a/resource-manager/apimanagement/2021-08-01/group/client.go +++ b/resource-manager/apimanagement/2021-08-01/group/client.go @@ -1,18 +1,26 @@ package group -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 GroupClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewGroupClientWithBaseURI(endpoint string) GroupClient { - return GroupClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewGroupClientWithBaseURI(api environments.Api) (*GroupClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "group", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating GroupClient: %+v", err) } + + return &GroupClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2021-08-01/group/constants.go b/resource-manager/apimanagement/2021-08-01/group/constants.go index a4fc43f47e7..1cda5dadcaf 100644 --- a/resource-manager/apimanagement/2021-08-01/group/constants.go +++ b/resource-manager/apimanagement/2021-08-01/group/constants.go @@ -1,6 +1,10 @@ package group -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 PossibleValuesForGroupType() []string { } } +func (s *GroupType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseGroupType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseGroupType(input string) (*GroupType, error) { vals := map[string]GroupType{ "custom": GroupTypeCustom, diff --git a/resource-manager/apimanagement/2021-08-01/group/method_createorupdate.go b/resource-manager/apimanagement/2021-08-01/group/method_createorupdate.go new file mode 100644 index 00000000000..c7c3873d667 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/group/method_createorupdate.go @@ -0,0 +1,85 @@ +package group + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *GroupContract +} + +type CreateOrUpdateOperationOptions struct { + IfMatch *string +} + +func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { + return CreateOrUpdateOperationOptions{} +} + +func (o CreateOrUpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o CreateOrUpdateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o CreateOrUpdateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// CreateOrUpdate ... +func (c GroupClient) CreateOrUpdate(ctx context.Context, id GroupId, input GroupCreateParameters, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + OptionsObject: options, + } + + 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/apimanagement/2021-08-01/group/method_createorupdate_autorest.go b/resource-manager/apimanagement/2021-08-01/group/method_createorupdate_autorest.go deleted file mode 100644 index 17bbc0cae9b..00000000000 --- a/resource-manager/apimanagement/2021-08-01/group/method_createorupdate_autorest.go +++ /dev/null @@ -1,98 +0,0 @@ -package group - -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 *GroupContract -} - -type CreateOrUpdateOperationOptions struct { - IfMatch *string -} - -func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { - return CreateOrUpdateOperationOptions{} -} - -func (o CreateOrUpdateOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o CreateOrUpdateOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// CreateOrUpdate ... -func (c GroupClient) CreateOrUpdate(ctx context.Context, id GroupId, input GroupCreateParameters, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdate(ctx, id, input, options) - if err != nil { - err = autorest.NewErrorWithError(err, "group.GroupClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "group.GroupClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCreateOrUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "group.GroupClient", "CreateOrUpdate", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCreateOrUpdate prepares the CreateOrUpdate request. -func (c GroupClient) preparerForCreateOrUpdate(ctx context.Context, id GroupId, input GroupCreateParameters, options CreateOrUpdateOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - 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 GroupClient) responderForCreateOrUpdate(resp *http.Response) (result CreateOrUpdateOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2021-08-01/group/method_delete.go b/resource-manager/apimanagement/2021-08-01/group/method_delete.go new file mode 100644 index 00000000000..8bd332e45a2 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/group/method_delete.go @@ -0,0 +1,76 @@ +package group + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +type DeleteOperationOptions struct { + IfMatch *string +} + +func DefaultDeleteOperationOptions() DeleteOperationOptions { + return DeleteOperationOptions{} +} + +func (o DeleteOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o DeleteOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o DeleteOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// Delete ... +func (c GroupClient) Delete(ctx context.Context, id GroupId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2021-08-01/group/method_delete_autorest.go b/resource-manager/apimanagement/2021-08-01/group/method_delete_autorest.go deleted file mode 100644 index 9abfbd05611..00000000000 --- a/resource-manager/apimanagement/2021-08-01/group/method_delete_autorest.go +++ /dev/null @@ -1,95 +0,0 @@ -package group - -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 DeleteOperationResponse struct { - HttpResponse *http.Response -} - -type DeleteOperationOptions struct { - IfMatch *string -} - -func DefaultDeleteOperationOptions() DeleteOperationOptions { - return DeleteOperationOptions{} -} - -func (o DeleteOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o DeleteOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// Delete ... -func (c GroupClient) Delete(ctx context.Context, id GroupId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { - req, err := c.preparerForDelete(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "group.GroupClient", "Delete", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "group.GroupClient", "Delete", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForDelete(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "group.GroupClient", "Delete", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForDelete prepares the Delete request. -func (c GroupClient) preparerForDelete(ctx context.Context, id GroupId, options DeleteOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForDelete handles the response to the Delete request. The method always -// closes the http.Response Body. -func (c GroupClient) responderForDelete(resp *http.Response) (result DeleteOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2021-08-01/group/method_get.go b/resource-manager/apimanagement/2021-08-01/group/method_get.go new file mode 100644 index 00000000000..4dbbc0759e2 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/group/method_get.go @@ -0,0 +1,51 @@ +package group + +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 *GroupContract +} + +// Get ... +func (c GroupClient) Get(ctx context.Context, id GroupId) (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/apimanagement/2021-08-01/group/method_get_autorest.go b/resource-manager/apimanagement/2021-08-01/group/method_get_autorest.go deleted file mode 100644 index bb3e3b2d619..00000000000 --- a/resource-manager/apimanagement/2021-08-01/group/method_get_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package group - -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 *GroupContract -} - -// Get ... -func (c GroupClient) Get(ctx context.Context, id GroupId) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "group.GroupClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "group.GroupClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "group.GroupClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c GroupClient) preparerForGet(ctx context.Context, id GroupId) (*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 GroupClient) 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/apimanagement/2021-08-01/group/method_getentitytag.go b/resource-manager/apimanagement/2021-08-01/group/method_getentitytag.go new file mode 100644 index 00000000000..e6ee5a9ba2d --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/group/method_getentitytag.go @@ -0,0 +1,46 @@ +package group + +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 GetEntityTagOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// GetEntityTag ... +func (c GroupClient) GetEntityTag(ctx context.Context, id GroupId) (result GetEntityTagOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodHead, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2021-08-01/group/method_getentitytag_autorest.go b/resource-manager/apimanagement/2021-08-01/group/method_getentitytag_autorest.go deleted file mode 100644 index 3dca8de39a0..00000000000 --- a/resource-manager/apimanagement/2021-08-01/group/method_getentitytag_autorest.go +++ /dev/null @@ -1,66 +0,0 @@ -package group - -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 GetEntityTagOperationResponse struct { - HttpResponse *http.Response -} - -// GetEntityTag ... -func (c GroupClient) GetEntityTag(ctx context.Context, id GroupId) (result GetEntityTagOperationResponse, err error) { - req, err := c.preparerForGetEntityTag(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "group.GroupClient", "GetEntityTag", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "group.GroupClient", "GetEntityTag", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetEntityTag(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "group.GroupClient", "GetEntityTag", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetEntityTag prepares the GetEntityTag request. -func (c GroupClient) preparerForGetEntityTag(ctx context.Context, id GroupId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsHead(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetEntityTag handles the response to the GetEntityTag request. The method always -// closes the http.Response Body. -func (c GroupClient) responderForGetEntityTag(resp *http.Response) (result GetEntityTagOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2021-08-01/group/method_listbyservice.go b/resource-manager/apimanagement/2021-08-01/group/method_listbyservice.go new file mode 100644 index 00000000000..080778877db --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/group/method_listbyservice.go @@ -0,0 +1,125 @@ +package group + +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 ListByServiceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]GroupContract +} + +type ListByServiceCompleteResult struct { + Items []GroupContract +} + +type ListByServiceOperationOptions struct { + Filter *string + Skip *int64 + Top *int64 +} + +func DefaultListByServiceOperationOptions() ListByServiceOperationOptions { + return ListByServiceOperationOptions{} +} + +func (o ListByServiceOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListByServiceOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListByServiceOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.Skip != nil { + out.Append("$skip", fmt.Sprintf("%v", *o.Skip)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +// ListByService ... +func (c GroupClient) ListByService(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (result ListByServiceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/groups", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]GroupContract `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByServiceComplete retrieves all the results into a single object +func (c GroupClient) ListByServiceComplete(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (ListByServiceCompleteResult, error) { + return c.ListByServiceCompleteMatchingPredicate(ctx, id, options, GroupContractOperationPredicate{}) +} + +// ListByServiceCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c GroupClient) ListByServiceCompleteMatchingPredicate(ctx context.Context, id ServiceId, options ListByServiceOperationOptions, predicate GroupContractOperationPredicate) (result ListByServiceCompleteResult, err error) { + items := make([]GroupContract, 0) + + resp, err := c.ListByService(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByServiceCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/apimanagement/2021-08-01/group/method_listbyservice_autorest.go b/resource-manager/apimanagement/2021-08-01/group/method_listbyservice_autorest.go deleted file mode 100644 index f2981bb97a5..00000000000 --- a/resource-manager/apimanagement/2021-08-01/group/method_listbyservice_autorest.go +++ /dev/null @@ -1,225 +0,0 @@ -package group - -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 ListByServiceOperationResponse struct { - HttpResponse *http.Response - Model *[]GroupContract - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListByServiceOperationResponse, error) -} - -type ListByServiceCompleteResult struct { - Items []GroupContract -} - -func (r ListByServiceOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListByServiceOperationResponse) LoadMore(ctx context.Context) (resp ListByServiceOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -type ListByServiceOperationOptions struct { - Filter *string - Skip *int64 - Top *int64 -} - -func DefaultListByServiceOperationOptions() ListByServiceOperationOptions { - return ListByServiceOperationOptions{} -} - -func (o ListByServiceOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o ListByServiceOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Filter != nil { - out["$filter"] = *o.Filter - } - - if o.Skip != nil { - out["$skip"] = *o.Skip - } - - if o.Top != nil { - out["$top"] = *o.Top - } - - return out -} - -// ListByService ... -func (c GroupClient) ListByService(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (resp ListByServiceOperationResponse, err error) { - req, err := c.preparerForListByService(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "group.GroupClient", "ListByService", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "group.GroupClient", "ListByService", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListByService(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "group.GroupClient", "ListByService", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListByService prepares the ListByService request. -func (c GroupClient) preparerForListByService(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/groups", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListByServiceWithNextLink prepares the ListByService request with the given nextLink token. -func (c GroupClient) preparerForListByServiceWithNextLink(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)) -} - -// responderForListByService handles the response to the ListByService request. The method always -// closes the http.Response Body. -func (c GroupClient) responderForListByService(resp *http.Response) (result ListByServiceOperationResponse, err error) { - type page struct { - Values []GroupContract `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 ListByServiceOperationResponse, err error) { - req, err := c.preparerForListByServiceWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "group.GroupClient", "ListByService", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "group.GroupClient", "ListByService", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByService(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "group.GroupClient", "ListByService", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListByServiceComplete retrieves all of the results into a single object -func (c GroupClient) ListByServiceComplete(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (ListByServiceCompleteResult, error) { - return c.ListByServiceCompleteMatchingPredicate(ctx, id, options, GroupContractOperationPredicate{}) -} - -// ListByServiceCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c GroupClient) ListByServiceCompleteMatchingPredicate(ctx context.Context, id ServiceId, options ListByServiceOperationOptions, predicate GroupContractOperationPredicate) (resp ListByServiceCompleteResult, err error) { - items := make([]GroupContract, 0) - - page, err := c.ListByService(ctx, id, options) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListByServiceCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/apimanagement/2021-08-01/group/method_update.go b/resource-manager/apimanagement/2021-08-01/group/method_update.go new file mode 100644 index 00000000000..8ef4191a0f2 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/group/method_update.go @@ -0,0 +1,84 @@ +package group + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *GroupContract +} + +type UpdateOperationOptions struct { + IfMatch *string +} + +func DefaultUpdateOperationOptions() UpdateOperationOptions { + return UpdateOperationOptions{} +} + +func (o UpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o UpdateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o UpdateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// Update ... +func (c GroupClient) Update(ctx context.Context, id GroupId, input GroupUpdateParameters, options UpdateOperationOptions) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + OptionsObject: options, + } + + 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/apimanagement/2021-08-01/group/method_update_autorest.go b/resource-manager/apimanagement/2021-08-01/group/method_update_autorest.go deleted file mode 100644 index 09760546a0e..00000000000 --- a/resource-manager/apimanagement/2021-08-01/group/method_update_autorest.go +++ /dev/null @@ -1,98 +0,0 @@ -package group - -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 *GroupContract -} - -type UpdateOperationOptions struct { - IfMatch *string -} - -func DefaultUpdateOperationOptions() UpdateOperationOptions { - return UpdateOperationOptions{} -} - -func (o UpdateOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o UpdateOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// Update ... -func (c GroupClient) Update(ctx context.Context, id GroupId, input GroupUpdateParameters, options UpdateOperationOptions) (result UpdateOperationResponse, err error) { - req, err := c.preparerForUpdate(ctx, id, input, options) - if err != nil { - err = autorest.NewErrorWithError(err, "group.GroupClient", "Update", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "group.GroupClient", "Update", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "group.GroupClient", "Update", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForUpdate prepares the Update request. -func (c GroupClient) preparerForUpdate(ctx context.Context, id GroupId, input GroupUpdateParameters, options UpdateOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPatch(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - 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 GroupClient) 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/apimanagement/2021-08-01/groupuser/client.go b/resource-manager/apimanagement/2021-08-01/groupuser/client.go index ab4bea57574..83797d917e2 100644 --- a/resource-manager/apimanagement/2021-08-01/groupuser/client.go +++ b/resource-manager/apimanagement/2021-08-01/groupuser/client.go @@ -1,18 +1,26 @@ package groupuser -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 GroupUserClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewGroupUserClientWithBaseURI(endpoint string) GroupUserClient { - return GroupUserClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewGroupUserClientWithBaseURI(api environments.Api) (*GroupUserClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "groupuser", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating GroupUserClient: %+v", err) } + + return &GroupUserClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2021-08-01/groupuser/constants.go b/resource-manager/apimanagement/2021-08-01/groupuser/constants.go index 4023a21458d..520579fefd7 100644 --- a/resource-manager/apimanagement/2021-08-01/groupuser/constants.go +++ b/resource-manager/apimanagement/2021-08-01/groupuser/constants.go @@ -1,6 +1,10 @@ package groupuser -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 PossibleValuesForGroupType() []string { } } +func (s *GroupType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseGroupType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseGroupType(input string) (*GroupType, error) { vals := map[string]GroupType{ "custom": GroupTypeCustom, @@ -54,6 +71,19 @@ func PossibleValuesForUserState() []string { } } +func (s *UserState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseUserState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseUserState(input string) (*UserState, error) { vals := map[string]UserState{ "active": UserStateActive, diff --git a/resource-manager/apimanagement/2021-08-01/groupuser/method_checkentityexists.go b/resource-manager/apimanagement/2021-08-01/groupuser/method_checkentityexists.go new file mode 100644 index 00000000000..ecf5ac1f37b --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/groupuser/method_checkentityexists.go @@ -0,0 +1,46 @@ +package groupuser + +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 CheckEntityExistsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// CheckEntityExists ... +func (c GroupUserClient) CheckEntityExists(ctx context.Context, id GroupUserId) (result CheckEntityExistsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: http.MethodHead, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2021-08-01/groupuser/method_checkentityexists_autorest.go b/resource-manager/apimanagement/2021-08-01/groupuser/method_checkentityexists_autorest.go deleted file mode 100644 index 6c318ef5a01..00000000000 --- a/resource-manager/apimanagement/2021-08-01/groupuser/method_checkentityexists_autorest.go +++ /dev/null @@ -1,66 +0,0 @@ -package groupuser - -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 CheckEntityExistsOperationResponse struct { - HttpResponse *http.Response -} - -// CheckEntityExists ... -func (c GroupUserClient) CheckEntityExists(ctx context.Context, id GroupUserId) (result CheckEntityExistsOperationResponse, err error) { - req, err := c.preparerForCheckEntityExists(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "groupuser.GroupUserClient", "CheckEntityExists", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "groupuser.GroupUserClient", "CheckEntityExists", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCheckEntityExists(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "groupuser.GroupUserClient", "CheckEntityExists", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCheckEntityExists prepares the CheckEntityExists request. -func (c GroupUserClient) preparerForCheckEntityExists(ctx context.Context, id GroupUserId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsHead(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForCheckEntityExists handles the response to the CheckEntityExists request. The method always -// closes the http.Response Body. -func (c GroupUserClient) responderForCheckEntityExists(resp *http.Response) (result CheckEntityExistsOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2021-08-01/groupuser/method_create.go b/resource-manager/apimanagement/2021-08-01/groupuser/method_create.go new file mode 100644 index 00000000000..b13b301f403 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/groupuser/method_create.go @@ -0,0 +1,52 @@ +package groupuser + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *UserContract +} + +// Create ... +func (c GroupUserClient) Create(ctx context.Context, id GroupUserId) (result CreateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + 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/apimanagement/2021-08-01/groupuser/method_create_autorest.go b/resource-manager/apimanagement/2021-08-01/groupuser/method_create_autorest.go deleted file mode 100644 index bc34063331f..00000000000 --- a/resource-manager/apimanagement/2021-08-01/groupuser/method_create_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package groupuser - -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 CreateOperationResponse struct { - HttpResponse *http.Response - Model *UserContract -} - -// Create ... -func (c GroupUserClient) Create(ctx context.Context, id GroupUserId) (result CreateOperationResponse, err error) { - req, err := c.preparerForCreate(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "groupuser.GroupUserClient", "Create", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "groupuser.GroupUserClient", "Create", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCreate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "groupuser.GroupUserClient", "Create", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCreate prepares the Create request. -func (c GroupUserClient) preparerForCreate(ctx context.Context, id GroupUserId) (*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.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForCreate handles the response to the Create request. The method always -// closes the http.Response Body. -func (c GroupUserClient) responderForCreate(resp *http.Response) (result CreateOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2021-08-01/groupuser/method_delete.go b/resource-manager/apimanagement/2021-08-01/groupuser/method_delete.go new file mode 100644 index 00000000000..e8513f36120 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/groupuser/method_delete.go @@ -0,0 +1,47 @@ +package groupuser + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c GroupUserClient) Delete(ctx context.Context, id GroupUserId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2021-08-01/groupuser/method_delete_autorest.go b/resource-manager/apimanagement/2021-08-01/groupuser/method_delete_autorest.go deleted file mode 100644 index 26cb84da7d4..00000000000 --- a/resource-manager/apimanagement/2021-08-01/groupuser/method_delete_autorest.go +++ /dev/null @@ -1,66 +0,0 @@ -package groupuser - -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 DeleteOperationResponse struct { - HttpResponse *http.Response -} - -// Delete ... -func (c GroupUserClient) Delete(ctx context.Context, id GroupUserId) (result DeleteOperationResponse, err error) { - req, err := c.preparerForDelete(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "groupuser.GroupUserClient", "Delete", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "groupuser.GroupUserClient", "Delete", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForDelete(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "groupuser.GroupUserClient", "Delete", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForDelete prepares the Delete request. -func (c GroupUserClient) preparerForDelete(ctx context.Context, id GroupUserId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForDelete handles the response to the Delete request. The method always -// closes the http.Response Body. -func (c GroupUserClient) responderForDelete(resp *http.Response) (result DeleteOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2021-08-01/groupuser/method_list.go b/resource-manager/apimanagement/2021-08-01/groupuser/method_list.go new file mode 100644 index 00000000000..0f87bb365b1 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/groupuser/method_list.go @@ -0,0 +1,125 @@ +package groupuser + +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 *[]UserContract +} + +type ListCompleteResult struct { + Items []UserContract +} + +type ListOperationOptions struct { + Filter *string + Skip *int64 + Top *int64 +} + +func DefaultListOperationOptions() ListOperationOptions { + return ListOperationOptions{} +} + +func (o ListOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.Skip != nil { + out.Append("$skip", fmt.Sprintf("%v", *o.Skip)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +// List ... +func (c GroupUserClient) List(ctx context.Context, id GroupId, options ListOperationOptions) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/users", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]UserContract `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 GroupUserClient) ListComplete(ctx context.Context, id GroupId, options ListOperationOptions) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, options, UserContractOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c GroupUserClient) ListCompleteMatchingPredicate(ctx context.Context, id GroupId, options ListOperationOptions, predicate UserContractOperationPredicate) (result ListCompleteResult, err error) { + items := make([]UserContract, 0) + + resp, err := c.List(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/apimanagement/2021-08-01/groupuser/method_list_autorest.go b/resource-manager/apimanagement/2021-08-01/groupuser/method_list_autorest.go deleted file mode 100644 index 92652a7a09f..00000000000 --- a/resource-manager/apimanagement/2021-08-01/groupuser/method_list_autorest.go +++ /dev/null @@ -1,225 +0,0 @@ -package groupuser - -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 *[]UserContract - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListOperationResponse, error) -} - -type ListCompleteResult struct { - Items []UserContract -} - -func (r ListOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListOperationResponse) LoadMore(ctx context.Context) (resp ListOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -type ListOperationOptions struct { - Filter *string - Skip *int64 - Top *int64 -} - -func DefaultListOperationOptions() ListOperationOptions { - return ListOperationOptions{} -} - -func (o ListOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o ListOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Filter != nil { - out["$filter"] = *o.Filter - } - - if o.Skip != nil { - out["$skip"] = *o.Skip - } - - if o.Top != nil { - out["$top"] = *o.Top - } - - return out -} - -// List ... -func (c GroupUserClient) List(ctx context.Context, id GroupId, options ListOperationOptions) (resp ListOperationResponse, err error) { - req, err := c.preparerForList(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "groupuser.GroupUserClient", "List", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "groupuser.GroupUserClient", "List", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForList(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "groupuser.GroupUserClient", "List", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForList prepares the List request. -func (c GroupUserClient) preparerForList(ctx context.Context, id GroupId, options ListOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/users", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListWithNextLink prepares the List request with the given nextLink token. -func (c GroupUserClient) 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 GroupUserClient) responderForList(resp *http.Response) (result ListOperationResponse, err error) { - type page struct { - Values []UserContract `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, "groupuser.GroupUserClient", "List", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "groupuser.GroupUserClient", "List", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForList(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "groupuser.GroupUserClient", "List", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListComplete retrieves all of the results into a single object -func (c GroupUserClient) ListComplete(ctx context.Context, id GroupId, options ListOperationOptions) (ListCompleteResult, error) { - return c.ListCompleteMatchingPredicate(ctx, id, options, UserContractOperationPredicate{}) -} - -// ListCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c GroupUserClient) ListCompleteMatchingPredicate(ctx context.Context, id GroupId, options ListOperationOptions, predicate UserContractOperationPredicate) (resp ListCompleteResult, err error) { - items := make([]UserContract, 0) - - page, err := c.List(ctx, id, options) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/apimanagement/2021-08-01/identityprovider/client.go b/resource-manager/apimanagement/2021-08-01/identityprovider/client.go index 72328783c91..c29923f5737 100644 --- a/resource-manager/apimanagement/2021-08-01/identityprovider/client.go +++ b/resource-manager/apimanagement/2021-08-01/identityprovider/client.go @@ -1,18 +1,26 @@ package identityprovider -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 IdentityProviderClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewIdentityProviderClientWithBaseURI(endpoint string) IdentityProviderClient { - return IdentityProviderClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewIdentityProviderClientWithBaseURI(api environments.Api) (*IdentityProviderClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "identityprovider", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating IdentityProviderClient: %+v", err) } + + return &IdentityProviderClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2021-08-01/identityprovider/constants.go b/resource-manager/apimanagement/2021-08-01/identityprovider/constants.go index dbcc693e57a..d96fcd03253 100644 --- a/resource-manager/apimanagement/2021-08-01/identityprovider/constants.go +++ b/resource-manager/apimanagement/2021-08-01/identityprovider/constants.go @@ -1,6 +1,10 @@ package identityprovider -import "strings" +import ( + "encoding/json" + "fmt" + "strings" +) // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See NOTICE.txt in the project root for license information. @@ -27,6 +31,19 @@ func PossibleValuesForIdentityProviderType() []string { } } +func (s *IdentityProviderType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseIdentityProviderType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseIdentityProviderType(input string) (*IdentityProviderType, error) { vals := map[string]IdentityProviderType{ "aad": IdentityProviderTypeAad, diff --git a/resource-manager/apimanagement/2021-08-01/identityprovider/method_createorupdate.go b/resource-manager/apimanagement/2021-08-01/identityprovider/method_createorupdate.go new file mode 100644 index 00000000000..7e7257ff801 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/identityprovider/method_createorupdate.go @@ -0,0 +1,85 @@ +package identityprovider + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *IdentityProviderContract +} + +type CreateOrUpdateOperationOptions struct { + IfMatch *string +} + +func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { + return CreateOrUpdateOperationOptions{} +} + +func (o CreateOrUpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o CreateOrUpdateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o CreateOrUpdateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// CreateOrUpdate ... +func (c IdentityProviderClient) CreateOrUpdate(ctx context.Context, id IdentityProviderId, input IdentityProviderCreateContract, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + OptionsObject: options, + } + + 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/apimanagement/2021-08-01/identityprovider/method_createorupdate_autorest.go b/resource-manager/apimanagement/2021-08-01/identityprovider/method_createorupdate_autorest.go deleted file mode 100644 index 01365a7baa9..00000000000 --- a/resource-manager/apimanagement/2021-08-01/identityprovider/method_createorupdate_autorest.go +++ /dev/null @@ -1,98 +0,0 @@ -package identityprovider - -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 *IdentityProviderContract -} - -type CreateOrUpdateOperationOptions struct { - IfMatch *string -} - -func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { - return CreateOrUpdateOperationOptions{} -} - -func (o CreateOrUpdateOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o CreateOrUpdateOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// CreateOrUpdate ... -func (c IdentityProviderClient) CreateOrUpdate(ctx context.Context, id IdentityProviderId, input IdentityProviderCreateContract, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdate(ctx, id, input, options) - if err != nil { - err = autorest.NewErrorWithError(err, "identityprovider.IdentityProviderClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "identityprovider.IdentityProviderClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCreateOrUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "identityprovider.IdentityProviderClient", "CreateOrUpdate", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCreateOrUpdate prepares the CreateOrUpdate request. -func (c IdentityProviderClient) preparerForCreateOrUpdate(ctx context.Context, id IdentityProviderId, input IdentityProviderCreateContract, options CreateOrUpdateOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - 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 IdentityProviderClient) responderForCreateOrUpdate(resp *http.Response) (result CreateOrUpdateOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2021-08-01/identityprovider/method_delete.go b/resource-manager/apimanagement/2021-08-01/identityprovider/method_delete.go new file mode 100644 index 00000000000..ff4f9cee7c4 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/identityprovider/method_delete.go @@ -0,0 +1,76 @@ +package identityprovider + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +type DeleteOperationOptions struct { + IfMatch *string +} + +func DefaultDeleteOperationOptions() DeleteOperationOptions { + return DeleteOperationOptions{} +} + +func (o DeleteOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o DeleteOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o DeleteOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// Delete ... +func (c IdentityProviderClient) Delete(ctx context.Context, id IdentityProviderId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2021-08-01/identityprovider/method_delete_autorest.go b/resource-manager/apimanagement/2021-08-01/identityprovider/method_delete_autorest.go deleted file mode 100644 index d65e64e44b4..00000000000 --- a/resource-manager/apimanagement/2021-08-01/identityprovider/method_delete_autorest.go +++ /dev/null @@ -1,95 +0,0 @@ -package identityprovider - -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 DeleteOperationResponse struct { - HttpResponse *http.Response -} - -type DeleteOperationOptions struct { - IfMatch *string -} - -func DefaultDeleteOperationOptions() DeleteOperationOptions { - return DeleteOperationOptions{} -} - -func (o DeleteOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o DeleteOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// Delete ... -func (c IdentityProviderClient) Delete(ctx context.Context, id IdentityProviderId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { - req, err := c.preparerForDelete(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "identityprovider.IdentityProviderClient", "Delete", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "identityprovider.IdentityProviderClient", "Delete", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForDelete(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "identityprovider.IdentityProviderClient", "Delete", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForDelete prepares the Delete request. -func (c IdentityProviderClient) preparerForDelete(ctx context.Context, id IdentityProviderId, options DeleteOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForDelete handles the response to the Delete request. The method always -// closes the http.Response Body. -func (c IdentityProviderClient) responderForDelete(resp *http.Response) (result DeleteOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2021-08-01/identityprovider/method_get.go b/resource-manager/apimanagement/2021-08-01/identityprovider/method_get.go new file mode 100644 index 00000000000..3ea0d912b93 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/identityprovider/method_get.go @@ -0,0 +1,51 @@ +package identityprovider + +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 *IdentityProviderContract +} + +// Get ... +func (c IdentityProviderClient) Get(ctx context.Context, id IdentityProviderId) (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/apimanagement/2021-08-01/identityprovider/method_get_autorest.go b/resource-manager/apimanagement/2021-08-01/identityprovider/method_get_autorest.go deleted file mode 100644 index 05ae191473a..00000000000 --- a/resource-manager/apimanagement/2021-08-01/identityprovider/method_get_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package identityprovider - -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 *IdentityProviderContract -} - -// Get ... -func (c IdentityProviderClient) Get(ctx context.Context, id IdentityProviderId) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "identityprovider.IdentityProviderClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "identityprovider.IdentityProviderClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "identityprovider.IdentityProviderClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c IdentityProviderClient) preparerForGet(ctx context.Context, id IdentityProviderId) (*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 IdentityProviderClient) 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/apimanagement/2021-08-01/identityprovider/method_getentitytag.go b/resource-manager/apimanagement/2021-08-01/identityprovider/method_getentitytag.go new file mode 100644 index 00000000000..626d199ac1f --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/identityprovider/method_getentitytag.go @@ -0,0 +1,46 @@ +package identityprovider + +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 GetEntityTagOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// GetEntityTag ... +func (c IdentityProviderClient) GetEntityTag(ctx context.Context, id IdentityProviderId) (result GetEntityTagOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodHead, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2021-08-01/identityprovider/method_getentitytag_autorest.go b/resource-manager/apimanagement/2021-08-01/identityprovider/method_getentitytag_autorest.go deleted file mode 100644 index 1df4d8b8805..00000000000 --- a/resource-manager/apimanagement/2021-08-01/identityprovider/method_getentitytag_autorest.go +++ /dev/null @@ -1,66 +0,0 @@ -package identityprovider - -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 GetEntityTagOperationResponse struct { - HttpResponse *http.Response -} - -// GetEntityTag ... -func (c IdentityProviderClient) GetEntityTag(ctx context.Context, id IdentityProviderId) (result GetEntityTagOperationResponse, err error) { - req, err := c.preparerForGetEntityTag(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "identityprovider.IdentityProviderClient", "GetEntityTag", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "identityprovider.IdentityProviderClient", "GetEntityTag", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetEntityTag(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "identityprovider.IdentityProviderClient", "GetEntityTag", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetEntityTag prepares the GetEntityTag request. -func (c IdentityProviderClient) preparerForGetEntityTag(ctx context.Context, id IdentityProviderId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsHead(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetEntityTag handles the response to the GetEntityTag request. The method always -// closes the http.Response Body. -func (c IdentityProviderClient) responderForGetEntityTag(resp *http.Response) (result GetEntityTagOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2021-08-01/identityprovider/method_listbyservice.go b/resource-manager/apimanagement/2021-08-01/identityprovider/method_listbyservice.go new file mode 100644 index 00000000000..881b7200016 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/identityprovider/method_listbyservice.go @@ -0,0 +1,89 @@ +package identityprovider + +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 ListByServiceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]IdentityProviderContract +} + +type ListByServiceCompleteResult struct { + Items []IdentityProviderContract +} + +// ListByService ... +func (c IdentityProviderClient) ListByService(ctx context.Context, id ServiceId) (result ListByServiceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/identityProviders", 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 *[]IdentityProviderContract `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByServiceComplete retrieves all the results into a single object +func (c IdentityProviderClient) ListByServiceComplete(ctx context.Context, id ServiceId) (ListByServiceCompleteResult, error) { + return c.ListByServiceCompleteMatchingPredicate(ctx, id, IdentityProviderContractOperationPredicate{}) +} + +// ListByServiceCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c IdentityProviderClient) ListByServiceCompleteMatchingPredicate(ctx context.Context, id ServiceId, predicate IdentityProviderContractOperationPredicate) (result ListByServiceCompleteResult, err error) { + items := make([]IdentityProviderContract, 0) + + resp, err := c.ListByService(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 = ListByServiceCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/apimanagement/2021-08-01/identityprovider/method_listbyservice_autorest.go b/resource-manager/apimanagement/2021-08-01/identityprovider/method_listbyservice_autorest.go deleted file mode 100644 index 993d95a854d..00000000000 --- a/resource-manager/apimanagement/2021-08-01/identityprovider/method_listbyservice_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package identityprovider - -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 ListByServiceOperationResponse struct { - HttpResponse *http.Response - Model *[]IdentityProviderContract - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListByServiceOperationResponse, error) -} - -type ListByServiceCompleteResult struct { - Items []IdentityProviderContract -} - -func (r ListByServiceOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListByServiceOperationResponse) LoadMore(ctx context.Context) (resp ListByServiceOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListByService ... -func (c IdentityProviderClient) ListByService(ctx context.Context, id ServiceId) (resp ListByServiceOperationResponse, err error) { - req, err := c.preparerForListByService(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "identityprovider.IdentityProviderClient", "ListByService", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "identityprovider.IdentityProviderClient", "ListByService", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListByService(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "identityprovider.IdentityProviderClient", "ListByService", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListByService prepares the ListByService request. -func (c IdentityProviderClient) preparerForListByService(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(fmt.Sprintf("%s/identityProviders", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListByServiceWithNextLink prepares the ListByService request with the given nextLink token. -func (c IdentityProviderClient) preparerForListByServiceWithNextLink(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)) -} - -// responderForListByService handles the response to the ListByService request. The method always -// closes the http.Response Body. -func (c IdentityProviderClient) responderForListByService(resp *http.Response) (result ListByServiceOperationResponse, err error) { - type page struct { - Values []IdentityProviderContract `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 ListByServiceOperationResponse, err error) { - req, err := c.preparerForListByServiceWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "identityprovider.IdentityProviderClient", "ListByService", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "identityprovider.IdentityProviderClient", "ListByService", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByService(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "identityprovider.IdentityProviderClient", "ListByService", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListByServiceComplete retrieves all of the results into a single object -func (c IdentityProviderClient) ListByServiceComplete(ctx context.Context, id ServiceId) (ListByServiceCompleteResult, error) { - return c.ListByServiceCompleteMatchingPredicate(ctx, id, IdentityProviderContractOperationPredicate{}) -} - -// ListByServiceCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c IdentityProviderClient) ListByServiceCompleteMatchingPredicate(ctx context.Context, id ServiceId, predicate IdentityProviderContractOperationPredicate) (resp ListByServiceCompleteResult, err error) { - items := make([]IdentityProviderContract, 0) - - page, err := c.ListByService(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 := ListByServiceCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/apimanagement/2021-08-01/identityprovider/method_listsecrets.go b/resource-manager/apimanagement/2021-08-01/identityprovider/method_listsecrets.go new file mode 100644 index 00000000000..bf808b63434 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/identityprovider/method_listsecrets.go @@ -0,0 +1,52 @@ +package identityprovider + +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 ListSecretsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ClientSecretContract +} + +// ListSecrets ... +func (c IdentityProviderClient) ListSecrets(ctx context.Context, id IdentityProviderId) (result ListSecretsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/listSecrets", 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/apimanagement/2021-08-01/identityprovider/method_listsecrets_autorest.go b/resource-manager/apimanagement/2021-08-01/identityprovider/method_listsecrets_autorest.go deleted file mode 100644 index 1e36cc02469..00000000000 --- a/resource-manager/apimanagement/2021-08-01/identityprovider/method_listsecrets_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package identityprovider - -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 ListSecretsOperationResponse struct { - HttpResponse *http.Response - Model *ClientSecretContract -} - -// ListSecrets ... -func (c IdentityProviderClient) ListSecrets(ctx context.Context, id IdentityProviderId) (result ListSecretsOperationResponse, err error) { - req, err := c.preparerForListSecrets(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "identityprovider.IdentityProviderClient", "ListSecrets", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "identityprovider.IdentityProviderClient", "ListSecrets", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListSecrets(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "identityprovider.IdentityProviderClient", "ListSecrets", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForListSecrets prepares the ListSecrets request. -func (c IdentityProviderClient) preparerForListSecrets(ctx context.Context, id IdentityProviderId) (*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/listSecrets", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListSecrets handles the response to the ListSecrets request. The method always -// closes the http.Response Body. -func (c IdentityProviderClient) responderForListSecrets(resp *http.Response) (result ListSecretsOperationResponse, 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/apimanagement/2021-08-01/identityprovider/method_update.go b/resource-manager/apimanagement/2021-08-01/identityprovider/method_update.go new file mode 100644 index 00000000000..9ac8eaebfa4 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/identityprovider/method_update.go @@ -0,0 +1,84 @@ +package identityprovider + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *IdentityProviderContract +} + +type UpdateOperationOptions struct { + IfMatch *string +} + +func DefaultUpdateOperationOptions() UpdateOperationOptions { + return UpdateOperationOptions{} +} + +func (o UpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o UpdateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o UpdateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// Update ... +func (c IdentityProviderClient) Update(ctx context.Context, id IdentityProviderId, input IdentityProviderUpdateParameters, options UpdateOperationOptions) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + OptionsObject: options, + } + + 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/apimanagement/2021-08-01/identityprovider/method_update_autorest.go b/resource-manager/apimanagement/2021-08-01/identityprovider/method_update_autorest.go deleted file mode 100644 index 0f1cbf0647f..00000000000 --- a/resource-manager/apimanagement/2021-08-01/identityprovider/method_update_autorest.go +++ /dev/null @@ -1,98 +0,0 @@ -package identityprovider - -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 *IdentityProviderContract -} - -type UpdateOperationOptions struct { - IfMatch *string -} - -func DefaultUpdateOperationOptions() UpdateOperationOptions { - return UpdateOperationOptions{} -} - -func (o UpdateOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o UpdateOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// Update ... -func (c IdentityProviderClient) Update(ctx context.Context, id IdentityProviderId, input IdentityProviderUpdateParameters, options UpdateOperationOptions) (result UpdateOperationResponse, err error) { - req, err := c.preparerForUpdate(ctx, id, input, options) - if err != nil { - err = autorest.NewErrorWithError(err, "identityprovider.IdentityProviderClient", "Update", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "identityprovider.IdentityProviderClient", "Update", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "identityprovider.IdentityProviderClient", "Update", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForUpdate prepares the Update request. -func (c IdentityProviderClient) preparerForUpdate(ctx context.Context, id IdentityProviderId, input IdentityProviderUpdateParameters, options UpdateOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPatch(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - 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 IdentityProviderClient) 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/apimanagement/2021-08-01/issue/client.go b/resource-manager/apimanagement/2021-08-01/issue/client.go index 973a74c9ec3..da86b4f1e45 100644 --- a/resource-manager/apimanagement/2021-08-01/issue/client.go +++ b/resource-manager/apimanagement/2021-08-01/issue/client.go @@ -1,18 +1,26 @@ package issue -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 IssueClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewIssueClientWithBaseURI(endpoint string) IssueClient { - return IssueClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewIssueClientWithBaseURI(api environments.Api) (*IssueClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "issue", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating IssueClient: %+v", err) } + + return &IssueClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2021-08-01/issue/constants.go b/resource-manager/apimanagement/2021-08-01/issue/constants.go index 837f3883c24..737222a81b0 100644 --- a/resource-manager/apimanagement/2021-08-01/issue/constants.go +++ b/resource-manager/apimanagement/2021-08-01/issue/constants.go @@ -1,6 +1,10 @@ package issue -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. @@ -25,6 +29,19 @@ func PossibleValuesForState() []string { } } +func (s *State) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseState(input string) (*State, error) { vals := map[string]State{ "closed": StateClosed, diff --git a/resource-manager/apimanagement/2021-08-01/issue/method_get.go b/resource-manager/apimanagement/2021-08-01/issue/method_get.go new file mode 100644 index 00000000000..d23f005d647 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/issue/method_get.go @@ -0,0 +1,51 @@ +package issue + +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 *IssueContract +} + +// Get ... +func (c IssueClient) Get(ctx context.Context, id IssueId) (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/apimanagement/2021-08-01/issue/method_get_autorest.go b/resource-manager/apimanagement/2021-08-01/issue/method_get_autorest.go deleted file mode 100644 index fbdc95d1081..00000000000 --- a/resource-manager/apimanagement/2021-08-01/issue/method_get_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package issue - -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 *IssueContract -} - -// Get ... -func (c IssueClient) Get(ctx context.Context, id IssueId) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "issue.IssueClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "issue.IssueClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "issue.IssueClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c IssueClient) preparerForGet(ctx context.Context, id IssueId) (*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 IssueClient) 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/apimanagement/2021-08-01/issue/method_listbyservice.go b/resource-manager/apimanagement/2021-08-01/issue/method_listbyservice.go new file mode 100644 index 00000000000..f18cb96e08c --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/issue/method_listbyservice.go @@ -0,0 +1,125 @@ +package issue + +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 ListByServiceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]IssueContract +} + +type ListByServiceCompleteResult struct { + Items []IssueContract +} + +type ListByServiceOperationOptions struct { + Filter *string + Skip *int64 + Top *int64 +} + +func DefaultListByServiceOperationOptions() ListByServiceOperationOptions { + return ListByServiceOperationOptions{} +} + +func (o ListByServiceOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListByServiceOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListByServiceOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.Skip != nil { + out.Append("$skip", fmt.Sprintf("%v", *o.Skip)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +// ListByService ... +func (c IssueClient) ListByService(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (result ListByServiceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/issues", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]IssueContract `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByServiceComplete retrieves all the results into a single object +func (c IssueClient) ListByServiceComplete(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (ListByServiceCompleteResult, error) { + return c.ListByServiceCompleteMatchingPredicate(ctx, id, options, IssueContractOperationPredicate{}) +} + +// ListByServiceCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c IssueClient) ListByServiceCompleteMatchingPredicate(ctx context.Context, id ServiceId, options ListByServiceOperationOptions, predicate IssueContractOperationPredicate) (result ListByServiceCompleteResult, err error) { + items := make([]IssueContract, 0) + + resp, err := c.ListByService(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByServiceCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/apimanagement/2021-08-01/issue/method_listbyservice_autorest.go b/resource-manager/apimanagement/2021-08-01/issue/method_listbyservice_autorest.go deleted file mode 100644 index c811024f3da..00000000000 --- a/resource-manager/apimanagement/2021-08-01/issue/method_listbyservice_autorest.go +++ /dev/null @@ -1,225 +0,0 @@ -package issue - -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 ListByServiceOperationResponse struct { - HttpResponse *http.Response - Model *[]IssueContract - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListByServiceOperationResponse, error) -} - -type ListByServiceCompleteResult struct { - Items []IssueContract -} - -func (r ListByServiceOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListByServiceOperationResponse) LoadMore(ctx context.Context) (resp ListByServiceOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -type ListByServiceOperationOptions struct { - Filter *string - Skip *int64 - Top *int64 -} - -func DefaultListByServiceOperationOptions() ListByServiceOperationOptions { - return ListByServiceOperationOptions{} -} - -func (o ListByServiceOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o ListByServiceOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Filter != nil { - out["$filter"] = *o.Filter - } - - if o.Skip != nil { - out["$skip"] = *o.Skip - } - - if o.Top != nil { - out["$top"] = *o.Top - } - - return out -} - -// ListByService ... -func (c IssueClient) ListByService(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (resp ListByServiceOperationResponse, err error) { - req, err := c.preparerForListByService(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "issue.IssueClient", "ListByService", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "issue.IssueClient", "ListByService", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListByService(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "issue.IssueClient", "ListByService", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListByService prepares the ListByService request. -func (c IssueClient) preparerForListByService(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/issues", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListByServiceWithNextLink prepares the ListByService request with the given nextLink token. -func (c IssueClient) preparerForListByServiceWithNextLink(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)) -} - -// responderForListByService handles the response to the ListByService request. The method always -// closes the http.Response Body. -func (c IssueClient) responderForListByService(resp *http.Response) (result ListByServiceOperationResponse, err error) { - type page struct { - Values []IssueContract `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 ListByServiceOperationResponse, err error) { - req, err := c.preparerForListByServiceWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "issue.IssueClient", "ListByService", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "issue.IssueClient", "ListByService", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByService(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "issue.IssueClient", "ListByService", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListByServiceComplete retrieves all of the results into a single object -func (c IssueClient) ListByServiceComplete(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (ListByServiceCompleteResult, error) { - return c.ListByServiceCompleteMatchingPredicate(ctx, id, options, IssueContractOperationPredicate{}) -} - -// ListByServiceCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c IssueClient) ListByServiceCompleteMatchingPredicate(ctx context.Context, id ServiceId, options ListByServiceOperationOptions, predicate IssueContractOperationPredicate) (resp ListByServiceCompleteResult, err error) { - items := make([]IssueContract, 0) - - page, err := c.ListByService(ctx, id, options) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListByServiceCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/apimanagement/2021-08-01/logger/client.go b/resource-manager/apimanagement/2021-08-01/logger/client.go index 35b0189b9e7..2e9c29e82cb 100644 --- a/resource-manager/apimanagement/2021-08-01/logger/client.go +++ b/resource-manager/apimanagement/2021-08-01/logger/client.go @@ -1,18 +1,26 @@ package logger -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 LoggerClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewLoggerClientWithBaseURI(endpoint string) LoggerClient { - return LoggerClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewLoggerClientWithBaseURI(api environments.Api) (*LoggerClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "logger", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating LoggerClient: %+v", err) } + + return &LoggerClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2021-08-01/logger/constants.go b/resource-manager/apimanagement/2021-08-01/logger/constants.go index cf45d74e056..0aa7cb68a3e 100644 --- a/resource-manager/apimanagement/2021-08-01/logger/constants.go +++ b/resource-manager/apimanagement/2021-08-01/logger/constants.go @@ -1,6 +1,10 @@ package logger -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 PossibleValuesForLoggerType() []string { } } +func (s *LoggerType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseLoggerType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseLoggerType(input string) (*LoggerType, error) { vals := map[string]LoggerType{ "applicationinsights": LoggerTypeApplicationInsights, diff --git a/resource-manager/apimanagement/2021-08-01/logger/method_createorupdate.go b/resource-manager/apimanagement/2021-08-01/logger/method_createorupdate.go new file mode 100644 index 00000000000..5afa3c7881e --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/logger/method_createorupdate.go @@ -0,0 +1,85 @@ +package logger + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *LoggerContract +} + +type CreateOrUpdateOperationOptions struct { + IfMatch *string +} + +func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { + return CreateOrUpdateOperationOptions{} +} + +func (o CreateOrUpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o CreateOrUpdateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o CreateOrUpdateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// CreateOrUpdate ... +func (c LoggerClient) CreateOrUpdate(ctx context.Context, id LoggerId, input LoggerContract, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + OptionsObject: options, + } + + 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/apimanagement/2021-08-01/logger/method_createorupdate_autorest.go b/resource-manager/apimanagement/2021-08-01/logger/method_createorupdate_autorest.go deleted file mode 100644 index 0575dfc04e6..00000000000 --- a/resource-manager/apimanagement/2021-08-01/logger/method_createorupdate_autorest.go +++ /dev/null @@ -1,98 +0,0 @@ -package logger - -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 *LoggerContract -} - -type CreateOrUpdateOperationOptions struct { - IfMatch *string -} - -func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { - return CreateOrUpdateOperationOptions{} -} - -func (o CreateOrUpdateOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o CreateOrUpdateOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// CreateOrUpdate ... -func (c LoggerClient) CreateOrUpdate(ctx context.Context, id LoggerId, input LoggerContract, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdate(ctx, id, input, options) - if err != nil { - err = autorest.NewErrorWithError(err, "logger.LoggerClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "logger.LoggerClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCreateOrUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "logger.LoggerClient", "CreateOrUpdate", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCreateOrUpdate prepares the CreateOrUpdate request. -func (c LoggerClient) preparerForCreateOrUpdate(ctx context.Context, id LoggerId, input LoggerContract, options CreateOrUpdateOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - 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 LoggerClient) responderForCreateOrUpdate(resp *http.Response) (result CreateOrUpdateOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2021-08-01/logger/method_delete.go b/resource-manager/apimanagement/2021-08-01/logger/method_delete.go new file mode 100644 index 00000000000..9a3b1b42ad9 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/logger/method_delete.go @@ -0,0 +1,76 @@ +package logger + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +type DeleteOperationOptions struct { + IfMatch *string +} + +func DefaultDeleteOperationOptions() DeleteOperationOptions { + return DeleteOperationOptions{} +} + +func (o DeleteOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o DeleteOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o DeleteOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// Delete ... +func (c LoggerClient) Delete(ctx context.Context, id LoggerId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2021-08-01/logger/method_delete_autorest.go b/resource-manager/apimanagement/2021-08-01/logger/method_delete_autorest.go deleted file mode 100644 index cdc22bf87cc..00000000000 --- a/resource-manager/apimanagement/2021-08-01/logger/method_delete_autorest.go +++ /dev/null @@ -1,95 +0,0 @@ -package logger - -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 DeleteOperationResponse struct { - HttpResponse *http.Response -} - -type DeleteOperationOptions struct { - IfMatch *string -} - -func DefaultDeleteOperationOptions() DeleteOperationOptions { - return DeleteOperationOptions{} -} - -func (o DeleteOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o DeleteOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// Delete ... -func (c LoggerClient) Delete(ctx context.Context, id LoggerId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { - req, err := c.preparerForDelete(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "logger.LoggerClient", "Delete", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "logger.LoggerClient", "Delete", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForDelete(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "logger.LoggerClient", "Delete", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForDelete prepares the Delete request. -func (c LoggerClient) preparerForDelete(ctx context.Context, id LoggerId, options DeleteOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForDelete handles the response to the Delete request. The method always -// closes the http.Response Body. -func (c LoggerClient) responderForDelete(resp *http.Response) (result DeleteOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2021-08-01/logger/method_get.go b/resource-manager/apimanagement/2021-08-01/logger/method_get.go new file mode 100644 index 00000000000..a755ecf8263 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/logger/method_get.go @@ -0,0 +1,51 @@ +package logger + +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 *LoggerContract +} + +// Get ... +func (c LoggerClient) Get(ctx context.Context, id LoggerId) (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/apimanagement/2021-08-01/logger/method_get_autorest.go b/resource-manager/apimanagement/2021-08-01/logger/method_get_autorest.go deleted file mode 100644 index 37e10193f3d..00000000000 --- a/resource-manager/apimanagement/2021-08-01/logger/method_get_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package logger - -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 *LoggerContract -} - -// Get ... -func (c LoggerClient) Get(ctx context.Context, id LoggerId) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "logger.LoggerClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "logger.LoggerClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "logger.LoggerClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c LoggerClient) preparerForGet(ctx context.Context, id LoggerId) (*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 LoggerClient) 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/apimanagement/2021-08-01/logger/method_getentitytag.go b/resource-manager/apimanagement/2021-08-01/logger/method_getentitytag.go new file mode 100644 index 00000000000..b65f6ac22bd --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/logger/method_getentitytag.go @@ -0,0 +1,46 @@ +package logger + +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 GetEntityTagOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// GetEntityTag ... +func (c LoggerClient) GetEntityTag(ctx context.Context, id LoggerId) (result GetEntityTagOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodHead, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2021-08-01/logger/method_getentitytag_autorest.go b/resource-manager/apimanagement/2021-08-01/logger/method_getentitytag_autorest.go deleted file mode 100644 index 4e2a41cb3a9..00000000000 --- a/resource-manager/apimanagement/2021-08-01/logger/method_getentitytag_autorest.go +++ /dev/null @@ -1,66 +0,0 @@ -package logger - -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 GetEntityTagOperationResponse struct { - HttpResponse *http.Response -} - -// GetEntityTag ... -func (c LoggerClient) GetEntityTag(ctx context.Context, id LoggerId) (result GetEntityTagOperationResponse, err error) { - req, err := c.preparerForGetEntityTag(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "logger.LoggerClient", "GetEntityTag", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "logger.LoggerClient", "GetEntityTag", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetEntityTag(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "logger.LoggerClient", "GetEntityTag", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetEntityTag prepares the GetEntityTag request. -func (c LoggerClient) preparerForGetEntityTag(ctx context.Context, id LoggerId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsHead(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetEntityTag handles the response to the GetEntityTag request. The method always -// closes the http.Response Body. -func (c LoggerClient) responderForGetEntityTag(resp *http.Response) (result GetEntityTagOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2021-08-01/logger/method_listbyservice.go b/resource-manager/apimanagement/2021-08-01/logger/method_listbyservice.go new file mode 100644 index 00000000000..6049c405eb8 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/logger/method_listbyservice.go @@ -0,0 +1,125 @@ +package logger + +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 ListByServiceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]LoggerContract +} + +type ListByServiceCompleteResult struct { + Items []LoggerContract +} + +type ListByServiceOperationOptions struct { + Filter *string + Skip *int64 + Top *int64 +} + +func DefaultListByServiceOperationOptions() ListByServiceOperationOptions { + return ListByServiceOperationOptions{} +} + +func (o ListByServiceOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListByServiceOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListByServiceOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.Skip != nil { + out.Append("$skip", fmt.Sprintf("%v", *o.Skip)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +// ListByService ... +func (c LoggerClient) ListByService(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (result ListByServiceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/loggers", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]LoggerContract `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByServiceComplete retrieves all the results into a single object +func (c LoggerClient) ListByServiceComplete(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (ListByServiceCompleteResult, error) { + return c.ListByServiceCompleteMatchingPredicate(ctx, id, options, LoggerContractOperationPredicate{}) +} + +// ListByServiceCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c LoggerClient) ListByServiceCompleteMatchingPredicate(ctx context.Context, id ServiceId, options ListByServiceOperationOptions, predicate LoggerContractOperationPredicate) (result ListByServiceCompleteResult, err error) { + items := make([]LoggerContract, 0) + + resp, err := c.ListByService(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByServiceCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/apimanagement/2021-08-01/logger/method_listbyservice_autorest.go b/resource-manager/apimanagement/2021-08-01/logger/method_listbyservice_autorest.go deleted file mode 100644 index 23f43bba9ca..00000000000 --- a/resource-manager/apimanagement/2021-08-01/logger/method_listbyservice_autorest.go +++ /dev/null @@ -1,225 +0,0 @@ -package logger - -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 ListByServiceOperationResponse struct { - HttpResponse *http.Response - Model *[]LoggerContract - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListByServiceOperationResponse, error) -} - -type ListByServiceCompleteResult struct { - Items []LoggerContract -} - -func (r ListByServiceOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListByServiceOperationResponse) LoadMore(ctx context.Context) (resp ListByServiceOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -type ListByServiceOperationOptions struct { - Filter *string - Skip *int64 - Top *int64 -} - -func DefaultListByServiceOperationOptions() ListByServiceOperationOptions { - return ListByServiceOperationOptions{} -} - -func (o ListByServiceOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o ListByServiceOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Filter != nil { - out["$filter"] = *o.Filter - } - - if o.Skip != nil { - out["$skip"] = *o.Skip - } - - if o.Top != nil { - out["$top"] = *o.Top - } - - return out -} - -// ListByService ... -func (c LoggerClient) ListByService(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (resp ListByServiceOperationResponse, err error) { - req, err := c.preparerForListByService(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "logger.LoggerClient", "ListByService", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "logger.LoggerClient", "ListByService", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListByService(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "logger.LoggerClient", "ListByService", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListByService prepares the ListByService request. -func (c LoggerClient) preparerForListByService(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/loggers", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListByServiceWithNextLink prepares the ListByService request with the given nextLink token. -func (c LoggerClient) preparerForListByServiceWithNextLink(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)) -} - -// responderForListByService handles the response to the ListByService request. The method always -// closes the http.Response Body. -func (c LoggerClient) responderForListByService(resp *http.Response) (result ListByServiceOperationResponse, err error) { - type page struct { - Values []LoggerContract `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 ListByServiceOperationResponse, err error) { - req, err := c.preparerForListByServiceWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "logger.LoggerClient", "ListByService", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "logger.LoggerClient", "ListByService", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByService(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "logger.LoggerClient", "ListByService", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListByServiceComplete retrieves all of the results into a single object -func (c LoggerClient) ListByServiceComplete(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (ListByServiceCompleteResult, error) { - return c.ListByServiceCompleteMatchingPredicate(ctx, id, options, LoggerContractOperationPredicate{}) -} - -// ListByServiceCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c LoggerClient) ListByServiceCompleteMatchingPredicate(ctx context.Context, id ServiceId, options ListByServiceOperationOptions, predicate LoggerContractOperationPredicate) (resp ListByServiceCompleteResult, err error) { - items := make([]LoggerContract, 0) - - page, err := c.ListByService(ctx, id, options) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListByServiceCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/apimanagement/2021-08-01/logger/method_update.go b/resource-manager/apimanagement/2021-08-01/logger/method_update.go new file mode 100644 index 00000000000..f7245ad9404 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/logger/method_update.go @@ -0,0 +1,84 @@ +package logger + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *LoggerContract +} + +type UpdateOperationOptions struct { + IfMatch *string +} + +func DefaultUpdateOperationOptions() UpdateOperationOptions { + return UpdateOperationOptions{} +} + +func (o UpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o UpdateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o UpdateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// Update ... +func (c LoggerClient) Update(ctx context.Context, id LoggerId, input LoggerUpdateContract, options UpdateOperationOptions) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + OptionsObject: options, + } + + 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/apimanagement/2021-08-01/logger/method_update_autorest.go b/resource-manager/apimanagement/2021-08-01/logger/method_update_autorest.go deleted file mode 100644 index 73a90ec1fbc..00000000000 --- a/resource-manager/apimanagement/2021-08-01/logger/method_update_autorest.go +++ /dev/null @@ -1,98 +0,0 @@ -package logger - -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 *LoggerContract -} - -type UpdateOperationOptions struct { - IfMatch *string -} - -func DefaultUpdateOperationOptions() UpdateOperationOptions { - return UpdateOperationOptions{} -} - -func (o UpdateOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o UpdateOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// Update ... -func (c LoggerClient) Update(ctx context.Context, id LoggerId, input LoggerUpdateContract, options UpdateOperationOptions) (result UpdateOperationResponse, err error) { - req, err := c.preparerForUpdate(ctx, id, input, options) - if err != nil { - err = autorest.NewErrorWithError(err, "logger.LoggerClient", "Update", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "logger.LoggerClient", "Update", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "logger.LoggerClient", "Update", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForUpdate prepares the Update request. -func (c LoggerClient) preparerForUpdate(ctx context.Context, id LoggerId, input LoggerUpdateContract, options UpdateOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPatch(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - 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 LoggerClient) 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/apimanagement/2021-08-01/namedvalue/client.go b/resource-manager/apimanagement/2021-08-01/namedvalue/client.go index 50c96afd343..e7f6f57c3c7 100644 --- a/resource-manager/apimanagement/2021-08-01/namedvalue/client.go +++ b/resource-manager/apimanagement/2021-08-01/namedvalue/client.go @@ -1,18 +1,26 @@ package namedvalue -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 NamedValueClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewNamedValueClientWithBaseURI(endpoint string) NamedValueClient { - return NamedValueClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewNamedValueClientWithBaseURI(api environments.Api) (*NamedValueClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "namedvalue", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating NamedValueClient: %+v", err) } + + return &NamedValueClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2021-08-01/namedvalue/method_createorupdate.go b/resource-manager/apimanagement/2021-08-01/namedvalue/method_createorupdate.go new file mode 100644 index 00000000000..09c8aa0bbe5 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/namedvalue/method_createorupdate.go @@ -0,0 +1,103 @@ +package namedvalue + +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 +} + +type CreateOrUpdateOperationOptions struct { + IfMatch *string +} + +func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { + return CreateOrUpdateOperationOptions{} +} + +func (o CreateOrUpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o CreateOrUpdateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o CreateOrUpdateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// CreateOrUpdate ... +func (c NamedValueClient) CreateOrUpdate(ctx context.Context, id NamedValueId, input NamedValueCreateContract, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + OptionsObject: options, + } + + 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 NamedValueClient) CreateOrUpdateThenPoll(ctx context.Context, id NamedValueId, input NamedValueCreateContract, options CreateOrUpdateOperationOptions) error { + result, err := c.CreateOrUpdate(ctx, id, input, options) + 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/apimanagement/2021-08-01/namedvalue/method_createorupdate_autorest.go b/resource-manager/apimanagement/2021-08-01/namedvalue/method_createorupdate_autorest.go deleted file mode 100644 index 7f838bb490b..00000000000 --- a/resource-manager/apimanagement/2021-08-01/namedvalue/method_createorupdate_autorest.go +++ /dev/null @@ -1,108 +0,0 @@ -package namedvalue - -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 -} - -type CreateOrUpdateOperationOptions struct { - IfMatch *string -} - -func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { - return CreateOrUpdateOperationOptions{} -} - -func (o CreateOrUpdateOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o CreateOrUpdateOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// CreateOrUpdate ... -func (c NamedValueClient) CreateOrUpdate(ctx context.Context, id NamedValueId, input NamedValueCreateContract, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdate(ctx, id, input, options) - if err != nil { - err = autorest.NewErrorWithError(err, "namedvalue.NamedValueClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result, err = c.senderForCreateOrUpdate(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "namedvalue.NamedValueClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed -func (c NamedValueClient) CreateOrUpdateThenPoll(ctx context.Context, id NamedValueId, input NamedValueCreateContract, options CreateOrUpdateOperationOptions) error { - result, err := c.CreateOrUpdate(ctx, id, input, options) - 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 NamedValueClient) preparerForCreateOrUpdate(ctx context.Context, id NamedValueId, input NamedValueCreateContract, options CreateOrUpdateOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - 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 NamedValueClient) 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/apimanagement/2021-08-01/namedvalue/method_delete.go b/resource-manager/apimanagement/2021-08-01/namedvalue/method_delete.go new file mode 100644 index 00000000000..82bbf62ac51 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/namedvalue/method_delete.go @@ -0,0 +1,76 @@ +package namedvalue + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +type DeleteOperationOptions struct { + IfMatch *string +} + +func DefaultDeleteOperationOptions() DeleteOperationOptions { + return DeleteOperationOptions{} +} + +func (o DeleteOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o DeleteOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o DeleteOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// Delete ... +func (c NamedValueClient) Delete(ctx context.Context, id NamedValueId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2021-08-01/namedvalue/method_delete_autorest.go b/resource-manager/apimanagement/2021-08-01/namedvalue/method_delete_autorest.go deleted file mode 100644 index da4a8178f35..00000000000 --- a/resource-manager/apimanagement/2021-08-01/namedvalue/method_delete_autorest.go +++ /dev/null @@ -1,95 +0,0 @@ -package namedvalue - -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 DeleteOperationResponse struct { - HttpResponse *http.Response -} - -type DeleteOperationOptions struct { - IfMatch *string -} - -func DefaultDeleteOperationOptions() DeleteOperationOptions { - return DeleteOperationOptions{} -} - -func (o DeleteOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o DeleteOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// Delete ... -func (c NamedValueClient) Delete(ctx context.Context, id NamedValueId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { - req, err := c.preparerForDelete(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "namedvalue.NamedValueClient", "Delete", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "namedvalue.NamedValueClient", "Delete", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForDelete(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "namedvalue.NamedValueClient", "Delete", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForDelete prepares the Delete request. -func (c NamedValueClient) preparerForDelete(ctx context.Context, id NamedValueId, options DeleteOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForDelete handles the response to the Delete request. The method always -// closes the http.Response Body. -func (c NamedValueClient) responderForDelete(resp *http.Response) (result DeleteOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2021-08-01/namedvalue/method_get.go b/resource-manager/apimanagement/2021-08-01/namedvalue/method_get.go new file mode 100644 index 00000000000..db6c7dc54e2 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/namedvalue/method_get.go @@ -0,0 +1,51 @@ +package namedvalue + +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 *NamedValueContract +} + +// Get ... +func (c NamedValueClient) Get(ctx context.Context, id NamedValueId) (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/apimanagement/2021-08-01/namedvalue/method_get_autorest.go b/resource-manager/apimanagement/2021-08-01/namedvalue/method_get_autorest.go deleted file mode 100644 index ce18c60cb5f..00000000000 --- a/resource-manager/apimanagement/2021-08-01/namedvalue/method_get_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package namedvalue - -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 *NamedValueContract -} - -// Get ... -func (c NamedValueClient) Get(ctx context.Context, id NamedValueId) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "namedvalue.NamedValueClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "namedvalue.NamedValueClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "namedvalue.NamedValueClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c NamedValueClient) preparerForGet(ctx context.Context, id NamedValueId) (*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 NamedValueClient) 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/apimanagement/2021-08-01/namedvalue/method_getentitytag.go b/resource-manager/apimanagement/2021-08-01/namedvalue/method_getentitytag.go new file mode 100644 index 00000000000..d292a66e0af --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/namedvalue/method_getentitytag.go @@ -0,0 +1,46 @@ +package namedvalue + +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 GetEntityTagOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// GetEntityTag ... +func (c NamedValueClient) GetEntityTag(ctx context.Context, id NamedValueId) (result GetEntityTagOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodHead, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2021-08-01/namedvalue/method_getentitytag_autorest.go b/resource-manager/apimanagement/2021-08-01/namedvalue/method_getentitytag_autorest.go deleted file mode 100644 index ac30709913d..00000000000 --- a/resource-manager/apimanagement/2021-08-01/namedvalue/method_getentitytag_autorest.go +++ /dev/null @@ -1,66 +0,0 @@ -package namedvalue - -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 GetEntityTagOperationResponse struct { - HttpResponse *http.Response -} - -// GetEntityTag ... -func (c NamedValueClient) GetEntityTag(ctx context.Context, id NamedValueId) (result GetEntityTagOperationResponse, err error) { - req, err := c.preparerForGetEntityTag(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "namedvalue.NamedValueClient", "GetEntityTag", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "namedvalue.NamedValueClient", "GetEntityTag", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetEntityTag(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "namedvalue.NamedValueClient", "GetEntityTag", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetEntityTag prepares the GetEntityTag request. -func (c NamedValueClient) preparerForGetEntityTag(ctx context.Context, id NamedValueId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsHead(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetEntityTag handles the response to the GetEntityTag request. The method always -// closes the http.Response Body. -func (c NamedValueClient) responderForGetEntityTag(resp *http.Response) (result GetEntityTagOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2021-08-01/namedvalue/method_listbyservice.go b/resource-manager/apimanagement/2021-08-01/namedvalue/method_listbyservice.go new file mode 100644 index 00000000000..ebb1b6b4849 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/namedvalue/method_listbyservice.go @@ -0,0 +1,129 @@ +package namedvalue + +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 ListByServiceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]NamedValueContract +} + +type ListByServiceCompleteResult struct { + Items []NamedValueContract +} + +type ListByServiceOperationOptions struct { + Filter *string + IsKeyVaultRefreshFailed *bool + Skip *int64 + Top *int64 +} + +func DefaultListByServiceOperationOptions() ListByServiceOperationOptions { + return ListByServiceOperationOptions{} +} + +func (o ListByServiceOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListByServiceOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListByServiceOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.IsKeyVaultRefreshFailed != nil { + out.Append("isKeyVaultRefreshFailed", fmt.Sprintf("%v", *o.IsKeyVaultRefreshFailed)) + } + if o.Skip != nil { + out.Append("$skip", fmt.Sprintf("%v", *o.Skip)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +// ListByService ... +func (c NamedValueClient) ListByService(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (result ListByServiceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/namedValues", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]NamedValueContract `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByServiceComplete retrieves all the results into a single object +func (c NamedValueClient) ListByServiceComplete(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (ListByServiceCompleteResult, error) { + return c.ListByServiceCompleteMatchingPredicate(ctx, id, options, NamedValueContractOperationPredicate{}) +} + +// ListByServiceCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c NamedValueClient) ListByServiceCompleteMatchingPredicate(ctx context.Context, id ServiceId, options ListByServiceOperationOptions, predicate NamedValueContractOperationPredicate) (result ListByServiceCompleteResult, err error) { + items := make([]NamedValueContract, 0) + + resp, err := c.ListByService(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByServiceCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/apimanagement/2021-08-01/namedvalue/method_listbyservice_autorest.go b/resource-manager/apimanagement/2021-08-01/namedvalue/method_listbyservice_autorest.go deleted file mode 100644 index cbfcd1b0b7b..00000000000 --- a/resource-manager/apimanagement/2021-08-01/namedvalue/method_listbyservice_autorest.go +++ /dev/null @@ -1,230 +0,0 @@ -package namedvalue - -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 ListByServiceOperationResponse struct { - HttpResponse *http.Response - Model *[]NamedValueContract - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListByServiceOperationResponse, error) -} - -type ListByServiceCompleteResult struct { - Items []NamedValueContract -} - -func (r ListByServiceOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListByServiceOperationResponse) LoadMore(ctx context.Context) (resp ListByServiceOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -type ListByServiceOperationOptions struct { - Filter *string - IsKeyVaultRefreshFailed *bool - Skip *int64 - Top *int64 -} - -func DefaultListByServiceOperationOptions() ListByServiceOperationOptions { - return ListByServiceOperationOptions{} -} - -func (o ListByServiceOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o ListByServiceOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Filter != nil { - out["$filter"] = *o.Filter - } - - if o.IsKeyVaultRefreshFailed != nil { - out["isKeyVaultRefreshFailed"] = *o.IsKeyVaultRefreshFailed - } - - if o.Skip != nil { - out["$skip"] = *o.Skip - } - - if o.Top != nil { - out["$top"] = *o.Top - } - - return out -} - -// ListByService ... -func (c NamedValueClient) ListByService(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (resp ListByServiceOperationResponse, err error) { - req, err := c.preparerForListByService(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "namedvalue.NamedValueClient", "ListByService", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "namedvalue.NamedValueClient", "ListByService", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListByService(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "namedvalue.NamedValueClient", "ListByService", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListByService prepares the ListByService request. -func (c NamedValueClient) preparerForListByService(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/namedValues", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListByServiceWithNextLink prepares the ListByService request with the given nextLink token. -func (c NamedValueClient) preparerForListByServiceWithNextLink(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)) -} - -// responderForListByService handles the response to the ListByService request. The method always -// closes the http.Response Body. -func (c NamedValueClient) responderForListByService(resp *http.Response) (result ListByServiceOperationResponse, err error) { - type page struct { - Values []NamedValueContract `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 ListByServiceOperationResponse, err error) { - req, err := c.preparerForListByServiceWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "namedvalue.NamedValueClient", "ListByService", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "namedvalue.NamedValueClient", "ListByService", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByService(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "namedvalue.NamedValueClient", "ListByService", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListByServiceComplete retrieves all of the results into a single object -func (c NamedValueClient) ListByServiceComplete(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (ListByServiceCompleteResult, error) { - return c.ListByServiceCompleteMatchingPredicate(ctx, id, options, NamedValueContractOperationPredicate{}) -} - -// ListByServiceCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c NamedValueClient) ListByServiceCompleteMatchingPredicate(ctx context.Context, id ServiceId, options ListByServiceOperationOptions, predicate NamedValueContractOperationPredicate) (resp ListByServiceCompleteResult, err error) { - items := make([]NamedValueContract, 0) - - page, err := c.ListByService(ctx, id, options) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListByServiceCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/apimanagement/2021-08-01/namedvalue/method_listvalue.go b/resource-manager/apimanagement/2021-08-01/namedvalue/method_listvalue.go new file mode 100644 index 00000000000..4dbf0997989 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/namedvalue/method_listvalue.go @@ -0,0 +1,52 @@ +package namedvalue + +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 ListValueOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *NamedValueSecretContract +} + +// ListValue ... +func (c NamedValueClient) ListValue(ctx context.Context, id NamedValueId) (result ListValueOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/listValue", 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/apimanagement/2021-08-01/namedvalue/method_listvalue_autorest.go b/resource-manager/apimanagement/2021-08-01/namedvalue/method_listvalue_autorest.go deleted file mode 100644 index 0370e762206..00000000000 --- a/resource-manager/apimanagement/2021-08-01/namedvalue/method_listvalue_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package namedvalue - -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 ListValueOperationResponse struct { - HttpResponse *http.Response - Model *NamedValueSecretContract -} - -// ListValue ... -func (c NamedValueClient) ListValue(ctx context.Context, id NamedValueId) (result ListValueOperationResponse, err error) { - req, err := c.preparerForListValue(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "namedvalue.NamedValueClient", "ListValue", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "namedvalue.NamedValueClient", "ListValue", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListValue(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "namedvalue.NamedValueClient", "ListValue", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForListValue prepares the ListValue request. -func (c NamedValueClient) preparerForListValue(ctx context.Context, id NamedValueId) (*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/listValue", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListValue handles the response to the ListValue request. The method always -// closes the http.Response Body. -func (c NamedValueClient) responderForListValue(resp *http.Response) (result ListValueOperationResponse, 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/apimanagement/2021-08-01/namedvalue/method_refreshsecret.go b/resource-manager/apimanagement/2021-08-01/namedvalue/method_refreshsecret.go new file mode 100644 index 00000000000..0dd3a006aec --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/namedvalue/method_refreshsecret.go @@ -0,0 +1,70 @@ +package namedvalue + +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 RefreshSecretOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// RefreshSecret ... +func (c NamedValueClient) RefreshSecret(ctx context.Context, id NamedValueId) (result RefreshSecretOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/refreshSecret", 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 +} + +// RefreshSecretThenPoll performs RefreshSecret then polls until it's completed +func (c NamedValueClient) RefreshSecretThenPoll(ctx context.Context, id NamedValueId) error { + result, err := c.RefreshSecret(ctx, id) + if err != nil { + return fmt.Errorf("performing RefreshSecret: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after RefreshSecret: %+v", err) + } + + return nil +} diff --git a/resource-manager/apimanagement/2021-08-01/namedvalue/method_refreshsecret_autorest.go b/resource-manager/apimanagement/2021-08-01/namedvalue/method_refreshsecret_autorest.go deleted file mode 100644 index 7574f5aaaf5..00000000000 --- a/resource-manager/apimanagement/2021-08-01/namedvalue/method_refreshsecret_autorest.go +++ /dev/null @@ -1,78 +0,0 @@ -package namedvalue - -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 RefreshSecretOperationResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// RefreshSecret ... -func (c NamedValueClient) RefreshSecret(ctx context.Context, id NamedValueId) (result RefreshSecretOperationResponse, err error) { - req, err := c.preparerForRefreshSecret(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "namedvalue.NamedValueClient", "RefreshSecret", nil, "Failure preparing request") - return - } - - result, err = c.senderForRefreshSecret(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "namedvalue.NamedValueClient", "RefreshSecret", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// RefreshSecretThenPoll performs RefreshSecret then polls until it's completed -func (c NamedValueClient) RefreshSecretThenPoll(ctx context.Context, id NamedValueId) error { - result, err := c.RefreshSecret(ctx, id) - if err != nil { - return fmt.Errorf("performing RefreshSecret: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after RefreshSecret: %+v", err) - } - - return nil -} - -// preparerForRefreshSecret prepares the RefreshSecret request. -func (c NamedValueClient) preparerForRefreshSecret(ctx context.Context, id NamedValueId) (*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/refreshSecret", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForRefreshSecret sends the RefreshSecret request. The method will close the -// http.Response Body if it receives an error. -func (c NamedValueClient) senderForRefreshSecret(ctx context.Context, req *http.Request) (future RefreshSecretOperationResponse, 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/apimanagement/2021-08-01/namedvalue/method_update.go b/resource-manager/apimanagement/2021-08-01/namedvalue/method_update.go new file mode 100644 index 00000000000..83793e803c7 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/namedvalue/method_update.go @@ -0,0 +1,102 @@ +package namedvalue + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +type UpdateOperationOptions struct { + IfMatch *string +} + +func DefaultUpdateOperationOptions() UpdateOperationOptions { + return UpdateOperationOptions{} +} + +func (o UpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o UpdateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o UpdateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// Update ... +func (c NamedValueClient) Update(ctx context.Context, id NamedValueId, input NamedValueUpdateParameters, options UpdateOperationOptions) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// UpdateThenPoll performs Update then polls until it's completed +func (c NamedValueClient) UpdateThenPoll(ctx context.Context, id NamedValueId, input NamedValueUpdateParameters, options UpdateOperationOptions) error { + result, err := c.Update(ctx, id, input, options) + if err != nil { + return fmt.Errorf("performing Update: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Update: %+v", err) + } + + return nil +} diff --git a/resource-manager/apimanagement/2021-08-01/namedvalue/method_update_autorest.go b/resource-manager/apimanagement/2021-08-01/namedvalue/method_update_autorest.go deleted file mode 100644 index 9de4e8a7883..00000000000 --- a/resource-manager/apimanagement/2021-08-01/namedvalue/method_update_autorest.go +++ /dev/null @@ -1,108 +0,0 @@ -package namedvalue - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type UpdateOperationResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -type UpdateOperationOptions struct { - IfMatch *string -} - -func DefaultUpdateOperationOptions() UpdateOperationOptions { - return UpdateOperationOptions{} -} - -func (o UpdateOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o UpdateOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// Update ... -func (c NamedValueClient) Update(ctx context.Context, id NamedValueId, input NamedValueUpdateParameters, options UpdateOperationOptions) (result UpdateOperationResponse, err error) { - req, err := c.preparerForUpdate(ctx, id, input, options) - if err != nil { - err = autorest.NewErrorWithError(err, "namedvalue.NamedValueClient", "Update", nil, "Failure preparing request") - return - } - - result, err = c.senderForUpdate(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "namedvalue.NamedValueClient", "Update", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// UpdateThenPoll performs Update then polls until it's completed -func (c NamedValueClient) UpdateThenPoll(ctx context.Context, id NamedValueId, input NamedValueUpdateParameters, options UpdateOperationOptions) error { - result, err := c.Update(ctx, id, input, options) - if err != nil { - return fmt.Errorf("performing Update: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after Update: %+v", err) - } - - return nil -} - -// preparerForUpdate prepares the Update request. -func (c NamedValueClient) preparerForUpdate(ctx context.Context, id NamedValueId, input NamedValueUpdateParameters, options UpdateOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPatch(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForUpdate sends the Update request. The method will close the -// http.Response Body if it receives an error. -func (c NamedValueClient) senderForUpdate(ctx context.Context, req *http.Request) (future UpdateOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/apimanagement/2021-08-01/networkstatus/client.go b/resource-manager/apimanagement/2021-08-01/networkstatus/client.go index 7d6f9215235..029c8296963 100644 --- a/resource-manager/apimanagement/2021-08-01/networkstatus/client.go +++ b/resource-manager/apimanagement/2021-08-01/networkstatus/client.go @@ -1,18 +1,26 @@ package networkstatus -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 NetworkStatusClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewNetworkStatusClientWithBaseURI(endpoint string) NetworkStatusClient { - return NetworkStatusClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewNetworkStatusClientWithBaseURI(api environments.Api) (*NetworkStatusClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "networkstatus", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating NetworkStatusClient: %+v", err) } + + return &NetworkStatusClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2021-08-01/networkstatus/constants.go b/resource-manager/apimanagement/2021-08-01/networkstatus/constants.go index fe5f4ceaf1c..caf05ed6a2c 100644 --- a/resource-manager/apimanagement/2021-08-01/networkstatus/constants.go +++ b/resource-manager/apimanagement/2021-08-01/networkstatus/constants.go @@ -1,6 +1,10 @@ package networkstatus -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 PossibleValuesForConnectivityStatusType() []string { } } +func (s *ConnectivityStatusType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseConnectivityStatusType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseConnectivityStatusType(input string) (*ConnectivityStatusType, error) { vals := map[string]ConnectivityStatusType{ "failure": ConnectivityStatusTypeFailure, diff --git a/resource-manager/apimanagement/2021-08-01/networkstatus/method_listbylocation.go b/resource-manager/apimanagement/2021-08-01/networkstatus/method_listbylocation.go new file mode 100644 index 00000000000..040ec0de64d --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/networkstatus/method_listbylocation.go @@ -0,0 +1,52 @@ +package networkstatus + +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 ListByLocationOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *NetworkStatusContract +} + +// ListByLocation ... +func (c NetworkStatusClient) ListByLocation(ctx context.Context, id LocationId) (result ListByLocationOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/networkstatus", 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/apimanagement/2021-08-01/networkstatus/method_listbylocation_autorest.go b/resource-manager/apimanagement/2021-08-01/networkstatus/method_listbylocation_autorest.go deleted file mode 100644 index bd98a6e965e..00000000000 --- a/resource-manager/apimanagement/2021-08-01/networkstatus/method_listbylocation_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package networkstatus - -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 ListByLocationOperationResponse struct { - HttpResponse *http.Response - Model *NetworkStatusContract -} - -// ListByLocation ... -func (c NetworkStatusClient) ListByLocation(ctx context.Context, id LocationId) (result ListByLocationOperationResponse, err error) { - req, err := c.preparerForListByLocation(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "networkstatus.NetworkStatusClient", "ListByLocation", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "networkstatus.NetworkStatusClient", "ListByLocation", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByLocation(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "networkstatus.NetworkStatusClient", "ListByLocation", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForListByLocation prepares the ListByLocation request. -func (c NetworkStatusClient) preparerForListByLocation(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/networkstatus", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListByLocation handles the response to the ListByLocation request. The method always -// closes the http.Response Body. -func (c NetworkStatusClient) responderForListByLocation(resp *http.Response) (result ListByLocationOperationResponse, 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/apimanagement/2021-08-01/networkstatus/method_listbyservice.go b/resource-manager/apimanagement/2021-08-01/networkstatus/method_listbyservice.go new file mode 100644 index 00000000000..509a1b2da91 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/networkstatus/method_listbyservice.go @@ -0,0 +1,52 @@ +package networkstatus + +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 ListByServiceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]NetworkStatusContractByLocation +} + +// ListByService ... +func (c NetworkStatusClient) ListByService(ctx context.Context, id ServiceId) (result ListByServiceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/networkstatus", 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/apimanagement/2021-08-01/networkstatus/method_listbyservice_autorest.go b/resource-manager/apimanagement/2021-08-01/networkstatus/method_listbyservice_autorest.go deleted file mode 100644 index e5f374af6e0..00000000000 --- a/resource-manager/apimanagement/2021-08-01/networkstatus/method_listbyservice_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package networkstatus - -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 ListByServiceOperationResponse struct { - HttpResponse *http.Response - Model *[]NetworkStatusContractByLocation -} - -// ListByService ... -func (c NetworkStatusClient) ListByService(ctx context.Context, id ServiceId) (result ListByServiceOperationResponse, err error) { - req, err := c.preparerForListByService(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "networkstatus.NetworkStatusClient", "ListByService", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "networkstatus.NetworkStatusClient", "ListByService", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByService(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "networkstatus.NetworkStatusClient", "ListByService", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForListByService prepares the ListByService request. -func (c NetworkStatusClient) preparerForListByService(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(fmt.Sprintf("%s/networkstatus", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListByService handles the response to the ListByService request. The method always -// closes the http.Response Body. -func (c NetworkStatusClient) responderForListByService(resp *http.Response) (result ListByServiceOperationResponse, 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/apimanagement/2021-08-01/notification/client.go b/resource-manager/apimanagement/2021-08-01/notification/client.go index 090f6db749d..3d20bbeb2ef 100644 --- a/resource-manager/apimanagement/2021-08-01/notification/client.go +++ b/resource-manager/apimanagement/2021-08-01/notification/client.go @@ -1,18 +1,26 @@ package notification -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 NotificationClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewNotificationClientWithBaseURI(endpoint string) NotificationClient { - return NotificationClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewNotificationClientWithBaseURI(api environments.Api) (*NotificationClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "notification", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating NotificationClient: %+v", err) } + + return &NotificationClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2021-08-01/notification/constants.go b/resource-manager/apimanagement/2021-08-01/notification/constants.go index e4c9332d3bd..28634a3bb8e 100644 --- a/resource-manager/apimanagement/2021-08-01/notification/constants.go +++ b/resource-manager/apimanagement/2021-08-01/notification/constants.go @@ -1,6 +1,10 @@ package notification -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. @@ -29,6 +33,19 @@ func PossibleValuesForNotificationName() []string { } } +func (s *NotificationName) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNotificationName(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseNotificationName(input string) (*NotificationName, error) { vals := map[string]NotificationName{ "accountclosedpublisher": NotificationNameAccountClosedPublisher, diff --git a/resource-manager/apimanagement/2021-08-01/notification/method_createorupdate.go b/resource-manager/apimanagement/2021-08-01/notification/method_createorupdate.go new file mode 100644 index 00000000000..f1f56dbe3ba --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/notification/method_createorupdate.go @@ -0,0 +1,80 @@ +package notification + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *NotificationContract +} + +type CreateOrUpdateOperationOptions struct { + IfMatch *string +} + +func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { + return CreateOrUpdateOperationOptions{} +} + +func (o CreateOrUpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o CreateOrUpdateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o CreateOrUpdateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// CreateOrUpdate ... +func (c NotificationClient) CreateOrUpdate(ctx context.Context, id NotificationId, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + OptionsObject: options, + } + + 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/apimanagement/2021-08-01/notification/method_createorupdate_autorest.go b/resource-manager/apimanagement/2021-08-01/notification/method_createorupdate_autorest.go deleted file mode 100644 index 129cedaaadd..00000000000 --- a/resource-manager/apimanagement/2021-08-01/notification/method_createorupdate_autorest.go +++ /dev/null @@ -1,97 +0,0 @@ -package notification - -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 *NotificationContract -} - -type CreateOrUpdateOperationOptions struct { - IfMatch *string -} - -func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { - return CreateOrUpdateOperationOptions{} -} - -func (o CreateOrUpdateOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o CreateOrUpdateOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// CreateOrUpdate ... -func (c NotificationClient) CreateOrUpdate(ctx context.Context, id NotificationId, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdate(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "notification.NotificationClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "notification.NotificationClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCreateOrUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "notification.NotificationClient", "CreateOrUpdate", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCreateOrUpdate prepares the CreateOrUpdate request. -func (c NotificationClient) preparerForCreateOrUpdate(ctx context.Context, id NotificationId, options CreateOrUpdateOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(id.ID()), - 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 NotificationClient) 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/apimanagement/2021-08-01/notification/method_get.go b/resource-manager/apimanagement/2021-08-01/notification/method_get.go new file mode 100644 index 00000000000..a5f0293b824 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/notification/method_get.go @@ -0,0 +1,51 @@ +package notification + +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 *NotificationContract +} + +// Get ... +func (c NotificationClient) Get(ctx context.Context, id NotificationId) (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/apimanagement/2021-08-01/notification/method_get_autorest.go b/resource-manager/apimanagement/2021-08-01/notification/method_get_autorest.go deleted file mode 100644 index 1290bcc6685..00000000000 --- a/resource-manager/apimanagement/2021-08-01/notification/method_get_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package notification - -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 *NotificationContract -} - -// Get ... -func (c NotificationClient) Get(ctx context.Context, id NotificationId) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "notification.NotificationClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "notification.NotificationClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "notification.NotificationClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c NotificationClient) preparerForGet(ctx context.Context, id NotificationId) (*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 NotificationClient) 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/apimanagement/2021-08-01/notification/method_listbyservice.go b/resource-manager/apimanagement/2021-08-01/notification/method_listbyservice.go new file mode 100644 index 00000000000..ec6e29b47c6 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/notification/method_listbyservice.go @@ -0,0 +1,121 @@ +package notification + +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 ListByServiceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]NotificationContract +} + +type ListByServiceCompleteResult struct { + Items []NotificationContract +} + +type ListByServiceOperationOptions struct { + Skip *int64 + Top *int64 +} + +func DefaultListByServiceOperationOptions() ListByServiceOperationOptions { + return ListByServiceOperationOptions{} +} + +func (o ListByServiceOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListByServiceOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListByServiceOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Skip != nil { + out.Append("$skip", fmt.Sprintf("%v", *o.Skip)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +// ListByService ... +func (c NotificationClient) ListByService(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (result ListByServiceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/notifications", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]NotificationContract `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByServiceComplete retrieves all the results into a single object +func (c NotificationClient) ListByServiceComplete(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (ListByServiceCompleteResult, error) { + return c.ListByServiceCompleteMatchingPredicate(ctx, id, options, NotificationContractOperationPredicate{}) +} + +// ListByServiceCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c NotificationClient) ListByServiceCompleteMatchingPredicate(ctx context.Context, id ServiceId, options ListByServiceOperationOptions, predicate NotificationContractOperationPredicate) (result ListByServiceCompleteResult, err error) { + items := make([]NotificationContract, 0) + + resp, err := c.ListByService(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByServiceCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/apimanagement/2021-08-01/notification/method_listbyservice_autorest.go b/resource-manager/apimanagement/2021-08-01/notification/method_listbyservice_autorest.go deleted file mode 100644 index d439d198b0c..00000000000 --- a/resource-manager/apimanagement/2021-08-01/notification/method_listbyservice_autorest.go +++ /dev/null @@ -1,220 +0,0 @@ -package notification - -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 ListByServiceOperationResponse struct { - HttpResponse *http.Response - Model *[]NotificationContract - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListByServiceOperationResponse, error) -} - -type ListByServiceCompleteResult struct { - Items []NotificationContract -} - -func (r ListByServiceOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListByServiceOperationResponse) LoadMore(ctx context.Context) (resp ListByServiceOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -type ListByServiceOperationOptions struct { - Skip *int64 - Top *int64 -} - -func DefaultListByServiceOperationOptions() ListByServiceOperationOptions { - return ListByServiceOperationOptions{} -} - -func (o ListByServiceOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o ListByServiceOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Skip != nil { - out["$skip"] = *o.Skip - } - - if o.Top != nil { - out["$top"] = *o.Top - } - - return out -} - -// ListByService ... -func (c NotificationClient) ListByService(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (resp ListByServiceOperationResponse, err error) { - req, err := c.preparerForListByService(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "notification.NotificationClient", "ListByService", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "notification.NotificationClient", "ListByService", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListByService(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "notification.NotificationClient", "ListByService", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListByService prepares the ListByService request. -func (c NotificationClient) preparerForListByService(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/notifications", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListByServiceWithNextLink prepares the ListByService request with the given nextLink token. -func (c NotificationClient) preparerForListByServiceWithNextLink(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)) -} - -// responderForListByService handles the response to the ListByService request. The method always -// closes the http.Response Body. -func (c NotificationClient) responderForListByService(resp *http.Response) (result ListByServiceOperationResponse, err error) { - type page struct { - Values []NotificationContract `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 ListByServiceOperationResponse, err error) { - req, err := c.preparerForListByServiceWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "notification.NotificationClient", "ListByService", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "notification.NotificationClient", "ListByService", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByService(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "notification.NotificationClient", "ListByService", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListByServiceComplete retrieves all of the results into a single object -func (c NotificationClient) ListByServiceComplete(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (ListByServiceCompleteResult, error) { - return c.ListByServiceCompleteMatchingPredicate(ctx, id, options, NotificationContractOperationPredicate{}) -} - -// ListByServiceCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c NotificationClient) ListByServiceCompleteMatchingPredicate(ctx context.Context, id ServiceId, options ListByServiceOperationOptions, predicate NotificationContractOperationPredicate) (resp ListByServiceCompleteResult, err error) { - items := make([]NotificationContract, 0) - - page, err := c.ListByService(ctx, id, options) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListByServiceCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/apimanagement/2021-08-01/notificationrecipientemail/client.go b/resource-manager/apimanagement/2021-08-01/notificationrecipientemail/client.go index 6f974759762..9479afea2f0 100644 --- a/resource-manager/apimanagement/2021-08-01/notificationrecipientemail/client.go +++ b/resource-manager/apimanagement/2021-08-01/notificationrecipientemail/client.go @@ -1,18 +1,26 @@ package notificationrecipientemail -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 NotificationRecipientEmailClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewNotificationRecipientEmailClientWithBaseURI(endpoint string) NotificationRecipientEmailClient { - return NotificationRecipientEmailClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewNotificationRecipientEmailClientWithBaseURI(api environments.Api) (*NotificationRecipientEmailClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "notificationrecipientemail", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating NotificationRecipientEmailClient: %+v", err) } + + return &NotificationRecipientEmailClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2021-08-01/notificationrecipientemail/constants.go b/resource-manager/apimanagement/2021-08-01/notificationrecipientemail/constants.go index e48b9eee0a2..85940aee54e 100644 --- a/resource-manager/apimanagement/2021-08-01/notificationrecipientemail/constants.go +++ b/resource-manager/apimanagement/2021-08-01/notificationrecipientemail/constants.go @@ -1,6 +1,10 @@ package notificationrecipientemail -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. @@ -29,6 +33,19 @@ func PossibleValuesForNotificationName() []string { } } +func (s *NotificationName) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNotificationName(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseNotificationName(input string) (*NotificationName, error) { vals := map[string]NotificationName{ "accountclosedpublisher": NotificationNameAccountClosedPublisher, diff --git a/resource-manager/apimanagement/2021-08-01/notificationrecipientemail/method_checkentityexists.go b/resource-manager/apimanagement/2021-08-01/notificationrecipientemail/method_checkentityexists.go new file mode 100644 index 00000000000..acddee29b82 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/notificationrecipientemail/method_checkentityexists.go @@ -0,0 +1,46 @@ +package notificationrecipientemail + +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 CheckEntityExistsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// CheckEntityExists ... +func (c NotificationRecipientEmailClient) CheckEntityExists(ctx context.Context, id RecipientEmailId) (result CheckEntityExistsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: http.MethodHead, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2021-08-01/notificationrecipientemail/method_checkentityexists_autorest.go b/resource-manager/apimanagement/2021-08-01/notificationrecipientemail/method_checkentityexists_autorest.go deleted file mode 100644 index da1fef7c04b..00000000000 --- a/resource-manager/apimanagement/2021-08-01/notificationrecipientemail/method_checkentityexists_autorest.go +++ /dev/null @@ -1,66 +0,0 @@ -package notificationrecipientemail - -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 CheckEntityExistsOperationResponse struct { - HttpResponse *http.Response -} - -// CheckEntityExists ... -func (c NotificationRecipientEmailClient) CheckEntityExists(ctx context.Context, id RecipientEmailId) (result CheckEntityExistsOperationResponse, err error) { - req, err := c.preparerForCheckEntityExists(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "notificationrecipientemail.NotificationRecipientEmailClient", "CheckEntityExists", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "notificationrecipientemail.NotificationRecipientEmailClient", "CheckEntityExists", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCheckEntityExists(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "notificationrecipientemail.NotificationRecipientEmailClient", "CheckEntityExists", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCheckEntityExists prepares the CheckEntityExists request. -func (c NotificationRecipientEmailClient) preparerForCheckEntityExists(ctx context.Context, id RecipientEmailId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsHead(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForCheckEntityExists handles the response to the CheckEntityExists request. The method always -// closes the http.Response Body. -func (c NotificationRecipientEmailClient) responderForCheckEntityExists(resp *http.Response) (result CheckEntityExistsOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2021-08-01/notificationrecipientemail/method_createorupdate.go b/resource-manager/apimanagement/2021-08-01/notificationrecipientemail/method_createorupdate.go new file mode 100644 index 00000000000..076065b12a4 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/notificationrecipientemail/method_createorupdate.go @@ -0,0 +1,52 @@ +package notificationrecipientemail + +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 *RecipientEmailContract +} + +// CreateOrUpdate ... +func (c NotificationRecipientEmailClient) CreateOrUpdate(ctx context.Context, id RecipientEmailId) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + 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/apimanagement/2021-08-01/notificationrecipientemail/method_createorupdate_autorest.go b/resource-manager/apimanagement/2021-08-01/notificationrecipientemail/method_createorupdate_autorest.go deleted file mode 100644 index 54e5266a7f4..00000000000 --- a/resource-manager/apimanagement/2021-08-01/notificationrecipientemail/method_createorupdate_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package notificationrecipientemail - -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 *RecipientEmailContract -} - -// CreateOrUpdate ... -func (c NotificationRecipientEmailClient) CreateOrUpdate(ctx context.Context, id RecipientEmailId) (result CreateOrUpdateOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdate(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "notificationrecipientemail.NotificationRecipientEmailClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "notificationrecipientemail.NotificationRecipientEmailClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCreateOrUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "notificationrecipientemail.NotificationRecipientEmailClient", "CreateOrUpdate", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCreateOrUpdate prepares the CreateOrUpdate request. -func (c NotificationRecipientEmailClient) preparerForCreateOrUpdate(ctx context.Context, id RecipientEmailId) (*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.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 NotificationRecipientEmailClient) responderForCreateOrUpdate(resp *http.Response) (result CreateOrUpdateOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2021-08-01/notificationrecipientemail/method_delete.go b/resource-manager/apimanagement/2021-08-01/notificationrecipientemail/method_delete.go new file mode 100644 index 00000000000..083dbc0417f --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/notificationrecipientemail/method_delete.go @@ -0,0 +1,47 @@ +package notificationrecipientemail + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c NotificationRecipientEmailClient) Delete(ctx context.Context, id RecipientEmailId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2021-08-01/notificationrecipientemail/method_delete_autorest.go b/resource-manager/apimanagement/2021-08-01/notificationrecipientemail/method_delete_autorest.go deleted file mode 100644 index c38e5d32b20..00000000000 --- a/resource-manager/apimanagement/2021-08-01/notificationrecipientemail/method_delete_autorest.go +++ /dev/null @@ -1,66 +0,0 @@ -package notificationrecipientemail - -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 DeleteOperationResponse struct { - HttpResponse *http.Response -} - -// Delete ... -func (c NotificationRecipientEmailClient) Delete(ctx context.Context, id RecipientEmailId) (result DeleteOperationResponse, err error) { - req, err := c.preparerForDelete(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "notificationrecipientemail.NotificationRecipientEmailClient", "Delete", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "notificationrecipientemail.NotificationRecipientEmailClient", "Delete", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForDelete(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "notificationrecipientemail.NotificationRecipientEmailClient", "Delete", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForDelete prepares the Delete request. -func (c NotificationRecipientEmailClient) preparerForDelete(ctx context.Context, id RecipientEmailId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForDelete handles the response to the Delete request. The method always -// closes the http.Response Body. -func (c NotificationRecipientEmailClient) responderForDelete(resp *http.Response) (result DeleteOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2021-08-01/notificationrecipientemail/method_listbynotification.go b/resource-manager/apimanagement/2021-08-01/notificationrecipientemail/method_listbynotification.go new file mode 100644 index 00000000000..091cf193ce9 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/notificationrecipientemail/method_listbynotification.go @@ -0,0 +1,52 @@ +package notificationrecipientemail + +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 ListByNotificationOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *RecipientEmailCollection +} + +// ListByNotification ... +func (c NotificationRecipientEmailClient) ListByNotification(ctx context.Context, id NotificationId) (result ListByNotificationOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/recipientEmails", 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/apimanagement/2021-08-01/notificationrecipientemail/method_listbynotification_autorest.go b/resource-manager/apimanagement/2021-08-01/notificationrecipientemail/method_listbynotification_autorest.go deleted file mode 100644 index c694b327a26..00000000000 --- a/resource-manager/apimanagement/2021-08-01/notificationrecipientemail/method_listbynotification_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package notificationrecipientemail - -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 ListByNotificationOperationResponse struct { - HttpResponse *http.Response - Model *RecipientEmailCollection -} - -// ListByNotification ... -func (c NotificationRecipientEmailClient) ListByNotification(ctx context.Context, id NotificationId) (result ListByNotificationOperationResponse, err error) { - req, err := c.preparerForListByNotification(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "notificationrecipientemail.NotificationRecipientEmailClient", "ListByNotification", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "notificationrecipientemail.NotificationRecipientEmailClient", "ListByNotification", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByNotification(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "notificationrecipientemail.NotificationRecipientEmailClient", "ListByNotification", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForListByNotification prepares the ListByNotification request. -func (c NotificationRecipientEmailClient) preparerForListByNotification(ctx context.Context, id NotificationId) (*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/recipientEmails", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListByNotification handles the response to the ListByNotification request. The method always -// closes the http.Response Body. -func (c NotificationRecipientEmailClient) responderForListByNotification(resp *http.Response) (result ListByNotificationOperationResponse, 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/apimanagement/2021-08-01/notificationrecipientuser/client.go b/resource-manager/apimanagement/2021-08-01/notificationrecipientuser/client.go index ee1917a9307..8d6c753120f 100644 --- a/resource-manager/apimanagement/2021-08-01/notificationrecipientuser/client.go +++ b/resource-manager/apimanagement/2021-08-01/notificationrecipientuser/client.go @@ -1,18 +1,26 @@ package notificationrecipientuser -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 NotificationRecipientUserClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewNotificationRecipientUserClientWithBaseURI(endpoint string) NotificationRecipientUserClient { - return NotificationRecipientUserClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewNotificationRecipientUserClientWithBaseURI(api environments.Api) (*NotificationRecipientUserClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "notificationrecipientuser", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating NotificationRecipientUserClient: %+v", err) } + + return &NotificationRecipientUserClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2021-08-01/notificationrecipientuser/constants.go b/resource-manager/apimanagement/2021-08-01/notificationrecipientuser/constants.go index 32178bd55a0..879dbf85c44 100644 --- a/resource-manager/apimanagement/2021-08-01/notificationrecipientuser/constants.go +++ b/resource-manager/apimanagement/2021-08-01/notificationrecipientuser/constants.go @@ -1,6 +1,10 @@ package notificationrecipientuser -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. @@ -29,6 +33,19 @@ func PossibleValuesForNotificationName() []string { } } +func (s *NotificationName) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNotificationName(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseNotificationName(input string) (*NotificationName, error) { vals := map[string]NotificationName{ "accountclosedpublisher": NotificationNameAccountClosedPublisher, diff --git a/resource-manager/apimanagement/2021-08-01/notificationrecipientuser/method_checkentityexists.go b/resource-manager/apimanagement/2021-08-01/notificationrecipientuser/method_checkentityexists.go new file mode 100644 index 00000000000..baae87b86d1 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/notificationrecipientuser/method_checkentityexists.go @@ -0,0 +1,46 @@ +package notificationrecipientuser + +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 CheckEntityExistsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// CheckEntityExists ... +func (c NotificationRecipientUserClient) CheckEntityExists(ctx context.Context, id RecipientUserId) (result CheckEntityExistsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: http.MethodHead, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2021-08-01/notificationrecipientuser/method_checkentityexists_autorest.go b/resource-manager/apimanagement/2021-08-01/notificationrecipientuser/method_checkentityexists_autorest.go deleted file mode 100644 index ddfad8eeecb..00000000000 --- a/resource-manager/apimanagement/2021-08-01/notificationrecipientuser/method_checkentityexists_autorest.go +++ /dev/null @@ -1,66 +0,0 @@ -package notificationrecipientuser - -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 CheckEntityExistsOperationResponse struct { - HttpResponse *http.Response -} - -// CheckEntityExists ... -func (c NotificationRecipientUserClient) CheckEntityExists(ctx context.Context, id RecipientUserId) (result CheckEntityExistsOperationResponse, err error) { - req, err := c.preparerForCheckEntityExists(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "notificationrecipientuser.NotificationRecipientUserClient", "CheckEntityExists", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "notificationrecipientuser.NotificationRecipientUserClient", "CheckEntityExists", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCheckEntityExists(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "notificationrecipientuser.NotificationRecipientUserClient", "CheckEntityExists", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCheckEntityExists prepares the CheckEntityExists request. -func (c NotificationRecipientUserClient) preparerForCheckEntityExists(ctx context.Context, id RecipientUserId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsHead(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForCheckEntityExists handles the response to the CheckEntityExists request. The method always -// closes the http.Response Body. -func (c NotificationRecipientUserClient) responderForCheckEntityExists(resp *http.Response) (result CheckEntityExistsOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2021-08-01/notificationrecipientuser/method_createorupdate.go b/resource-manager/apimanagement/2021-08-01/notificationrecipientuser/method_createorupdate.go new file mode 100644 index 00000000000..a9b12b60ca8 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/notificationrecipientuser/method_createorupdate.go @@ -0,0 +1,52 @@ +package notificationrecipientuser + +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 *RecipientUserContract +} + +// CreateOrUpdate ... +func (c NotificationRecipientUserClient) CreateOrUpdate(ctx context.Context, id RecipientUserId) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + 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/apimanagement/2021-08-01/notificationrecipientuser/method_createorupdate_autorest.go b/resource-manager/apimanagement/2021-08-01/notificationrecipientuser/method_createorupdate_autorest.go deleted file mode 100644 index 3c013a3fa62..00000000000 --- a/resource-manager/apimanagement/2021-08-01/notificationrecipientuser/method_createorupdate_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package notificationrecipientuser - -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 *RecipientUserContract -} - -// CreateOrUpdate ... -func (c NotificationRecipientUserClient) CreateOrUpdate(ctx context.Context, id RecipientUserId) (result CreateOrUpdateOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdate(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "notificationrecipientuser.NotificationRecipientUserClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "notificationrecipientuser.NotificationRecipientUserClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCreateOrUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "notificationrecipientuser.NotificationRecipientUserClient", "CreateOrUpdate", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCreateOrUpdate prepares the CreateOrUpdate request. -func (c NotificationRecipientUserClient) preparerForCreateOrUpdate(ctx context.Context, id RecipientUserId) (*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.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 NotificationRecipientUserClient) responderForCreateOrUpdate(resp *http.Response) (result CreateOrUpdateOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2021-08-01/notificationrecipientuser/method_delete.go b/resource-manager/apimanagement/2021-08-01/notificationrecipientuser/method_delete.go new file mode 100644 index 00000000000..d0bf672da2e --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/notificationrecipientuser/method_delete.go @@ -0,0 +1,47 @@ +package notificationrecipientuser + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c NotificationRecipientUserClient) Delete(ctx context.Context, id RecipientUserId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2021-08-01/notificationrecipientuser/method_delete_autorest.go b/resource-manager/apimanagement/2021-08-01/notificationrecipientuser/method_delete_autorest.go deleted file mode 100644 index 808cdd48ac5..00000000000 --- a/resource-manager/apimanagement/2021-08-01/notificationrecipientuser/method_delete_autorest.go +++ /dev/null @@ -1,66 +0,0 @@ -package notificationrecipientuser - -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 DeleteOperationResponse struct { - HttpResponse *http.Response -} - -// Delete ... -func (c NotificationRecipientUserClient) Delete(ctx context.Context, id RecipientUserId) (result DeleteOperationResponse, err error) { - req, err := c.preparerForDelete(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "notificationrecipientuser.NotificationRecipientUserClient", "Delete", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "notificationrecipientuser.NotificationRecipientUserClient", "Delete", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForDelete(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "notificationrecipientuser.NotificationRecipientUserClient", "Delete", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForDelete prepares the Delete request. -func (c NotificationRecipientUserClient) preparerForDelete(ctx context.Context, id RecipientUserId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForDelete handles the response to the Delete request. The method always -// closes the http.Response Body. -func (c NotificationRecipientUserClient) responderForDelete(resp *http.Response) (result DeleteOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2021-08-01/notificationrecipientuser/method_listbynotification.go b/resource-manager/apimanagement/2021-08-01/notificationrecipientuser/method_listbynotification.go new file mode 100644 index 00000000000..bfe4badf1f5 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/notificationrecipientuser/method_listbynotification.go @@ -0,0 +1,52 @@ +package notificationrecipientuser + +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 ListByNotificationOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *RecipientUserCollection +} + +// ListByNotification ... +func (c NotificationRecipientUserClient) ListByNotification(ctx context.Context, id NotificationId) (result ListByNotificationOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/recipientUsers", 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/apimanagement/2021-08-01/notificationrecipientuser/method_listbynotification_autorest.go b/resource-manager/apimanagement/2021-08-01/notificationrecipientuser/method_listbynotification_autorest.go deleted file mode 100644 index adefe67aec1..00000000000 --- a/resource-manager/apimanagement/2021-08-01/notificationrecipientuser/method_listbynotification_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package notificationrecipientuser - -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 ListByNotificationOperationResponse struct { - HttpResponse *http.Response - Model *RecipientUserCollection -} - -// ListByNotification ... -func (c NotificationRecipientUserClient) ListByNotification(ctx context.Context, id NotificationId) (result ListByNotificationOperationResponse, err error) { - req, err := c.preparerForListByNotification(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "notificationrecipientuser.NotificationRecipientUserClient", "ListByNotification", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "notificationrecipientuser.NotificationRecipientUserClient", "ListByNotification", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByNotification(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "notificationrecipientuser.NotificationRecipientUserClient", "ListByNotification", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForListByNotification prepares the ListByNotification request. -func (c NotificationRecipientUserClient) preparerForListByNotification(ctx context.Context, id NotificationId) (*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/recipientUsers", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListByNotification handles the response to the ListByNotification request. The method always -// closes the http.Response Body. -func (c NotificationRecipientUserClient) responderForListByNotification(resp *http.Response) (result ListByNotificationOperationResponse, 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/apimanagement/2021-08-01/openidconnectprovider/client.go b/resource-manager/apimanagement/2021-08-01/openidconnectprovider/client.go index 6e9956e13eb..f8cd6dda463 100644 --- a/resource-manager/apimanagement/2021-08-01/openidconnectprovider/client.go +++ b/resource-manager/apimanagement/2021-08-01/openidconnectprovider/client.go @@ -1,18 +1,26 @@ package openidconnectprovider -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 OpenidConnectProviderClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewOpenidConnectProviderClientWithBaseURI(endpoint string) OpenidConnectProviderClient { - return OpenidConnectProviderClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewOpenidConnectProviderClientWithBaseURI(api environments.Api) (*OpenidConnectProviderClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "openidconnectprovider", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating OpenidConnectProviderClient: %+v", err) } + + return &OpenidConnectProviderClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2021-08-01/openidconnectprovider/method_createorupdate.go b/resource-manager/apimanagement/2021-08-01/openidconnectprovider/method_createorupdate.go new file mode 100644 index 00000000000..022112dd8ee --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/openidconnectprovider/method_createorupdate.go @@ -0,0 +1,85 @@ +package openidconnectprovider + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *OpenidConnectProviderContract +} + +type CreateOrUpdateOperationOptions struct { + IfMatch *string +} + +func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { + return CreateOrUpdateOperationOptions{} +} + +func (o CreateOrUpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o CreateOrUpdateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o CreateOrUpdateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// CreateOrUpdate ... +func (c OpenidConnectProviderClient) CreateOrUpdate(ctx context.Context, id OpenidConnectProviderId, input OpenidConnectProviderContract, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + OptionsObject: options, + } + + 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/apimanagement/2021-08-01/openidconnectprovider/method_createorupdate_autorest.go b/resource-manager/apimanagement/2021-08-01/openidconnectprovider/method_createorupdate_autorest.go deleted file mode 100644 index 4dc253d0cac..00000000000 --- a/resource-manager/apimanagement/2021-08-01/openidconnectprovider/method_createorupdate_autorest.go +++ /dev/null @@ -1,98 +0,0 @@ -package openidconnectprovider - -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 *OpenidConnectProviderContract -} - -type CreateOrUpdateOperationOptions struct { - IfMatch *string -} - -func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { - return CreateOrUpdateOperationOptions{} -} - -func (o CreateOrUpdateOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o CreateOrUpdateOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// CreateOrUpdate ... -func (c OpenidConnectProviderClient) CreateOrUpdate(ctx context.Context, id OpenidConnectProviderId, input OpenidConnectProviderContract, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdate(ctx, id, input, options) - if err != nil { - err = autorest.NewErrorWithError(err, "openidconnectprovider.OpenidConnectProviderClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "openidconnectprovider.OpenidConnectProviderClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCreateOrUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "openidconnectprovider.OpenidConnectProviderClient", "CreateOrUpdate", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCreateOrUpdate prepares the CreateOrUpdate request. -func (c OpenidConnectProviderClient) preparerForCreateOrUpdate(ctx context.Context, id OpenidConnectProviderId, input OpenidConnectProviderContract, options CreateOrUpdateOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - 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 OpenidConnectProviderClient) responderForCreateOrUpdate(resp *http.Response) (result CreateOrUpdateOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2021-08-01/openidconnectprovider/method_delete.go b/resource-manager/apimanagement/2021-08-01/openidconnectprovider/method_delete.go new file mode 100644 index 00000000000..dd6f6bbf9c4 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/openidconnectprovider/method_delete.go @@ -0,0 +1,76 @@ +package openidconnectprovider + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +type DeleteOperationOptions struct { + IfMatch *string +} + +func DefaultDeleteOperationOptions() DeleteOperationOptions { + return DeleteOperationOptions{} +} + +func (o DeleteOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o DeleteOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o DeleteOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// Delete ... +func (c OpenidConnectProviderClient) Delete(ctx context.Context, id OpenidConnectProviderId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2021-08-01/openidconnectprovider/method_delete_autorest.go b/resource-manager/apimanagement/2021-08-01/openidconnectprovider/method_delete_autorest.go deleted file mode 100644 index e8d831f0dbf..00000000000 --- a/resource-manager/apimanagement/2021-08-01/openidconnectprovider/method_delete_autorest.go +++ /dev/null @@ -1,95 +0,0 @@ -package openidconnectprovider - -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 DeleteOperationResponse struct { - HttpResponse *http.Response -} - -type DeleteOperationOptions struct { - IfMatch *string -} - -func DefaultDeleteOperationOptions() DeleteOperationOptions { - return DeleteOperationOptions{} -} - -func (o DeleteOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o DeleteOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// Delete ... -func (c OpenidConnectProviderClient) Delete(ctx context.Context, id OpenidConnectProviderId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { - req, err := c.preparerForDelete(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "openidconnectprovider.OpenidConnectProviderClient", "Delete", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "openidconnectprovider.OpenidConnectProviderClient", "Delete", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForDelete(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "openidconnectprovider.OpenidConnectProviderClient", "Delete", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForDelete prepares the Delete request. -func (c OpenidConnectProviderClient) preparerForDelete(ctx context.Context, id OpenidConnectProviderId, options DeleteOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForDelete handles the response to the Delete request. The method always -// closes the http.Response Body. -func (c OpenidConnectProviderClient) responderForDelete(resp *http.Response) (result DeleteOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2021-08-01/openidconnectprovider/method_get.go b/resource-manager/apimanagement/2021-08-01/openidconnectprovider/method_get.go new file mode 100644 index 00000000000..25939c8a1ce --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/openidconnectprovider/method_get.go @@ -0,0 +1,51 @@ +package openidconnectprovider + +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 *OpenidConnectProviderContract +} + +// Get ... +func (c OpenidConnectProviderClient) Get(ctx context.Context, id OpenidConnectProviderId) (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/apimanagement/2021-08-01/openidconnectprovider/method_get_autorest.go b/resource-manager/apimanagement/2021-08-01/openidconnectprovider/method_get_autorest.go deleted file mode 100644 index b7d07f681e5..00000000000 --- a/resource-manager/apimanagement/2021-08-01/openidconnectprovider/method_get_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package openidconnectprovider - -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 *OpenidConnectProviderContract -} - -// Get ... -func (c OpenidConnectProviderClient) Get(ctx context.Context, id OpenidConnectProviderId) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "openidconnectprovider.OpenidConnectProviderClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "openidconnectprovider.OpenidConnectProviderClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "openidconnectprovider.OpenidConnectProviderClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c OpenidConnectProviderClient) preparerForGet(ctx context.Context, id OpenidConnectProviderId) (*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 OpenidConnectProviderClient) 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/apimanagement/2021-08-01/openidconnectprovider/method_getentitytag.go b/resource-manager/apimanagement/2021-08-01/openidconnectprovider/method_getentitytag.go new file mode 100644 index 00000000000..3f411d67cae --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/openidconnectprovider/method_getentitytag.go @@ -0,0 +1,46 @@ +package openidconnectprovider + +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 GetEntityTagOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// GetEntityTag ... +func (c OpenidConnectProviderClient) GetEntityTag(ctx context.Context, id OpenidConnectProviderId) (result GetEntityTagOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodHead, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2021-08-01/openidconnectprovider/method_getentitytag_autorest.go b/resource-manager/apimanagement/2021-08-01/openidconnectprovider/method_getentitytag_autorest.go deleted file mode 100644 index 02fdba1af30..00000000000 --- a/resource-manager/apimanagement/2021-08-01/openidconnectprovider/method_getentitytag_autorest.go +++ /dev/null @@ -1,66 +0,0 @@ -package openidconnectprovider - -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 GetEntityTagOperationResponse struct { - HttpResponse *http.Response -} - -// GetEntityTag ... -func (c OpenidConnectProviderClient) GetEntityTag(ctx context.Context, id OpenidConnectProviderId) (result GetEntityTagOperationResponse, err error) { - req, err := c.preparerForGetEntityTag(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "openidconnectprovider.OpenidConnectProviderClient", "GetEntityTag", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "openidconnectprovider.OpenidConnectProviderClient", "GetEntityTag", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetEntityTag(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "openidconnectprovider.OpenidConnectProviderClient", "GetEntityTag", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetEntityTag prepares the GetEntityTag request. -func (c OpenidConnectProviderClient) preparerForGetEntityTag(ctx context.Context, id OpenidConnectProviderId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsHead(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetEntityTag handles the response to the GetEntityTag request. The method always -// closes the http.Response Body. -func (c OpenidConnectProviderClient) responderForGetEntityTag(resp *http.Response) (result GetEntityTagOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2021-08-01/openidconnectprovider/method_listbyservice.go b/resource-manager/apimanagement/2021-08-01/openidconnectprovider/method_listbyservice.go new file mode 100644 index 00000000000..42ba42327c5 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/openidconnectprovider/method_listbyservice.go @@ -0,0 +1,125 @@ +package openidconnectprovider + +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 ListByServiceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]OpenidConnectProviderContract +} + +type ListByServiceCompleteResult struct { + Items []OpenidConnectProviderContract +} + +type ListByServiceOperationOptions struct { + Filter *string + Skip *int64 + Top *int64 +} + +func DefaultListByServiceOperationOptions() ListByServiceOperationOptions { + return ListByServiceOperationOptions{} +} + +func (o ListByServiceOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListByServiceOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListByServiceOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.Skip != nil { + out.Append("$skip", fmt.Sprintf("%v", *o.Skip)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +// ListByService ... +func (c OpenidConnectProviderClient) ListByService(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (result ListByServiceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/openidConnectProviders", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]OpenidConnectProviderContract `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByServiceComplete retrieves all the results into a single object +func (c OpenidConnectProviderClient) ListByServiceComplete(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (ListByServiceCompleteResult, error) { + return c.ListByServiceCompleteMatchingPredicate(ctx, id, options, OpenidConnectProviderContractOperationPredicate{}) +} + +// ListByServiceCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c OpenidConnectProviderClient) ListByServiceCompleteMatchingPredicate(ctx context.Context, id ServiceId, options ListByServiceOperationOptions, predicate OpenidConnectProviderContractOperationPredicate) (result ListByServiceCompleteResult, err error) { + items := make([]OpenidConnectProviderContract, 0) + + resp, err := c.ListByService(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByServiceCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/apimanagement/2021-08-01/openidconnectprovider/method_listbyservice_autorest.go b/resource-manager/apimanagement/2021-08-01/openidconnectprovider/method_listbyservice_autorest.go deleted file mode 100644 index e84f3a32000..00000000000 --- a/resource-manager/apimanagement/2021-08-01/openidconnectprovider/method_listbyservice_autorest.go +++ /dev/null @@ -1,225 +0,0 @@ -package openidconnectprovider - -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 ListByServiceOperationResponse struct { - HttpResponse *http.Response - Model *[]OpenidConnectProviderContract - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListByServiceOperationResponse, error) -} - -type ListByServiceCompleteResult struct { - Items []OpenidConnectProviderContract -} - -func (r ListByServiceOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListByServiceOperationResponse) LoadMore(ctx context.Context) (resp ListByServiceOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -type ListByServiceOperationOptions struct { - Filter *string - Skip *int64 - Top *int64 -} - -func DefaultListByServiceOperationOptions() ListByServiceOperationOptions { - return ListByServiceOperationOptions{} -} - -func (o ListByServiceOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o ListByServiceOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Filter != nil { - out["$filter"] = *o.Filter - } - - if o.Skip != nil { - out["$skip"] = *o.Skip - } - - if o.Top != nil { - out["$top"] = *o.Top - } - - return out -} - -// ListByService ... -func (c OpenidConnectProviderClient) ListByService(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (resp ListByServiceOperationResponse, err error) { - req, err := c.preparerForListByService(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "openidconnectprovider.OpenidConnectProviderClient", "ListByService", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "openidconnectprovider.OpenidConnectProviderClient", "ListByService", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListByService(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "openidconnectprovider.OpenidConnectProviderClient", "ListByService", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListByService prepares the ListByService request. -func (c OpenidConnectProviderClient) preparerForListByService(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/openidConnectProviders", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListByServiceWithNextLink prepares the ListByService request with the given nextLink token. -func (c OpenidConnectProviderClient) preparerForListByServiceWithNextLink(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)) -} - -// responderForListByService handles the response to the ListByService request. The method always -// closes the http.Response Body. -func (c OpenidConnectProviderClient) responderForListByService(resp *http.Response) (result ListByServiceOperationResponse, err error) { - type page struct { - Values []OpenidConnectProviderContract `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 ListByServiceOperationResponse, err error) { - req, err := c.preparerForListByServiceWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "openidconnectprovider.OpenidConnectProviderClient", "ListByService", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "openidconnectprovider.OpenidConnectProviderClient", "ListByService", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByService(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "openidconnectprovider.OpenidConnectProviderClient", "ListByService", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListByServiceComplete retrieves all of the results into a single object -func (c OpenidConnectProviderClient) ListByServiceComplete(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (ListByServiceCompleteResult, error) { - return c.ListByServiceCompleteMatchingPredicate(ctx, id, options, OpenidConnectProviderContractOperationPredicate{}) -} - -// ListByServiceCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c OpenidConnectProviderClient) ListByServiceCompleteMatchingPredicate(ctx context.Context, id ServiceId, options ListByServiceOperationOptions, predicate OpenidConnectProviderContractOperationPredicate) (resp ListByServiceCompleteResult, err error) { - items := make([]OpenidConnectProviderContract, 0) - - page, err := c.ListByService(ctx, id, options) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListByServiceCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/apimanagement/2021-08-01/openidconnectprovider/method_listsecrets.go b/resource-manager/apimanagement/2021-08-01/openidconnectprovider/method_listsecrets.go new file mode 100644 index 00000000000..d05b3d3c365 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/openidconnectprovider/method_listsecrets.go @@ -0,0 +1,52 @@ +package openidconnectprovider + +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 ListSecretsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ClientSecretContract +} + +// ListSecrets ... +func (c OpenidConnectProviderClient) ListSecrets(ctx context.Context, id OpenidConnectProviderId) (result ListSecretsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/listSecrets", 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/apimanagement/2021-08-01/openidconnectprovider/method_listsecrets_autorest.go b/resource-manager/apimanagement/2021-08-01/openidconnectprovider/method_listsecrets_autorest.go deleted file mode 100644 index df2556cf4f3..00000000000 --- a/resource-manager/apimanagement/2021-08-01/openidconnectprovider/method_listsecrets_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package openidconnectprovider - -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 ListSecretsOperationResponse struct { - HttpResponse *http.Response - Model *ClientSecretContract -} - -// ListSecrets ... -func (c OpenidConnectProviderClient) ListSecrets(ctx context.Context, id OpenidConnectProviderId) (result ListSecretsOperationResponse, err error) { - req, err := c.preparerForListSecrets(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "openidconnectprovider.OpenidConnectProviderClient", "ListSecrets", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "openidconnectprovider.OpenidConnectProviderClient", "ListSecrets", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListSecrets(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "openidconnectprovider.OpenidConnectProviderClient", "ListSecrets", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForListSecrets prepares the ListSecrets request. -func (c OpenidConnectProviderClient) preparerForListSecrets(ctx context.Context, id OpenidConnectProviderId) (*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/listSecrets", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListSecrets handles the response to the ListSecrets request. The method always -// closes the http.Response Body. -func (c OpenidConnectProviderClient) responderForListSecrets(resp *http.Response) (result ListSecretsOperationResponse, 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/apimanagement/2021-08-01/openidconnectprovider/method_update.go b/resource-manager/apimanagement/2021-08-01/openidconnectprovider/method_update.go new file mode 100644 index 00000000000..5b2402019c0 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/openidconnectprovider/method_update.go @@ -0,0 +1,84 @@ +package openidconnectprovider + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *OpenidConnectProviderContract +} + +type UpdateOperationOptions struct { + IfMatch *string +} + +func DefaultUpdateOperationOptions() UpdateOperationOptions { + return UpdateOperationOptions{} +} + +func (o UpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o UpdateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o UpdateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// Update ... +func (c OpenidConnectProviderClient) Update(ctx context.Context, id OpenidConnectProviderId, input OpenidConnectProviderUpdateContract, options UpdateOperationOptions) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + OptionsObject: options, + } + + 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/apimanagement/2021-08-01/openidconnectprovider/method_update_autorest.go b/resource-manager/apimanagement/2021-08-01/openidconnectprovider/method_update_autorest.go deleted file mode 100644 index 5f1845c884d..00000000000 --- a/resource-manager/apimanagement/2021-08-01/openidconnectprovider/method_update_autorest.go +++ /dev/null @@ -1,98 +0,0 @@ -package openidconnectprovider - -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 *OpenidConnectProviderContract -} - -type UpdateOperationOptions struct { - IfMatch *string -} - -func DefaultUpdateOperationOptions() UpdateOperationOptions { - return UpdateOperationOptions{} -} - -func (o UpdateOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o UpdateOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// Update ... -func (c OpenidConnectProviderClient) Update(ctx context.Context, id OpenidConnectProviderId, input OpenidConnectProviderUpdateContract, options UpdateOperationOptions) (result UpdateOperationResponse, err error) { - req, err := c.preparerForUpdate(ctx, id, input, options) - if err != nil { - err = autorest.NewErrorWithError(err, "openidconnectprovider.OpenidConnectProviderClient", "Update", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "openidconnectprovider.OpenidConnectProviderClient", "Update", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "openidconnectprovider.OpenidConnectProviderClient", "Update", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForUpdate prepares the Update request. -func (c OpenidConnectProviderClient) preparerForUpdate(ctx context.Context, id OpenidConnectProviderId, input OpenidConnectProviderUpdateContract, options UpdateOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPatch(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - 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 OpenidConnectProviderClient) 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/apimanagement/2021-08-01/outboundnetworkdependenciesendpoints/client.go b/resource-manager/apimanagement/2021-08-01/outboundnetworkdependenciesendpoints/client.go index 22c16a831a4..bdf407b2056 100644 --- a/resource-manager/apimanagement/2021-08-01/outboundnetworkdependenciesendpoints/client.go +++ b/resource-manager/apimanagement/2021-08-01/outboundnetworkdependenciesendpoints/client.go @@ -1,18 +1,26 @@ package outboundnetworkdependenciesendpoints -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 OutboundNetworkDependenciesEndpointsClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewOutboundNetworkDependenciesEndpointsClientWithBaseURI(endpoint string) OutboundNetworkDependenciesEndpointsClient { - return OutboundNetworkDependenciesEndpointsClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewOutboundNetworkDependenciesEndpointsClientWithBaseURI(api environments.Api) (*OutboundNetworkDependenciesEndpointsClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "outboundnetworkdependenciesendpoints", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating OutboundNetworkDependenciesEndpointsClient: %+v", err) } + + return &OutboundNetworkDependenciesEndpointsClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2021-08-01/outboundnetworkdependenciesendpoints/method_listbyservice.go b/resource-manager/apimanagement/2021-08-01/outboundnetworkdependenciesendpoints/method_listbyservice.go new file mode 100644 index 00000000000..32234f6b430 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/outboundnetworkdependenciesendpoints/method_listbyservice.go @@ -0,0 +1,52 @@ +package outboundnetworkdependenciesendpoints + +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 ListByServiceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *OutboundEnvironmentEndpointList +} + +// ListByService ... +func (c OutboundNetworkDependenciesEndpointsClient) ListByService(ctx context.Context, id ServiceId) (result ListByServiceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/outboundNetworkDependenciesEndpoints", 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/apimanagement/2021-08-01/outboundnetworkdependenciesendpoints/method_listbyservice_autorest.go b/resource-manager/apimanagement/2021-08-01/outboundnetworkdependenciesendpoints/method_listbyservice_autorest.go deleted file mode 100644 index 6c0aaf4214b..00000000000 --- a/resource-manager/apimanagement/2021-08-01/outboundnetworkdependenciesendpoints/method_listbyservice_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package outboundnetworkdependenciesendpoints - -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 ListByServiceOperationResponse struct { - HttpResponse *http.Response - Model *OutboundEnvironmentEndpointList -} - -// ListByService ... -func (c OutboundNetworkDependenciesEndpointsClient) ListByService(ctx context.Context, id ServiceId) (result ListByServiceOperationResponse, err error) { - req, err := c.preparerForListByService(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "outboundnetworkdependenciesendpoints.OutboundNetworkDependenciesEndpointsClient", "ListByService", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "outboundnetworkdependenciesendpoints.OutboundNetworkDependenciesEndpointsClient", "ListByService", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByService(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "outboundnetworkdependenciesendpoints.OutboundNetworkDependenciesEndpointsClient", "ListByService", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForListByService prepares the ListByService request. -func (c OutboundNetworkDependenciesEndpointsClient) preparerForListByService(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(fmt.Sprintf("%s/outboundNetworkDependenciesEndpoints", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListByService handles the response to the ListByService request. The method always -// closes the http.Response Body. -func (c OutboundNetworkDependenciesEndpointsClient) responderForListByService(resp *http.Response) (result ListByServiceOperationResponse, 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/apimanagement/2021-08-01/performconnectivitycheck/client.go b/resource-manager/apimanagement/2021-08-01/performconnectivitycheck/client.go index 9ad3cc36b7c..691170c7239 100644 --- a/resource-manager/apimanagement/2021-08-01/performconnectivitycheck/client.go +++ b/resource-manager/apimanagement/2021-08-01/performconnectivitycheck/client.go @@ -1,18 +1,26 @@ package performconnectivitycheck -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 PerformConnectivityCheckClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewPerformConnectivityCheckClientWithBaseURI(endpoint string) PerformConnectivityCheckClient { - return PerformConnectivityCheckClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewPerformConnectivityCheckClientWithBaseURI(api environments.Api) (*PerformConnectivityCheckClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "performconnectivitycheck", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating PerformConnectivityCheckClient: %+v", err) } + + return &PerformConnectivityCheckClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2021-08-01/performconnectivitycheck/constants.go b/resource-manager/apimanagement/2021-08-01/performconnectivitycheck/constants.go index 9bf9ce98491..df0ed03802b 100644 --- a/resource-manager/apimanagement/2021-08-01/performconnectivitycheck/constants.go +++ b/resource-manager/apimanagement/2021-08-01/performconnectivitycheck/constants.go @@ -1,6 +1,10 @@ package performconnectivitycheck -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 PossibleValuesForConnectionStatus() []string { } } +func (s *ConnectionStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseConnectionStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseConnectionStatus(input string) (*ConnectionStatus, error) { vals := map[string]ConnectionStatus{ "connected": ConnectionStatusConnected, @@ -55,6 +72,19 @@ func PossibleValuesForConnectivityCheckProtocol() []string { } } +func (s *ConnectivityCheckProtocol) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseConnectivityCheckProtocol(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseConnectivityCheckProtocol(input string) (*ConnectivityCheckProtocol, error) { vals := map[string]ConnectivityCheckProtocol{ "http": ConnectivityCheckProtocolHTTP, @@ -98,6 +128,19 @@ func PossibleValuesForIssueType() []string { } } +func (s *IssueType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseIssueType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseIssueType(input string) (*IssueType, error) { vals := map[string]IssueType{ "agentstopped": IssueTypeAgentStopped, @@ -133,6 +176,19 @@ func PossibleValuesForMethod() []string { } } +func (s *Method) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseMethod(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseMethod(input string) (*Method, error) { vals := map[string]Method{ "get": MethodGET, @@ -163,6 +219,19 @@ func PossibleValuesForOrigin() []string { } } +func (s *Origin) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseOrigin(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseOrigin(input string) (*Origin, error) { vals := map[string]Origin{ "inbound": OriginInbound, @@ -190,6 +259,19 @@ func PossibleValuesForPreferredIPVersion() []string { } } +func (s *PreferredIPVersion) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePreferredIPVersion(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parsePreferredIPVersion(input string) (*PreferredIPVersion, error) { vals := map[string]PreferredIPVersion{ "ipv4": PreferredIPVersionIPvFour, @@ -217,6 +299,19 @@ func PossibleValuesForSeverity() []string { } } +func (s *Severity) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSeverity(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseSeverity(input string) (*Severity, error) { vals := map[string]Severity{ "error": SeverityError, diff --git a/resource-manager/apimanagement/2021-08-01/performconnectivitycheck/method_async.go b/resource-manager/apimanagement/2021-08-01/performconnectivitycheck/method_async.go new file mode 100644 index 00000000000..ecb7574e628 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/performconnectivitycheck/method_async.go @@ -0,0 +1,74 @@ +package performconnectivitycheck + +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 AsyncOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Async ... +func (c PerformConnectivityCheckClient) Async(ctx context.Context, id ServiceId, input ConnectivityCheckRequest) (result AsyncOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/connectivityCheck", 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 +} + +// AsyncThenPoll performs Async then polls until it's completed +func (c PerformConnectivityCheckClient) AsyncThenPoll(ctx context.Context, id ServiceId, input ConnectivityCheckRequest) error { + result, err := c.Async(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Async: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Async: %+v", err) + } + + return nil +} diff --git a/resource-manager/apimanagement/2021-08-01/performconnectivitycheck/method_async_autorest.go b/resource-manager/apimanagement/2021-08-01/performconnectivitycheck/method_async_autorest.go deleted file mode 100644 index a2c486cc975..00000000000 --- a/resource-manager/apimanagement/2021-08-01/performconnectivitycheck/method_async_autorest.go +++ /dev/null @@ -1,79 +0,0 @@ -package performconnectivitycheck - -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 AsyncOperationResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// Async ... -func (c PerformConnectivityCheckClient) Async(ctx context.Context, id ServiceId, input ConnectivityCheckRequest) (result AsyncOperationResponse, err error) { - req, err := c.preparerForAsync(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "performconnectivitycheck.PerformConnectivityCheckClient", "Async", nil, "Failure preparing request") - return - } - - result, err = c.senderForAsync(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "performconnectivitycheck.PerformConnectivityCheckClient", "Async", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// AsyncThenPoll performs Async then polls until it's completed -func (c PerformConnectivityCheckClient) AsyncThenPoll(ctx context.Context, id ServiceId, input ConnectivityCheckRequest) error { - result, err := c.Async(ctx, id, input) - if err != nil { - return fmt.Errorf("performing Async: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after Async: %+v", err) - } - - return nil -} - -// preparerForAsync prepares the Async request. -func (c PerformConnectivityCheckClient) preparerForAsync(ctx context.Context, id ServiceId, input ConnectivityCheckRequest) (*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/connectivityCheck", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForAsync sends the Async request. The method will close the -// http.Response Body if it receives an error. -func (c PerformConnectivityCheckClient) senderForAsync(ctx context.Context, req *http.Request) (future AsyncOperationResponse, 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/apimanagement/2021-08-01/policy/client.go b/resource-manager/apimanagement/2021-08-01/policy/client.go index 100ea9be74e..609e5fa0964 100644 --- a/resource-manager/apimanagement/2021-08-01/policy/client.go +++ b/resource-manager/apimanagement/2021-08-01/policy/client.go @@ -1,18 +1,26 @@ package policy -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 PolicyClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewPolicyClientWithBaseURI(endpoint string) PolicyClient { - return PolicyClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewPolicyClientWithBaseURI(api environments.Api) (*PolicyClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "policy", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating PolicyClient: %+v", err) } + + return &PolicyClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2021-08-01/policy/constants.go b/resource-manager/apimanagement/2021-08-01/policy/constants.go index d347a3402e1..10a4650a395 100644 --- a/resource-manager/apimanagement/2021-08-01/policy/constants.go +++ b/resource-manager/apimanagement/2021-08-01/policy/constants.go @@ -1,6 +1,10 @@ package policy -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 PossibleValuesForPolicyContentFormat() []string { } } +func (s *PolicyContentFormat) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePolicyContentFormat(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parsePolicyContentFormat(input string) (*PolicyContentFormat, error) { vals := map[string]PolicyContentFormat{ "rawxml": PolicyContentFormatRawxml, @@ -53,6 +70,19 @@ func PossibleValuesForPolicyExportFormat() []string { } } +func (s *PolicyExportFormat) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePolicyExportFormat(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parsePolicyExportFormat(input string) (*PolicyExportFormat, error) { vals := map[string]PolicyExportFormat{ "rawxml": PolicyExportFormatRawxml, diff --git a/resource-manager/apimanagement/2021-08-01/policy/method_createorupdate.go b/resource-manager/apimanagement/2021-08-01/policy/method_createorupdate.go new file mode 100644 index 00000000000..0303d637d5e --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/policy/method_createorupdate.go @@ -0,0 +1,85 @@ +package policy + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PolicyContract +} + +type CreateOrUpdateOperationOptions struct { + IfMatch *string +} + +func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { + return CreateOrUpdateOperationOptions{} +} + +func (o CreateOrUpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o CreateOrUpdateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o CreateOrUpdateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// CreateOrUpdate ... +func (c PolicyClient) CreateOrUpdate(ctx context.Context, id ServiceId, input PolicyContract, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/policies/policy", id.ID()), + OptionsObject: options, + } + + 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/apimanagement/2021-08-01/policy/method_createorupdate_autorest.go b/resource-manager/apimanagement/2021-08-01/policy/method_createorupdate_autorest.go deleted file mode 100644 index 6891db3acdb..00000000000 --- a/resource-manager/apimanagement/2021-08-01/policy/method_createorupdate_autorest.go +++ /dev/null @@ -1,99 +0,0 @@ -package policy - -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 CreateOrUpdateOperationResponse struct { - HttpResponse *http.Response - Model *PolicyContract -} - -type CreateOrUpdateOperationOptions struct { - IfMatch *string -} - -func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { - return CreateOrUpdateOperationOptions{} -} - -func (o CreateOrUpdateOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o CreateOrUpdateOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// CreateOrUpdate ... -func (c PolicyClient) CreateOrUpdate(ctx context.Context, id ServiceId, input PolicyContract, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdate(ctx, id, input, options) - if err != nil { - err = autorest.NewErrorWithError(err, "policy.PolicyClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "policy.PolicyClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCreateOrUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "policy.PolicyClient", "CreateOrUpdate", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCreateOrUpdate prepares the CreateOrUpdate request. -func (c PolicyClient) preparerForCreateOrUpdate(ctx context.Context, id ServiceId, input PolicyContract, options CreateOrUpdateOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/policies/policy", 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 PolicyClient) responderForCreateOrUpdate(resp *http.Response) (result CreateOrUpdateOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2021-08-01/policy/method_delete.go b/resource-manager/apimanagement/2021-08-01/policy/method_delete.go new file mode 100644 index 00000000000..4ddd78e13cb --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/policy/method_delete.go @@ -0,0 +1,76 @@ +package policy + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +type DeleteOperationOptions struct { + IfMatch *string +} + +func DefaultDeleteOperationOptions() DeleteOperationOptions { + return DeleteOperationOptions{} +} + +func (o DeleteOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o DeleteOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o DeleteOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// Delete ... +func (c PolicyClient) Delete(ctx context.Context, id ServiceId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: fmt.Sprintf("%s/policies/policy", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2021-08-01/policy/method_delete_autorest.go b/resource-manager/apimanagement/2021-08-01/policy/method_delete_autorest.go deleted file mode 100644 index 48c0e129f41..00000000000 --- a/resource-manager/apimanagement/2021-08-01/policy/method_delete_autorest.go +++ /dev/null @@ -1,96 +0,0 @@ -package policy - -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 DeleteOperationResponse struct { - HttpResponse *http.Response -} - -type DeleteOperationOptions struct { - IfMatch *string -} - -func DefaultDeleteOperationOptions() DeleteOperationOptions { - return DeleteOperationOptions{} -} - -func (o DeleteOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o DeleteOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// Delete ... -func (c PolicyClient) Delete(ctx context.Context, id ServiceId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { - req, err := c.preparerForDelete(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "policy.PolicyClient", "Delete", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "policy.PolicyClient", "Delete", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForDelete(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "policy.PolicyClient", "Delete", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForDelete prepares the Delete request. -func (c PolicyClient) preparerForDelete(ctx context.Context, id ServiceId, options DeleteOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/policies/policy", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForDelete handles the response to the Delete request. The method always -// closes the http.Response Body. -func (c PolicyClient) responderForDelete(resp *http.Response) (result DeleteOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2021-08-01/policy/method_get.go b/resource-manager/apimanagement/2021-08-01/policy/method_get.go new file mode 100644 index 00000000000..829e84ff74d --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/policy/method_get.go @@ -0,0 +1,80 @@ +package policy + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PolicyContract +} + +type GetOperationOptions struct { + Format *PolicyExportFormat +} + +func DefaultGetOperationOptions() GetOperationOptions { + return GetOperationOptions{} +} + +func (o GetOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o GetOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o GetOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Format != nil { + out.Append("format", fmt.Sprintf("%v", *o.Format)) + } + return &out +} + +// Get ... +func (c PolicyClient) Get(ctx context.Context, id ServiceId, options GetOperationOptions) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/policies/policy", id.ID()), + OptionsObject: options, + } + + 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/apimanagement/2021-08-01/policy/method_get_autorest.go b/resource-manager/apimanagement/2021-08-01/policy/method_get_autorest.go deleted file mode 100644 index 5b1f10a4714..00000000000 --- a/resource-manager/apimanagement/2021-08-01/policy/method_get_autorest.go +++ /dev/null @@ -1,98 +0,0 @@ -package policy - -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 GetOperationResponse struct { - HttpResponse *http.Response - Model *PolicyContract -} - -type GetOperationOptions struct { - Format *PolicyExportFormat -} - -func DefaultGetOperationOptions() GetOperationOptions { - return GetOperationOptions{} -} - -func (o GetOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o GetOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Format != nil { - out["format"] = *o.Format - } - - return out -} - -// Get ... -func (c PolicyClient) Get(ctx context.Context, id ServiceId, options GetOperationOptions) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "policy.PolicyClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "policy.PolicyClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "policy.PolicyClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c PolicyClient) preparerForGet(ctx context.Context, id ServiceId, options GetOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/policies/policy", 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 PolicyClient) 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/apimanagement/2021-08-01/policy/method_getentitytag.go b/resource-manager/apimanagement/2021-08-01/policy/method_getentitytag.go new file mode 100644 index 00000000000..d8575a5f4ca --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/policy/method_getentitytag.go @@ -0,0 +1,47 @@ +package policy + +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 GetEntityTagOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// GetEntityTag ... +func (c PolicyClient) GetEntityTag(ctx context.Context, id ServiceId) (result GetEntityTagOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodHead, + Path: fmt.Sprintf("%s/policies/policy", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2021-08-01/policy/method_getentitytag_autorest.go b/resource-manager/apimanagement/2021-08-01/policy/method_getentitytag_autorest.go deleted file mode 100644 index 40957baa188..00000000000 --- a/resource-manager/apimanagement/2021-08-01/policy/method_getentitytag_autorest.go +++ /dev/null @@ -1,67 +0,0 @@ -package policy - -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 GetEntityTagOperationResponse struct { - HttpResponse *http.Response -} - -// GetEntityTag ... -func (c PolicyClient) GetEntityTag(ctx context.Context, id ServiceId) (result GetEntityTagOperationResponse, err error) { - req, err := c.preparerForGetEntityTag(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "policy.PolicyClient", "GetEntityTag", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "policy.PolicyClient", "GetEntityTag", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetEntityTag(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "policy.PolicyClient", "GetEntityTag", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetEntityTag prepares the GetEntityTag request. -func (c PolicyClient) preparerForGetEntityTag(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.AsHead(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/policies/policy", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetEntityTag handles the response to the GetEntityTag request. The method always -// closes the http.Response Body. -func (c PolicyClient) responderForGetEntityTag(resp *http.Response) (result GetEntityTagOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2021-08-01/policy/method_listbyservice.go b/resource-manager/apimanagement/2021-08-01/policy/method_listbyservice.go new file mode 100644 index 00000000000..2cba37b4dd0 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/policy/method_listbyservice.go @@ -0,0 +1,52 @@ +package policy + +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 ListByServiceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PolicyCollection +} + +// ListByService ... +func (c PolicyClient) ListByService(ctx context.Context, id ServiceId) (result ListByServiceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/policies", 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/apimanagement/2021-08-01/policy/method_listbyservice_autorest.go b/resource-manager/apimanagement/2021-08-01/policy/method_listbyservice_autorest.go deleted file mode 100644 index 753788e2a82..00000000000 --- a/resource-manager/apimanagement/2021-08-01/policy/method_listbyservice_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package policy - -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 ListByServiceOperationResponse struct { - HttpResponse *http.Response - Model *PolicyCollection -} - -// ListByService ... -func (c PolicyClient) ListByService(ctx context.Context, id ServiceId) (result ListByServiceOperationResponse, err error) { - req, err := c.preparerForListByService(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "policy.PolicyClient", "ListByService", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "policy.PolicyClient", "ListByService", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByService(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "policy.PolicyClient", "ListByService", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForListByService prepares the ListByService request. -func (c PolicyClient) preparerForListByService(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(fmt.Sprintf("%s/policies", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListByService handles the response to the ListByService request. The method always -// closes the http.Response Body. -func (c PolicyClient) responderForListByService(resp *http.Response) (result ListByServiceOperationResponse, 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/apimanagement/2021-08-01/policydescription/client.go b/resource-manager/apimanagement/2021-08-01/policydescription/client.go index 2ad1b60908c..a732550d9d3 100644 --- a/resource-manager/apimanagement/2021-08-01/policydescription/client.go +++ b/resource-manager/apimanagement/2021-08-01/policydescription/client.go @@ -1,18 +1,26 @@ package policydescription -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 PolicyDescriptionClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewPolicyDescriptionClientWithBaseURI(endpoint string) PolicyDescriptionClient { - return PolicyDescriptionClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewPolicyDescriptionClientWithBaseURI(api environments.Api) (*PolicyDescriptionClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "policydescription", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating PolicyDescriptionClient: %+v", err) } + + return &PolicyDescriptionClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2021-08-01/policydescription/constants.go b/resource-manager/apimanagement/2021-08-01/policydescription/constants.go index 5f73fe9e994..be5c274580c 100644 --- a/resource-manager/apimanagement/2021-08-01/policydescription/constants.go +++ b/resource-manager/apimanagement/2021-08-01/policydescription/constants.go @@ -1,6 +1,10 @@ package policydescription -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. @@ -25,6 +29,19 @@ func PossibleValuesForPolicyScopeContract() []string { } } +func (s *PolicyScopeContract) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePolicyScopeContract(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parsePolicyScopeContract(input string) (*PolicyScopeContract, error) { vals := map[string]PolicyScopeContract{ "all": PolicyScopeContractAll, diff --git a/resource-manager/apimanagement/2021-08-01/policydescription/method_listbyservice.go b/resource-manager/apimanagement/2021-08-01/policydescription/method_listbyservice.go new file mode 100644 index 00000000000..397951b3351 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/policydescription/method_listbyservice.go @@ -0,0 +1,80 @@ +package policydescription + +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 ListByServiceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PolicyDescriptionCollection +} + +type ListByServiceOperationOptions struct { + Scope *PolicyScopeContract +} + +func DefaultListByServiceOperationOptions() ListByServiceOperationOptions { + return ListByServiceOperationOptions{} +} + +func (o ListByServiceOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListByServiceOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListByServiceOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Scope != nil { + out.Append("scope", fmt.Sprintf("%v", *o.Scope)) + } + return &out +} + +// ListByService ... +func (c PolicyDescriptionClient) ListByService(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (result ListByServiceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/policyDescriptions", id.ID()), + OptionsObject: options, + } + + 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/apimanagement/2021-08-01/policydescription/method_listbyservice_autorest.go b/resource-manager/apimanagement/2021-08-01/policydescription/method_listbyservice_autorest.go deleted file mode 100644 index 0b74d09e511..00000000000 --- a/resource-manager/apimanagement/2021-08-01/policydescription/method_listbyservice_autorest.go +++ /dev/null @@ -1,98 +0,0 @@ -package policydescription - -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 ListByServiceOperationResponse struct { - HttpResponse *http.Response - Model *PolicyDescriptionCollection -} - -type ListByServiceOperationOptions struct { - Scope *PolicyScopeContract -} - -func DefaultListByServiceOperationOptions() ListByServiceOperationOptions { - return ListByServiceOperationOptions{} -} - -func (o ListByServiceOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o ListByServiceOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Scope != nil { - out["scope"] = *o.Scope - } - - return out -} - -// ListByService ... -func (c PolicyDescriptionClient) ListByService(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (result ListByServiceOperationResponse, err error) { - req, err := c.preparerForListByService(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "policydescription.PolicyDescriptionClient", "ListByService", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "policydescription.PolicyDescriptionClient", "ListByService", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByService(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "policydescription.PolicyDescriptionClient", "ListByService", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForListByService prepares the ListByService request. -func (c PolicyDescriptionClient) preparerForListByService(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/policyDescriptions", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListByService handles the response to the ListByService request. The method always -// closes the http.Response Body. -func (c PolicyDescriptionClient) responderForListByService(resp *http.Response) (result ListByServiceOperationResponse, 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/apimanagement/2021-08-01/portalrevision/client.go b/resource-manager/apimanagement/2021-08-01/portalrevision/client.go index b6215519652..01b0e3dbaa2 100644 --- a/resource-manager/apimanagement/2021-08-01/portalrevision/client.go +++ b/resource-manager/apimanagement/2021-08-01/portalrevision/client.go @@ -1,18 +1,26 @@ package portalrevision -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 PortalRevisionClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewPortalRevisionClientWithBaseURI(endpoint string) PortalRevisionClient { - return PortalRevisionClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewPortalRevisionClientWithBaseURI(api environments.Api) (*PortalRevisionClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "portalrevision", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating PortalRevisionClient: %+v", err) } + + return &PortalRevisionClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2021-08-01/portalrevision/constants.go b/resource-manager/apimanagement/2021-08-01/portalrevision/constants.go index aa2001884d8..721b9d119dc 100644 --- a/resource-manager/apimanagement/2021-08-01/portalrevision/constants.go +++ b/resource-manager/apimanagement/2021-08-01/portalrevision/constants.go @@ -1,6 +1,10 @@ package portalrevision -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 PossibleValuesForPortalRevisionStatus() []string { } } +func (s *PortalRevisionStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePortalRevisionStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parsePortalRevisionStatus(input string) (*PortalRevisionStatus, error) { vals := map[string]PortalRevisionStatus{ "completed": PortalRevisionStatusCompleted, diff --git a/resource-manager/apimanagement/2021-08-01/portalrevision/method_createorupdate.go b/resource-manager/apimanagement/2021-08-01/portalrevision/method_createorupdate.go new file mode 100644 index 00000000000..a28f2755f5b --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/portalrevision/method_createorupdate.go @@ -0,0 +1,74 @@ +package portalrevision + +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 +} + +// CreateOrUpdate ... +func (c PortalRevisionClient) CreateOrUpdate(ctx context.Context, id PortalRevisionId, input PortalRevisionContract) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusCreated, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed +func (c PortalRevisionClient) CreateOrUpdateThenPoll(ctx context.Context, id PortalRevisionId, input PortalRevisionContract) 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/apimanagement/2021-08-01/portalrevision/method_createorupdate_autorest.go b/resource-manager/apimanagement/2021-08-01/portalrevision/method_createorupdate_autorest.go deleted file mode 100644 index e674d1c6391..00000000000 --- a/resource-manager/apimanagement/2021-08-01/portalrevision/method_createorupdate_autorest.go +++ /dev/null @@ -1,79 +0,0 @@ -package portalrevision - -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 -} - -// CreateOrUpdate ... -func (c PortalRevisionClient) CreateOrUpdate(ctx context.Context, id PortalRevisionId, input PortalRevisionContract) (result CreateOrUpdateOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "portalrevision.PortalRevisionClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result, err = c.senderForCreateOrUpdate(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "portalrevision.PortalRevisionClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed -func (c PortalRevisionClient) CreateOrUpdateThenPoll(ctx context.Context, id PortalRevisionId, input PortalRevisionContract) 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 PortalRevisionClient) preparerForCreateOrUpdate(ctx context.Context, id PortalRevisionId, input PortalRevisionContract) (*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 PortalRevisionClient) 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/apimanagement/2021-08-01/portalrevision/method_get.go b/resource-manager/apimanagement/2021-08-01/portalrevision/method_get.go new file mode 100644 index 00000000000..ebc6cd16a57 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/portalrevision/method_get.go @@ -0,0 +1,51 @@ +package portalrevision + +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 *PortalRevisionContract +} + +// Get ... +func (c PortalRevisionClient) Get(ctx context.Context, id PortalRevisionId) (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/apimanagement/2021-08-01/portalrevision/method_get_autorest.go b/resource-manager/apimanagement/2021-08-01/portalrevision/method_get_autorest.go deleted file mode 100644 index 2c81b2f3322..00000000000 --- a/resource-manager/apimanagement/2021-08-01/portalrevision/method_get_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package portalrevision - -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 *PortalRevisionContract -} - -// Get ... -func (c PortalRevisionClient) Get(ctx context.Context, id PortalRevisionId) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "portalrevision.PortalRevisionClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "portalrevision.PortalRevisionClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "portalrevision.PortalRevisionClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c PortalRevisionClient) preparerForGet(ctx context.Context, id PortalRevisionId) (*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 PortalRevisionClient) 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/apimanagement/2021-08-01/portalrevision/method_getentitytag.go b/resource-manager/apimanagement/2021-08-01/portalrevision/method_getentitytag.go new file mode 100644 index 00000000000..c29d462fb8e --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/portalrevision/method_getentitytag.go @@ -0,0 +1,46 @@ +package portalrevision + +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 GetEntityTagOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// GetEntityTag ... +func (c PortalRevisionClient) GetEntityTag(ctx context.Context, id PortalRevisionId) (result GetEntityTagOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodHead, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2021-08-01/portalrevision/method_getentitytag_autorest.go b/resource-manager/apimanagement/2021-08-01/portalrevision/method_getentitytag_autorest.go deleted file mode 100644 index 673f88eb7c5..00000000000 --- a/resource-manager/apimanagement/2021-08-01/portalrevision/method_getentitytag_autorest.go +++ /dev/null @@ -1,66 +0,0 @@ -package portalrevision - -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 GetEntityTagOperationResponse struct { - HttpResponse *http.Response -} - -// GetEntityTag ... -func (c PortalRevisionClient) GetEntityTag(ctx context.Context, id PortalRevisionId) (result GetEntityTagOperationResponse, err error) { - req, err := c.preparerForGetEntityTag(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "portalrevision.PortalRevisionClient", "GetEntityTag", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "portalrevision.PortalRevisionClient", "GetEntityTag", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetEntityTag(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "portalrevision.PortalRevisionClient", "GetEntityTag", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetEntityTag prepares the GetEntityTag request. -func (c PortalRevisionClient) preparerForGetEntityTag(ctx context.Context, id PortalRevisionId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsHead(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetEntityTag handles the response to the GetEntityTag request. The method always -// closes the http.Response Body. -func (c PortalRevisionClient) responderForGetEntityTag(resp *http.Response) (result GetEntityTagOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2021-08-01/portalrevision/method_listbyservice.go b/resource-manager/apimanagement/2021-08-01/portalrevision/method_listbyservice.go new file mode 100644 index 00000000000..367a0040241 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/portalrevision/method_listbyservice.go @@ -0,0 +1,125 @@ +package portalrevision + +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 ListByServiceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]PortalRevisionContract +} + +type ListByServiceCompleteResult struct { + Items []PortalRevisionContract +} + +type ListByServiceOperationOptions struct { + Filter *string + Skip *int64 + Top *int64 +} + +func DefaultListByServiceOperationOptions() ListByServiceOperationOptions { + return ListByServiceOperationOptions{} +} + +func (o ListByServiceOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListByServiceOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListByServiceOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.Skip != nil { + out.Append("$skip", fmt.Sprintf("%v", *o.Skip)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +// ListByService ... +func (c PortalRevisionClient) ListByService(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (result ListByServiceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/portalRevisions", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]PortalRevisionContract `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByServiceComplete retrieves all the results into a single object +func (c PortalRevisionClient) ListByServiceComplete(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (ListByServiceCompleteResult, error) { + return c.ListByServiceCompleteMatchingPredicate(ctx, id, options, PortalRevisionContractOperationPredicate{}) +} + +// ListByServiceCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c PortalRevisionClient) ListByServiceCompleteMatchingPredicate(ctx context.Context, id ServiceId, options ListByServiceOperationOptions, predicate PortalRevisionContractOperationPredicate) (result ListByServiceCompleteResult, err error) { + items := make([]PortalRevisionContract, 0) + + resp, err := c.ListByService(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByServiceCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/apimanagement/2021-08-01/portalrevision/method_listbyservice_autorest.go b/resource-manager/apimanagement/2021-08-01/portalrevision/method_listbyservice_autorest.go deleted file mode 100644 index e804ebd138b..00000000000 --- a/resource-manager/apimanagement/2021-08-01/portalrevision/method_listbyservice_autorest.go +++ /dev/null @@ -1,225 +0,0 @@ -package portalrevision - -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 ListByServiceOperationResponse struct { - HttpResponse *http.Response - Model *[]PortalRevisionContract - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListByServiceOperationResponse, error) -} - -type ListByServiceCompleteResult struct { - Items []PortalRevisionContract -} - -func (r ListByServiceOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListByServiceOperationResponse) LoadMore(ctx context.Context) (resp ListByServiceOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -type ListByServiceOperationOptions struct { - Filter *string - Skip *int64 - Top *int64 -} - -func DefaultListByServiceOperationOptions() ListByServiceOperationOptions { - return ListByServiceOperationOptions{} -} - -func (o ListByServiceOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o ListByServiceOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Filter != nil { - out["$filter"] = *o.Filter - } - - if o.Skip != nil { - out["$skip"] = *o.Skip - } - - if o.Top != nil { - out["$top"] = *o.Top - } - - return out -} - -// ListByService ... -func (c PortalRevisionClient) ListByService(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (resp ListByServiceOperationResponse, err error) { - req, err := c.preparerForListByService(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "portalrevision.PortalRevisionClient", "ListByService", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "portalrevision.PortalRevisionClient", "ListByService", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListByService(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "portalrevision.PortalRevisionClient", "ListByService", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListByService prepares the ListByService request. -func (c PortalRevisionClient) preparerForListByService(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/portalRevisions", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListByServiceWithNextLink prepares the ListByService request with the given nextLink token. -func (c PortalRevisionClient) preparerForListByServiceWithNextLink(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)) -} - -// responderForListByService handles the response to the ListByService request. The method always -// closes the http.Response Body. -func (c PortalRevisionClient) responderForListByService(resp *http.Response) (result ListByServiceOperationResponse, err error) { - type page struct { - Values []PortalRevisionContract `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 ListByServiceOperationResponse, err error) { - req, err := c.preparerForListByServiceWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "portalrevision.PortalRevisionClient", "ListByService", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "portalrevision.PortalRevisionClient", "ListByService", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByService(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "portalrevision.PortalRevisionClient", "ListByService", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListByServiceComplete retrieves all of the results into a single object -func (c PortalRevisionClient) ListByServiceComplete(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (ListByServiceCompleteResult, error) { - return c.ListByServiceCompleteMatchingPredicate(ctx, id, options, PortalRevisionContractOperationPredicate{}) -} - -// ListByServiceCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c PortalRevisionClient) ListByServiceCompleteMatchingPredicate(ctx context.Context, id ServiceId, options ListByServiceOperationOptions, predicate PortalRevisionContractOperationPredicate) (resp ListByServiceCompleteResult, err error) { - items := make([]PortalRevisionContract, 0) - - page, err := c.ListByService(ctx, id, options) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListByServiceCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/apimanagement/2021-08-01/portalrevision/method_update.go b/resource-manager/apimanagement/2021-08-01/portalrevision/method_update.go new file mode 100644 index 00000000000..d9b47a64729 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/portalrevision/method_update.go @@ -0,0 +1,102 @@ +package portalrevision + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +type UpdateOperationOptions struct { + IfMatch *string +} + +func DefaultUpdateOperationOptions() UpdateOperationOptions { + return UpdateOperationOptions{} +} + +func (o UpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o UpdateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o UpdateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// Update ... +func (c PortalRevisionClient) Update(ctx context.Context, id PortalRevisionId, input PortalRevisionContract, options UpdateOperationOptions) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// UpdateThenPoll performs Update then polls until it's completed +func (c PortalRevisionClient) UpdateThenPoll(ctx context.Context, id PortalRevisionId, input PortalRevisionContract, options UpdateOperationOptions) error { + result, err := c.Update(ctx, id, input, options) + if err != nil { + return fmt.Errorf("performing Update: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Update: %+v", err) + } + + return nil +} diff --git a/resource-manager/apimanagement/2021-08-01/portalrevision/method_update_autorest.go b/resource-manager/apimanagement/2021-08-01/portalrevision/method_update_autorest.go deleted file mode 100644 index e6c980e81fa..00000000000 --- a/resource-manager/apimanagement/2021-08-01/portalrevision/method_update_autorest.go +++ /dev/null @@ -1,108 +0,0 @@ -package portalrevision - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type UpdateOperationResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -type UpdateOperationOptions struct { - IfMatch *string -} - -func DefaultUpdateOperationOptions() UpdateOperationOptions { - return UpdateOperationOptions{} -} - -func (o UpdateOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o UpdateOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// Update ... -func (c PortalRevisionClient) Update(ctx context.Context, id PortalRevisionId, input PortalRevisionContract, options UpdateOperationOptions) (result UpdateOperationResponse, err error) { - req, err := c.preparerForUpdate(ctx, id, input, options) - if err != nil { - err = autorest.NewErrorWithError(err, "portalrevision.PortalRevisionClient", "Update", nil, "Failure preparing request") - return - } - - result, err = c.senderForUpdate(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "portalrevision.PortalRevisionClient", "Update", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// UpdateThenPoll performs Update then polls until it's completed -func (c PortalRevisionClient) UpdateThenPoll(ctx context.Context, id PortalRevisionId, input PortalRevisionContract, options UpdateOperationOptions) error { - result, err := c.Update(ctx, id, input, options) - if err != nil { - return fmt.Errorf("performing Update: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after Update: %+v", err) - } - - return nil -} - -// preparerForUpdate prepares the Update request. -func (c PortalRevisionClient) preparerForUpdate(ctx context.Context, id PortalRevisionId, input PortalRevisionContract, options UpdateOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPatch(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForUpdate sends the Update request. The method will close the -// http.Response Body if it receives an error. -func (c PortalRevisionClient) senderForUpdate(ctx context.Context, req *http.Request) (future UpdateOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/apimanagement/2021-08-01/portalsettings/client.go b/resource-manager/apimanagement/2021-08-01/portalsettings/client.go index 7f256742d89..466acaf2584 100644 --- a/resource-manager/apimanagement/2021-08-01/portalsettings/client.go +++ b/resource-manager/apimanagement/2021-08-01/portalsettings/client.go @@ -1,18 +1,26 @@ package portalsettings -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 PortalSettingsClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewPortalSettingsClientWithBaseURI(endpoint string) PortalSettingsClient { - return PortalSettingsClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewPortalSettingsClientWithBaseURI(api environments.Api) (*PortalSettingsClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "portalsettings", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating PortalSettingsClient: %+v", err) } + + return &PortalSettingsClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2021-08-01/portalsettings/method_listbyservice.go b/resource-manager/apimanagement/2021-08-01/portalsettings/method_listbyservice.go new file mode 100644 index 00000000000..5f25ab8003b --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/portalsettings/method_listbyservice.go @@ -0,0 +1,52 @@ +package portalsettings + +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 ListByServiceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PortalSettingsCollection +} + +// ListByService ... +func (c PortalSettingsClient) ListByService(ctx context.Context, id ServiceId) (result ListByServiceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/portalsettings", 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/apimanagement/2021-08-01/portalsettings/method_listbyservice_autorest.go b/resource-manager/apimanagement/2021-08-01/portalsettings/method_listbyservice_autorest.go deleted file mode 100644 index d9168eff5c9..00000000000 --- a/resource-manager/apimanagement/2021-08-01/portalsettings/method_listbyservice_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package portalsettings - -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 ListByServiceOperationResponse struct { - HttpResponse *http.Response - Model *PortalSettingsCollection -} - -// ListByService ... -func (c PortalSettingsClient) ListByService(ctx context.Context, id ServiceId) (result ListByServiceOperationResponse, err error) { - req, err := c.preparerForListByService(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "portalsettings.PortalSettingsClient", "ListByService", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "portalsettings.PortalSettingsClient", "ListByService", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByService(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "portalsettings.PortalSettingsClient", "ListByService", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForListByService prepares the ListByService request. -func (c PortalSettingsClient) preparerForListByService(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(fmt.Sprintf("%s/portalsettings", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListByService handles the response to the ListByService request. The method always -// closes the http.Response Body. -func (c PortalSettingsClient) responderForListByService(resp *http.Response) (result ListByServiceOperationResponse, 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/apimanagement/2021-08-01/privateendpointconnections/client.go b/resource-manager/apimanagement/2021-08-01/privateendpointconnections/client.go index 1de584406fe..05a6653dc59 100644 --- a/resource-manager/apimanagement/2021-08-01/privateendpointconnections/client.go +++ b/resource-manager/apimanagement/2021-08-01/privateendpointconnections/client.go @@ -1,18 +1,26 @@ package privateendpointconnections -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/environments" +) // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See NOTICE.txt in the project root for license information. type PrivateEndpointConnectionsClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewPrivateEndpointConnectionsClientWithBaseURI(endpoint string) PrivateEndpointConnectionsClient { - return PrivateEndpointConnectionsClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewPrivateEndpointConnectionsClientWithBaseURI(api environments.Api) (*PrivateEndpointConnectionsClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "privateendpointconnections", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating PrivateEndpointConnectionsClient: %+v", err) } + + return &PrivateEndpointConnectionsClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2021-08-01/privateendpointconnections/constants.go b/resource-manager/apimanagement/2021-08-01/privateendpointconnections/constants.go index b6aed9e880a..c5850609650 100644 --- a/resource-manager/apimanagement/2021-08-01/privateendpointconnections/constants.go +++ b/resource-manager/apimanagement/2021-08-01/privateendpointconnections/constants.go @@ -1,6 +1,10 @@ package privateendpointconnections -import "strings" +import ( + "encoding/json" + "fmt" + "strings" +) // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See NOTICE.txt in the project root for license information. @@ -23,6 +27,19 @@ func PossibleValuesForPrivateEndpointConnectionProvisioningState() []string { } } +func (s *PrivateEndpointConnectionProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePrivateEndpointConnectionProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parsePrivateEndpointConnectionProvisioningState(input string) (*PrivateEndpointConnectionProvisioningState, error) { vals := map[string]PrivateEndpointConnectionProvisioningState{ "creating": PrivateEndpointConnectionProvisioningStateCreating, @@ -55,6 +72,19 @@ func PossibleValuesForPrivateEndpointServiceConnectionStatus() []string { } } +func (s *PrivateEndpointServiceConnectionStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePrivateEndpointServiceConnectionStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parsePrivateEndpointServiceConnectionStatus(input string) (*PrivateEndpointServiceConnectionStatus, error) { vals := map[string]PrivateEndpointServiceConnectionStatus{ "approved": PrivateEndpointServiceConnectionStatusApproved, diff --git a/resource-manager/apimanagement/2021-08-01/privateendpointconnections/method_privateendpointconnectioncreateorupdate.go b/resource-manager/apimanagement/2021-08-01/privateendpointconnections/method_privateendpointconnectioncreateorupdate.go new file mode 100644 index 00000000000..f348834c3ca --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/privateendpointconnections/method_privateendpointconnectioncreateorupdate.go @@ -0,0 +1,74 @@ +package privateendpointconnections + +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 PrivateEndpointConnectionCreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// PrivateEndpointConnectionCreateOrUpdate ... +func (c PrivateEndpointConnectionsClient) PrivateEndpointConnectionCreateOrUpdate(ctx context.Context, id PrivateEndpointConnectionId, input PrivateEndpointConnectionRequest) (result PrivateEndpointConnectionCreateOrUpdateOperationResponse, 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 +} + +// PrivateEndpointConnectionCreateOrUpdateThenPoll performs PrivateEndpointConnectionCreateOrUpdate then polls until it's completed +func (c PrivateEndpointConnectionsClient) PrivateEndpointConnectionCreateOrUpdateThenPoll(ctx context.Context, id PrivateEndpointConnectionId, input PrivateEndpointConnectionRequest) error { + result, err := c.PrivateEndpointConnectionCreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing PrivateEndpointConnectionCreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after PrivateEndpointConnectionCreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/apimanagement/2021-08-01/privateendpointconnections/method_privateendpointconnectioncreateorupdate_autorest.go b/resource-manager/apimanagement/2021-08-01/privateendpointconnections/method_privateendpointconnectioncreateorupdate_autorest.go deleted file mode 100644 index f890917081c..00000000000 --- a/resource-manager/apimanagement/2021-08-01/privateendpointconnections/method_privateendpointconnectioncreateorupdate_autorest.go +++ /dev/null @@ -1,79 +0,0 @@ -package privateendpointconnections - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type PrivateEndpointConnectionCreateOrUpdateOperationResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// PrivateEndpointConnectionCreateOrUpdate ... -func (c PrivateEndpointConnectionsClient) PrivateEndpointConnectionCreateOrUpdate(ctx context.Context, id PrivateEndpointConnectionId, input PrivateEndpointConnectionRequest) (result PrivateEndpointConnectionCreateOrUpdateOperationResponse, err error) { - req, err := c.preparerForPrivateEndpointConnectionCreateOrUpdate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "privateendpointconnections.PrivateEndpointConnectionsClient", "PrivateEndpointConnectionCreateOrUpdate", nil, "Failure preparing request") - return - } - - result, err = c.senderForPrivateEndpointConnectionCreateOrUpdate(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "privateendpointconnections.PrivateEndpointConnectionsClient", "PrivateEndpointConnectionCreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// PrivateEndpointConnectionCreateOrUpdateThenPoll performs PrivateEndpointConnectionCreateOrUpdate then polls until it's completed -func (c PrivateEndpointConnectionsClient) PrivateEndpointConnectionCreateOrUpdateThenPoll(ctx context.Context, id PrivateEndpointConnectionId, input PrivateEndpointConnectionRequest) error { - result, err := c.PrivateEndpointConnectionCreateOrUpdate(ctx, id, input) - if err != nil { - return fmt.Errorf("performing PrivateEndpointConnectionCreateOrUpdate: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after PrivateEndpointConnectionCreateOrUpdate: %+v", err) - } - - return nil -} - -// preparerForPrivateEndpointConnectionCreateOrUpdate prepares the PrivateEndpointConnectionCreateOrUpdate request. -func (c PrivateEndpointConnectionsClient) preparerForPrivateEndpointConnectionCreateOrUpdate(ctx context.Context, id PrivateEndpointConnectionId, input PrivateEndpointConnectionRequest) (*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)) -} - -// senderForPrivateEndpointConnectionCreateOrUpdate sends the PrivateEndpointConnectionCreateOrUpdate request. The method will close the -// http.Response Body if it receives an error. -func (c PrivateEndpointConnectionsClient) senderForPrivateEndpointConnectionCreateOrUpdate(ctx context.Context, req *http.Request) (future PrivateEndpointConnectionCreateOrUpdateOperationResponse, 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/apimanagement/2021-08-01/privateendpointconnections/method_privateendpointconnectiondelete.go b/resource-manager/apimanagement/2021-08-01/privateendpointconnections/method_privateendpointconnectiondelete.go new file mode 100644 index 00000000000..3dea5aca1b3 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/privateendpointconnections/method_privateendpointconnectiondelete.go @@ -0,0 +1,71 @@ +package privateendpointconnections + +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 PrivateEndpointConnectionDeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// PrivateEndpointConnectionDelete ... +func (c PrivateEndpointConnectionsClient) PrivateEndpointConnectionDelete(ctx context.Context, id PrivateEndpointConnectionId) (result PrivateEndpointConnectionDeleteOperationResponse, 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 +} + +// PrivateEndpointConnectionDeleteThenPoll performs PrivateEndpointConnectionDelete then polls until it's completed +func (c PrivateEndpointConnectionsClient) PrivateEndpointConnectionDeleteThenPoll(ctx context.Context, id PrivateEndpointConnectionId) error { + result, err := c.PrivateEndpointConnectionDelete(ctx, id) + if err != nil { + return fmt.Errorf("performing PrivateEndpointConnectionDelete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after PrivateEndpointConnectionDelete: %+v", err) + } + + return nil +} diff --git a/resource-manager/apimanagement/2021-08-01/privateendpointconnections/method_privateendpointconnectiondelete_autorest.go b/resource-manager/apimanagement/2021-08-01/privateendpointconnections/method_privateendpointconnectiondelete_autorest.go deleted file mode 100644 index 6c53edbf85b..00000000000 --- a/resource-manager/apimanagement/2021-08-01/privateendpointconnections/method_privateendpointconnectiondelete_autorest.go +++ /dev/null @@ -1,78 +0,0 @@ -package privateendpointconnections - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type PrivateEndpointConnectionDeleteOperationResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// PrivateEndpointConnectionDelete ... -func (c PrivateEndpointConnectionsClient) PrivateEndpointConnectionDelete(ctx context.Context, id PrivateEndpointConnectionId) (result PrivateEndpointConnectionDeleteOperationResponse, err error) { - req, err := c.preparerForPrivateEndpointConnectionDelete(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "privateendpointconnections.PrivateEndpointConnectionsClient", "PrivateEndpointConnectionDelete", nil, "Failure preparing request") - return - } - - result, err = c.senderForPrivateEndpointConnectionDelete(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "privateendpointconnections.PrivateEndpointConnectionsClient", "PrivateEndpointConnectionDelete", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// PrivateEndpointConnectionDeleteThenPoll performs PrivateEndpointConnectionDelete then polls until it's completed -func (c PrivateEndpointConnectionsClient) PrivateEndpointConnectionDeleteThenPoll(ctx context.Context, id PrivateEndpointConnectionId) error { - result, err := c.PrivateEndpointConnectionDelete(ctx, id) - if err != nil { - return fmt.Errorf("performing PrivateEndpointConnectionDelete: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after PrivateEndpointConnectionDelete: %+v", err) - } - - return nil -} - -// preparerForPrivateEndpointConnectionDelete prepares the PrivateEndpointConnectionDelete request. -func (c PrivateEndpointConnectionsClient) preparerForPrivateEndpointConnectionDelete(ctx context.Context, id PrivateEndpointConnectionId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForPrivateEndpointConnectionDelete sends the PrivateEndpointConnectionDelete request. The method will close the -// http.Response Body if it receives an error. -func (c PrivateEndpointConnectionsClient) senderForPrivateEndpointConnectionDelete(ctx context.Context, req *http.Request) (future PrivateEndpointConnectionDeleteOperationResponse, 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/apimanagement/2021-08-01/privateendpointconnections/method_privateendpointconnectiongetbyname.go b/resource-manager/apimanagement/2021-08-01/privateendpointconnections/method_privateendpointconnectiongetbyname.go new file mode 100644 index 00000000000..51d57d4f314 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/privateendpointconnections/method_privateendpointconnectiongetbyname.go @@ -0,0 +1,51 @@ +package privateendpointconnections + +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 PrivateEndpointConnectionGetByNameOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PrivateEndpointConnection +} + +// PrivateEndpointConnectionGetByName ... +func (c PrivateEndpointConnectionsClient) PrivateEndpointConnectionGetByName(ctx context.Context, id PrivateEndpointConnectionId) (result PrivateEndpointConnectionGetByNameOperationResponse, 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/apimanagement/2021-08-01/privateendpointconnections/method_privateendpointconnectiongetbyname_autorest.go b/resource-manager/apimanagement/2021-08-01/privateendpointconnections/method_privateendpointconnectiongetbyname_autorest.go deleted file mode 100644 index 88167729441..00000000000 --- a/resource-manager/apimanagement/2021-08-01/privateendpointconnections/method_privateendpointconnectiongetbyname_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package privateendpointconnections - -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 PrivateEndpointConnectionGetByNameOperationResponse struct { - HttpResponse *http.Response - Model *PrivateEndpointConnection -} - -// PrivateEndpointConnectionGetByName ... -func (c PrivateEndpointConnectionsClient) PrivateEndpointConnectionGetByName(ctx context.Context, id PrivateEndpointConnectionId) (result PrivateEndpointConnectionGetByNameOperationResponse, err error) { - req, err := c.preparerForPrivateEndpointConnectionGetByName(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "privateendpointconnections.PrivateEndpointConnectionsClient", "PrivateEndpointConnectionGetByName", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "privateendpointconnections.PrivateEndpointConnectionsClient", "PrivateEndpointConnectionGetByName", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForPrivateEndpointConnectionGetByName(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "privateendpointconnections.PrivateEndpointConnectionsClient", "PrivateEndpointConnectionGetByName", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForPrivateEndpointConnectionGetByName prepares the PrivateEndpointConnectionGetByName request. -func (c PrivateEndpointConnectionsClient) preparerForPrivateEndpointConnectionGetByName(ctx context.Context, id PrivateEndpointConnectionId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForPrivateEndpointConnectionGetByName handles the response to the PrivateEndpointConnectionGetByName request. The method always -// closes the http.Response Body. -func (c PrivateEndpointConnectionsClient) responderForPrivateEndpointConnectionGetByName(resp *http.Response) (result PrivateEndpointConnectionGetByNameOperationResponse, 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/apimanagement/2021-08-01/privateendpointconnections/method_privateendpointconnectiongetprivatelinkresource.go b/resource-manager/apimanagement/2021-08-01/privateendpointconnections/method_privateendpointconnectiongetprivatelinkresource.go new file mode 100644 index 00000000000..fd334bbacc0 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/privateendpointconnections/method_privateendpointconnectiongetprivatelinkresource.go @@ -0,0 +1,51 @@ +package privateendpointconnections + +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 PrivateEndpointConnectionGetPrivateLinkResourceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PrivateLinkResource +} + +// PrivateEndpointConnectionGetPrivateLinkResource ... +func (c PrivateEndpointConnectionsClient) PrivateEndpointConnectionGetPrivateLinkResource(ctx context.Context, id PrivateLinkResourceId) (result PrivateEndpointConnectionGetPrivateLinkResourceOperationResponse, 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/apimanagement/2021-08-01/privateendpointconnections/method_privateendpointconnectiongetprivatelinkresource_autorest.go b/resource-manager/apimanagement/2021-08-01/privateendpointconnections/method_privateendpointconnectiongetprivatelinkresource_autorest.go deleted file mode 100644 index 511f46e493e..00000000000 --- a/resource-manager/apimanagement/2021-08-01/privateendpointconnections/method_privateendpointconnectiongetprivatelinkresource_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package privateendpointconnections - -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 PrivateEndpointConnectionGetPrivateLinkResourceOperationResponse struct { - HttpResponse *http.Response - Model *PrivateLinkResource -} - -// PrivateEndpointConnectionGetPrivateLinkResource ... -func (c PrivateEndpointConnectionsClient) PrivateEndpointConnectionGetPrivateLinkResource(ctx context.Context, id PrivateLinkResourceId) (result PrivateEndpointConnectionGetPrivateLinkResourceOperationResponse, err error) { - req, err := c.preparerForPrivateEndpointConnectionGetPrivateLinkResource(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "privateendpointconnections.PrivateEndpointConnectionsClient", "PrivateEndpointConnectionGetPrivateLinkResource", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "privateendpointconnections.PrivateEndpointConnectionsClient", "PrivateEndpointConnectionGetPrivateLinkResource", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForPrivateEndpointConnectionGetPrivateLinkResource(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "privateendpointconnections.PrivateEndpointConnectionsClient", "PrivateEndpointConnectionGetPrivateLinkResource", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForPrivateEndpointConnectionGetPrivateLinkResource prepares the PrivateEndpointConnectionGetPrivateLinkResource request. -func (c PrivateEndpointConnectionsClient) preparerForPrivateEndpointConnectionGetPrivateLinkResource(ctx context.Context, id PrivateLinkResourceId) (*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)) -} - -// responderForPrivateEndpointConnectionGetPrivateLinkResource handles the response to the PrivateEndpointConnectionGetPrivateLinkResource request. The method always -// closes the http.Response Body. -func (c PrivateEndpointConnectionsClient) responderForPrivateEndpointConnectionGetPrivateLinkResource(resp *http.Response) (result PrivateEndpointConnectionGetPrivateLinkResourceOperationResponse, 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/apimanagement/2021-08-01/privateendpointconnections/method_privateendpointconnectionlistbyservice.go b/resource-manager/apimanagement/2021-08-01/privateendpointconnections/method_privateendpointconnectionlistbyservice.go new file mode 100644 index 00000000000..7ac03e3c251 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/privateendpointconnections/method_privateendpointconnectionlistbyservice.go @@ -0,0 +1,52 @@ +package privateendpointconnections + +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 PrivateEndpointConnectionListByServiceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PrivateEndpointConnectionListResult +} + +// PrivateEndpointConnectionListByService ... +func (c PrivateEndpointConnectionsClient) PrivateEndpointConnectionListByService(ctx context.Context, id ServiceId) (result PrivateEndpointConnectionListByServiceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/privateEndpointConnections", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.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/apimanagement/2021-08-01/privateendpointconnections/method_privateendpointconnectionlistbyservice_autorest.go b/resource-manager/apimanagement/2021-08-01/privateendpointconnections/method_privateendpointconnectionlistbyservice_autorest.go deleted file mode 100644 index a3878a76021..00000000000 --- a/resource-manager/apimanagement/2021-08-01/privateendpointconnections/method_privateendpointconnectionlistbyservice_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package privateendpointconnections - -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 PrivateEndpointConnectionListByServiceOperationResponse struct { - HttpResponse *http.Response - Model *PrivateEndpointConnectionListResult -} - -// PrivateEndpointConnectionListByService ... -func (c PrivateEndpointConnectionsClient) PrivateEndpointConnectionListByService(ctx context.Context, id ServiceId) (result PrivateEndpointConnectionListByServiceOperationResponse, err error) { - req, err := c.preparerForPrivateEndpointConnectionListByService(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "privateendpointconnections.PrivateEndpointConnectionsClient", "PrivateEndpointConnectionListByService", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "privateendpointconnections.PrivateEndpointConnectionsClient", "PrivateEndpointConnectionListByService", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForPrivateEndpointConnectionListByService(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "privateendpointconnections.PrivateEndpointConnectionsClient", "PrivateEndpointConnectionListByService", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForPrivateEndpointConnectionListByService prepares the PrivateEndpointConnectionListByService request. -func (c PrivateEndpointConnectionsClient) preparerForPrivateEndpointConnectionListByService(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(fmt.Sprintf("%s/privateEndpointConnections", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForPrivateEndpointConnectionListByService handles the response to the PrivateEndpointConnectionListByService request. The method always -// closes the http.Response Body. -func (c PrivateEndpointConnectionsClient) responderForPrivateEndpointConnectionListByService(resp *http.Response) (result PrivateEndpointConnectionListByServiceOperationResponse, 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/apimanagement/2021-08-01/privateendpointconnections/method_privateendpointconnectionlistprivatelinkresources.go b/resource-manager/apimanagement/2021-08-01/privateendpointconnections/method_privateendpointconnectionlistprivatelinkresources.go new file mode 100644 index 00000000000..5d2881f7c92 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/privateendpointconnections/method_privateendpointconnectionlistprivatelinkresources.go @@ -0,0 +1,52 @@ +package privateendpointconnections + +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 PrivateEndpointConnectionListPrivateLinkResourcesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PrivateLinkResourceListResult +} + +// PrivateEndpointConnectionListPrivateLinkResources ... +func (c PrivateEndpointConnectionsClient) PrivateEndpointConnectionListPrivateLinkResources(ctx context.Context, id ServiceId) (result PrivateEndpointConnectionListPrivateLinkResourcesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/privateLinkResources", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + if err = resp.Unmarshal(&result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2021-08-01/privateendpointconnections/method_privateendpointconnectionlistprivatelinkresources_autorest.go b/resource-manager/apimanagement/2021-08-01/privateendpointconnections/method_privateendpointconnectionlistprivatelinkresources_autorest.go deleted file mode 100644 index 2a3bdcb3962..00000000000 --- a/resource-manager/apimanagement/2021-08-01/privateendpointconnections/method_privateendpointconnectionlistprivatelinkresources_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package privateendpointconnections - -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 PrivateEndpointConnectionListPrivateLinkResourcesOperationResponse struct { - HttpResponse *http.Response - Model *PrivateLinkResourceListResult -} - -// PrivateEndpointConnectionListPrivateLinkResources ... -func (c PrivateEndpointConnectionsClient) PrivateEndpointConnectionListPrivateLinkResources(ctx context.Context, id ServiceId) (result PrivateEndpointConnectionListPrivateLinkResourcesOperationResponse, err error) { - req, err := c.preparerForPrivateEndpointConnectionListPrivateLinkResources(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "privateendpointconnections.PrivateEndpointConnectionsClient", "PrivateEndpointConnectionListPrivateLinkResources", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "privateendpointconnections.PrivateEndpointConnectionsClient", "PrivateEndpointConnectionListPrivateLinkResources", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForPrivateEndpointConnectionListPrivateLinkResources(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "privateendpointconnections.PrivateEndpointConnectionsClient", "PrivateEndpointConnectionListPrivateLinkResources", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForPrivateEndpointConnectionListPrivateLinkResources prepares the PrivateEndpointConnectionListPrivateLinkResources request. -func (c PrivateEndpointConnectionsClient) preparerForPrivateEndpointConnectionListPrivateLinkResources(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(fmt.Sprintf("%s/privateLinkResources", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForPrivateEndpointConnectionListPrivateLinkResources handles the response to the PrivateEndpointConnectionListPrivateLinkResources request. The method always -// closes the http.Response Body. -func (c PrivateEndpointConnectionsClient) responderForPrivateEndpointConnectionListPrivateLinkResources(resp *http.Response) (result PrivateEndpointConnectionListPrivateLinkResourcesOperationResponse, 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/apimanagement/2021-08-01/product/client.go b/resource-manager/apimanagement/2021-08-01/product/client.go index 964cb7131cc..558149db254 100644 --- a/resource-manager/apimanagement/2021-08-01/product/client.go +++ b/resource-manager/apimanagement/2021-08-01/product/client.go @@ -1,18 +1,26 @@ package product -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 ProductClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewProductClientWithBaseURI(endpoint string) ProductClient { - return ProductClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewProductClientWithBaseURI(api environments.Api) (*ProductClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "product", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ProductClient: %+v", err) } + + return &ProductClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2021-08-01/product/constants.go b/resource-manager/apimanagement/2021-08-01/product/constants.go index d9ad59725fd..b1aa827fdb2 100644 --- a/resource-manager/apimanagement/2021-08-01/product/constants.go +++ b/resource-manager/apimanagement/2021-08-01/product/constants.go @@ -1,6 +1,10 @@ package product -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 PossibleValuesForProductState() []string { } } +func (s *ProductState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProductState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseProductState(input string) (*ProductState, error) { vals := map[string]ProductState{ "notpublished": ProductStateNotPublished, diff --git a/resource-manager/apimanagement/2021-08-01/product/method_createorupdate.go b/resource-manager/apimanagement/2021-08-01/product/method_createorupdate.go new file mode 100644 index 00000000000..dc69508e31c --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/product/method_createorupdate.go @@ -0,0 +1,85 @@ +package product + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ProductContract +} + +type CreateOrUpdateOperationOptions struct { + IfMatch *string +} + +func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { + return CreateOrUpdateOperationOptions{} +} + +func (o CreateOrUpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o CreateOrUpdateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o CreateOrUpdateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// CreateOrUpdate ... +func (c ProductClient) CreateOrUpdate(ctx context.Context, id ProductId, input ProductContract, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + OptionsObject: options, + } + + 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/apimanagement/2021-08-01/product/method_createorupdate_autorest.go b/resource-manager/apimanagement/2021-08-01/product/method_createorupdate_autorest.go deleted file mode 100644 index 22bfb9119bf..00000000000 --- a/resource-manager/apimanagement/2021-08-01/product/method_createorupdate_autorest.go +++ /dev/null @@ -1,98 +0,0 @@ -package product - -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 *ProductContract -} - -type CreateOrUpdateOperationOptions struct { - IfMatch *string -} - -func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { - return CreateOrUpdateOperationOptions{} -} - -func (o CreateOrUpdateOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o CreateOrUpdateOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// CreateOrUpdate ... -func (c ProductClient) CreateOrUpdate(ctx context.Context, id ProductId, input ProductContract, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdate(ctx, id, input, options) - if err != nil { - err = autorest.NewErrorWithError(err, "product.ProductClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "product.ProductClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCreateOrUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "product.ProductClient", "CreateOrUpdate", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCreateOrUpdate prepares the CreateOrUpdate request. -func (c ProductClient) preparerForCreateOrUpdate(ctx context.Context, id ProductId, input ProductContract, options CreateOrUpdateOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - 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 ProductClient) responderForCreateOrUpdate(resp *http.Response) (result CreateOrUpdateOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2021-08-01/product/method_delete.go b/resource-manager/apimanagement/2021-08-01/product/method_delete.go new file mode 100644 index 00000000000..a2aebab1182 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/product/method_delete.go @@ -0,0 +1,79 @@ +package product + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +type DeleteOperationOptions struct { + DeleteSubscriptions *bool + IfMatch *string +} + +func DefaultDeleteOperationOptions() DeleteOperationOptions { + return DeleteOperationOptions{} +} + +func (o DeleteOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o DeleteOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o DeleteOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.DeleteSubscriptions != nil { + out.Append("deleteSubscriptions", fmt.Sprintf("%v", *o.DeleteSubscriptions)) + } + return &out +} + +// Delete ... +func (c ProductClient) Delete(ctx context.Context, id ProductId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2021-08-01/product/method_delete_autorest.go b/resource-manager/apimanagement/2021-08-01/product/method_delete_autorest.go deleted file mode 100644 index 6646be8a32f..00000000000 --- a/resource-manager/apimanagement/2021-08-01/product/method_delete_autorest.go +++ /dev/null @@ -1,100 +0,0 @@ -package product - -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 DeleteOperationResponse struct { - HttpResponse *http.Response -} - -type DeleteOperationOptions struct { - DeleteSubscriptions *bool - IfMatch *string -} - -func DefaultDeleteOperationOptions() DeleteOperationOptions { - return DeleteOperationOptions{} -} - -func (o DeleteOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o DeleteOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.DeleteSubscriptions != nil { - out["deleteSubscriptions"] = *o.DeleteSubscriptions - } - - return out -} - -// Delete ... -func (c ProductClient) Delete(ctx context.Context, id ProductId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { - req, err := c.preparerForDelete(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "product.ProductClient", "Delete", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "product.ProductClient", "Delete", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForDelete(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "product.ProductClient", "Delete", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForDelete prepares the Delete request. -func (c ProductClient) preparerForDelete(ctx context.Context, id ProductId, options DeleteOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForDelete handles the response to the Delete request. The method always -// closes the http.Response Body. -func (c ProductClient) responderForDelete(resp *http.Response) (result DeleteOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2021-08-01/product/method_get.go b/resource-manager/apimanagement/2021-08-01/product/method_get.go new file mode 100644 index 00000000000..41152aebc0a --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/product/method_get.go @@ -0,0 +1,51 @@ +package product + +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 *ProductContract +} + +// Get ... +func (c ProductClient) Get(ctx context.Context, id ProductId) (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/apimanagement/2021-08-01/product/method_get_autorest.go b/resource-manager/apimanagement/2021-08-01/product/method_get_autorest.go deleted file mode 100644 index 42680f3af9f..00000000000 --- a/resource-manager/apimanagement/2021-08-01/product/method_get_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package product - -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 *ProductContract -} - -// Get ... -func (c ProductClient) Get(ctx context.Context, id ProductId) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "product.ProductClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "product.ProductClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "product.ProductClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c ProductClient) preparerForGet(ctx context.Context, id ProductId) (*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 ProductClient) 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/apimanagement/2021-08-01/product/method_getentitytag.go b/resource-manager/apimanagement/2021-08-01/product/method_getentitytag.go new file mode 100644 index 00000000000..667f4afad59 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/product/method_getentitytag.go @@ -0,0 +1,46 @@ +package product + +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 GetEntityTagOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// GetEntityTag ... +func (c ProductClient) GetEntityTag(ctx context.Context, id ProductId) (result GetEntityTagOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodHead, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2021-08-01/product/method_getentitytag_autorest.go b/resource-manager/apimanagement/2021-08-01/product/method_getentitytag_autorest.go deleted file mode 100644 index b25eb533c2c..00000000000 --- a/resource-manager/apimanagement/2021-08-01/product/method_getentitytag_autorest.go +++ /dev/null @@ -1,66 +0,0 @@ -package product - -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 GetEntityTagOperationResponse struct { - HttpResponse *http.Response -} - -// GetEntityTag ... -func (c ProductClient) GetEntityTag(ctx context.Context, id ProductId) (result GetEntityTagOperationResponse, err error) { - req, err := c.preparerForGetEntityTag(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "product.ProductClient", "GetEntityTag", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "product.ProductClient", "GetEntityTag", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetEntityTag(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "product.ProductClient", "GetEntityTag", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetEntityTag prepares the GetEntityTag request. -func (c ProductClient) preparerForGetEntityTag(ctx context.Context, id ProductId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsHead(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetEntityTag handles the response to the GetEntityTag request. The method always -// closes the http.Response Body. -func (c ProductClient) responderForGetEntityTag(resp *http.Response) (result GetEntityTagOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2021-08-01/product/method_listbyservice.go b/resource-manager/apimanagement/2021-08-01/product/method_listbyservice.go new file mode 100644 index 00000000000..66a835096aa --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/product/method_listbyservice.go @@ -0,0 +1,133 @@ +package product + +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 ListByServiceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ProductContract +} + +type ListByServiceCompleteResult struct { + Items []ProductContract +} + +type ListByServiceOperationOptions struct { + ExpandGroups *bool + Filter *string + Skip *int64 + Tags *string + Top *int64 +} + +func DefaultListByServiceOperationOptions() ListByServiceOperationOptions { + return ListByServiceOperationOptions{} +} + +func (o ListByServiceOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListByServiceOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListByServiceOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.ExpandGroups != nil { + out.Append("expandGroups", fmt.Sprintf("%v", *o.ExpandGroups)) + } + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.Skip != nil { + out.Append("$skip", fmt.Sprintf("%v", *o.Skip)) + } + if o.Tags != nil { + out.Append("tags", fmt.Sprintf("%v", *o.Tags)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +// ListByService ... +func (c ProductClient) ListByService(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (result ListByServiceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/products", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ProductContract `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByServiceComplete retrieves all the results into a single object +func (c ProductClient) ListByServiceComplete(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (ListByServiceCompleteResult, error) { + return c.ListByServiceCompleteMatchingPredicate(ctx, id, options, ProductContractOperationPredicate{}) +} + +// ListByServiceCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ProductClient) ListByServiceCompleteMatchingPredicate(ctx context.Context, id ServiceId, options ListByServiceOperationOptions, predicate ProductContractOperationPredicate) (result ListByServiceCompleteResult, err error) { + items := make([]ProductContract, 0) + + resp, err := c.ListByService(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByServiceCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/apimanagement/2021-08-01/product/method_listbyservice_autorest.go b/resource-manager/apimanagement/2021-08-01/product/method_listbyservice_autorest.go deleted file mode 100644 index 5187a25caa7..00000000000 --- a/resource-manager/apimanagement/2021-08-01/product/method_listbyservice_autorest.go +++ /dev/null @@ -1,235 +0,0 @@ -package product - -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 ListByServiceOperationResponse struct { - HttpResponse *http.Response - Model *[]ProductContract - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListByServiceOperationResponse, error) -} - -type ListByServiceCompleteResult struct { - Items []ProductContract -} - -func (r ListByServiceOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListByServiceOperationResponse) LoadMore(ctx context.Context) (resp ListByServiceOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -type ListByServiceOperationOptions struct { - ExpandGroups *bool - Filter *string - Skip *int64 - Tags *string - Top *int64 -} - -func DefaultListByServiceOperationOptions() ListByServiceOperationOptions { - return ListByServiceOperationOptions{} -} - -func (o ListByServiceOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o ListByServiceOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.ExpandGroups != nil { - out["expandGroups"] = *o.ExpandGroups - } - - if o.Filter != nil { - out["$filter"] = *o.Filter - } - - if o.Skip != nil { - out["$skip"] = *o.Skip - } - - if o.Tags != nil { - out["tags"] = *o.Tags - } - - if o.Top != nil { - out["$top"] = *o.Top - } - - return out -} - -// ListByService ... -func (c ProductClient) ListByService(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (resp ListByServiceOperationResponse, err error) { - req, err := c.preparerForListByService(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "product.ProductClient", "ListByService", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "product.ProductClient", "ListByService", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListByService(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "product.ProductClient", "ListByService", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListByService prepares the ListByService request. -func (c ProductClient) preparerForListByService(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/products", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListByServiceWithNextLink prepares the ListByService request with the given nextLink token. -func (c ProductClient) preparerForListByServiceWithNextLink(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)) -} - -// responderForListByService handles the response to the ListByService request. The method always -// closes the http.Response Body. -func (c ProductClient) responderForListByService(resp *http.Response) (result ListByServiceOperationResponse, err error) { - type page struct { - Values []ProductContract `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 ListByServiceOperationResponse, err error) { - req, err := c.preparerForListByServiceWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "product.ProductClient", "ListByService", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "product.ProductClient", "ListByService", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByService(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "product.ProductClient", "ListByService", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListByServiceComplete retrieves all of the results into a single object -func (c ProductClient) ListByServiceComplete(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (ListByServiceCompleteResult, error) { - return c.ListByServiceCompleteMatchingPredicate(ctx, id, options, ProductContractOperationPredicate{}) -} - -// ListByServiceCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c ProductClient) ListByServiceCompleteMatchingPredicate(ctx context.Context, id ServiceId, options ListByServiceOperationOptions, predicate ProductContractOperationPredicate) (resp ListByServiceCompleteResult, err error) { - items := make([]ProductContract, 0) - - page, err := c.ListByService(ctx, id, options) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListByServiceCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/apimanagement/2021-08-01/product/method_update.go b/resource-manager/apimanagement/2021-08-01/product/method_update.go new file mode 100644 index 00000000000..a9a59bd595e --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/product/method_update.go @@ -0,0 +1,84 @@ +package product + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ProductContract +} + +type UpdateOperationOptions struct { + IfMatch *string +} + +func DefaultUpdateOperationOptions() UpdateOperationOptions { + return UpdateOperationOptions{} +} + +func (o UpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o UpdateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o UpdateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// Update ... +func (c ProductClient) Update(ctx context.Context, id ProductId, input ProductUpdateParameters, options UpdateOperationOptions) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + OptionsObject: options, + } + + 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/apimanagement/2021-08-01/product/method_update_autorest.go b/resource-manager/apimanagement/2021-08-01/product/method_update_autorest.go deleted file mode 100644 index d0fbe1007f8..00000000000 --- a/resource-manager/apimanagement/2021-08-01/product/method_update_autorest.go +++ /dev/null @@ -1,98 +0,0 @@ -package product - -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 *ProductContract -} - -type UpdateOperationOptions struct { - IfMatch *string -} - -func DefaultUpdateOperationOptions() UpdateOperationOptions { - return UpdateOperationOptions{} -} - -func (o UpdateOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o UpdateOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// Update ... -func (c ProductClient) Update(ctx context.Context, id ProductId, input ProductUpdateParameters, options UpdateOperationOptions) (result UpdateOperationResponse, err error) { - req, err := c.preparerForUpdate(ctx, id, input, options) - if err != nil { - err = autorest.NewErrorWithError(err, "product.ProductClient", "Update", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "product.ProductClient", "Update", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "product.ProductClient", "Update", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForUpdate prepares the Update request. -func (c ProductClient) preparerForUpdate(ctx context.Context, id ProductId, input ProductUpdateParameters, options UpdateOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPatch(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - 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 ProductClient) 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/apimanagement/2021-08-01/productapi/client.go b/resource-manager/apimanagement/2021-08-01/productapi/client.go index 5241293a527..1498ceafe98 100644 --- a/resource-manager/apimanagement/2021-08-01/productapi/client.go +++ b/resource-manager/apimanagement/2021-08-01/productapi/client.go @@ -1,18 +1,26 @@ package productapi -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 ProductApiClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewProductApiClientWithBaseURI(endpoint string) ProductApiClient { - return ProductApiClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewProductApiClientWithBaseURI(api environments.Api) (*ProductApiClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "productapi", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ProductApiClient: %+v", err) } + + return &ProductApiClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2021-08-01/productapi/constants.go b/resource-manager/apimanagement/2021-08-01/productapi/constants.go index 0b289271d26..a2efe7f0641 100644 --- a/resource-manager/apimanagement/2021-08-01/productapi/constants.go +++ b/resource-manager/apimanagement/2021-08-01/productapi/constants.go @@ -1,6 +1,10 @@ package productapi -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 PossibleValuesForApiType() []string { } } +func (s *ApiType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseApiType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseApiType(input string) (*ApiType, error) { vals := map[string]ApiType{ "graphql": ApiTypeGraphql, @@ -53,6 +70,19 @@ func PossibleValuesForBearerTokenSendingMethods() []string { } } +func (s *BearerTokenSendingMethods) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseBearerTokenSendingMethods(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseBearerTokenSendingMethods(input string) (*BearerTokenSendingMethods, error) { vals := map[string]BearerTokenSendingMethods{ "authorizationheader": BearerTokenSendingMethodsAuthorizationHeader, @@ -85,6 +115,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{ "http": ProtocolHTTP, @@ -117,6 +160,19 @@ func PossibleValuesForVersioningScheme() []string { } } +func (s *VersioningScheme) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseVersioningScheme(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseVersioningScheme(input string) (*VersioningScheme, error) { vals := map[string]VersioningScheme{ "header": VersioningSchemeHeader, diff --git a/resource-manager/apimanagement/2021-08-01/productapi/method_checkentityexists.go b/resource-manager/apimanagement/2021-08-01/productapi/method_checkentityexists.go new file mode 100644 index 00000000000..69d91adfcef --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/productapi/method_checkentityexists.go @@ -0,0 +1,46 @@ +package productapi + +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 CheckEntityExistsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// CheckEntityExists ... +func (c ProductApiClient) CheckEntityExists(ctx context.Context, id ProductApiId) (result CheckEntityExistsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: http.MethodHead, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2021-08-01/productapi/method_checkentityexists_autorest.go b/resource-manager/apimanagement/2021-08-01/productapi/method_checkentityexists_autorest.go deleted file mode 100644 index 37008921ef3..00000000000 --- a/resource-manager/apimanagement/2021-08-01/productapi/method_checkentityexists_autorest.go +++ /dev/null @@ -1,66 +0,0 @@ -package productapi - -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 CheckEntityExistsOperationResponse struct { - HttpResponse *http.Response -} - -// CheckEntityExists ... -func (c ProductApiClient) CheckEntityExists(ctx context.Context, id ProductApiId) (result CheckEntityExistsOperationResponse, err error) { - req, err := c.preparerForCheckEntityExists(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "productapi.ProductApiClient", "CheckEntityExists", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "productapi.ProductApiClient", "CheckEntityExists", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCheckEntityExists(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "productapi.ProductApiClient", "CheckEntityExists", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCheckEntityExists prepares the CheckEntityExists request. -func (c ProductApiClient) preparerForCheckEntityExists(ctx context.Context, id ProductApiId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsHead(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForCheckEntityExists handles the response to the CheckEntityExists request. The method always -// closes the http.Response Body. -func (c ProductApiClient) responderForCheckEntityExists(resp *http.Response) (result CheckEntityExistsOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2021-08-01/productapi/method_createorupdate.go b/resource-manager/apimanagement/2021-08-01/productapi/method_createorupdate.go new file mode 100644 index 00000000000..cfa64d59695 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/productapi/method_createorupdate.go @@ -0,0 +1,52 @@ +package productapi + +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 *ApiContract +} + +// CreateOrUpdate ... +func (c ProductApiClient) CreateOrUpdate(ctx context.Context, id ProductApiId) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + 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/apimanagement/2021-08-01/productapi/method_createorupdate_autorest.go b/resource-manager/apimanagement/2021-08-01/productapi/method_createorupdate_autorest.go deleted file mode 100644 index 1df50bc936d..00000000000 --- a/resource-manager/apimanagement/2021-08-01/productapi/method_createorupdate_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package productapi - -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 *ApiContract -} - -// CreateOrUpdate ... -func (c ProductApiClient) CreateOrUpdate(ctx context.Context, id ProductApiId) (result CreateOrUpdateOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdate(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "productapi.ProductApiClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "productapi.ProductApiClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCreateOrUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "productapi.ProductApiClient", "CreateOrUpdate", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCreateOrUpdate prepares the CreateOrUpdate request. -func (c ProductApiClient) preparerForCreateOrUpdate(ctx context.Context, id ProductApiId) (*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.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 ProductApiClient) responderForCreateOrUpdate(resp *http.Response) (result CreateOrUpdateOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2021-08-01/productapi/method_delete.go b/resource-manager/apimanagement/2021-08-01/productapi/method_delete.go new file mode 100644 index 00000000000..da188ce2e72 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/productapi/method_delete.go @@ -0,0 +1,47 @@ +package productapi + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c ProductApiClient) Delete(ctx context.Context, id ProductApiId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2021-08-01/productapi/method_delete_autorest.go b/resource-manager/apimanagement/2021-08-01/productapi/method_delete_autorest.go deleted file mode 100644 index b31ea2b6eef..00000000000 --- a/resource-manager/apimanagement/2021-08-01/productapi/method_delete_autorest.go +++ /dev/null @@ -1,66 +0,0 @@ -package productapi - -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 DeleteOperationResponse struct { - HttpResponse *http.Response -} - -// Delete ... -func (c ProductApiClient) Delete(ctx context.Context, id ProductApiId) (result DeleteOperationResponse, err error) { - req, err := c.preparerForDelete(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "productapi.ProductApiClient", "Delete", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "productapi.ProductApiClient", "Delete", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForDelete(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "productapi.ProductApiClient", "Delete", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForDelete prepares the Delete request. -func (c ProductApiClient) preparerForDelete(ctx context.Context, id ProductApiId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForDelete handles the response to the Delete request. The method always -// closes the http.Response Body. -func (c ProductApiClient) responderForDelete(resp *http.Response) (result DeleteOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2021-08-01/productapi/method_listbyproduct.go b/resource-manager/apimanagement/2021-08-01/productapi/method_listbyproduct.go new file mode 100644 index 00000000000..fbe56652d12 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/productapi/method_listbyproduct.go @@ -0,0 +1,125 @@ +package productapi + +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 ListByProductOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ApiContract +} + +type ListByProductCompleteResult struct { + Items []ApiContract +} + +type ListByProductOperationOptions struct { + Filter *string + Skip *int64 + Top *int64 +} + +func DefaultListByProductOperationOptions() ListByProductOperationOptions { + return ListByProductOperationOptions{} +} + +func (o ListByProductOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListByProductOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListByProductOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.Skip != nil { + out.Append("$skip", fmt.Sprintf("%v", *o.Skip)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +// ListByProduct ... +func (c ProductApiClient) ListByProduct(ctx context.Context, id ProductId, options ListByProductOperationOptions) (result ListByProductOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/apis", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ApiContract `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByProductComplete retrieves all the results into a single object +func (c ProductApiClient) ListByProductComplete(ctx context.Context, id ProductId, options ListByProductOperationOptions) (ListByProductCompleteResult, error) { + return c.ListByProductCompleteMatchingPredicate(ctx, id, options, ApiContractOperationPredicate{}) +} + +// ListByProductCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ProductApiClient) ListByProductCompleteMatchingPredicate(ctx context.Context, id ProductId, options ListByProductOperationOptions, predicate ApiContractOperationPredicate) (result ListByProductCompleteResult, err error) { + items := make([]ApiContract, 0) + + resp, err := c.ListByProduct(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByProductCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/apimanagement/2021-08-01/productapi/method_listbyproduct_autorest.go b/resource-manager/apimanagement/2021-08-01/productapi/method_listbyproduct_autorest.go deleted file mode 100644 index 5a0bdb0c971..00000000000 --- a/resource-manager/apimanagement/2021-08-01/productapi/method_listbyproduct_autorest.go +++ /dev/null @@ -1,225 +0,0 @@ -package productapi - -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 ListByProductOperationResponse struct { - HttpResponse *http.Response - Model *[]ApiContract - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListByProductOperationResponse, error) -} - -type ListByProductCompleteResult struct { - Items []ApiContract -} - -func (r ListByProductOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListByProductOperationResponse) LoadMore(ctx context.Context) (resp ListByProductOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -type ListByProductOperationOptions struct { - Filter *string - Skip *int64 - Top *int64 -} - -func DefaultListByProductOperationOptions() ListByProductOperationOptions { - return ListByProductOperationOptions{} -} - -func (o ListByProductOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o ListByProductOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Filter != nil { - out["$filter"] = *o.Filter - } - - if o.Skip != nil { - out["$skip"] = *o.Skip - } - - if o.Top != nil { - out["$top"] = *o.Top - } - - return out -} - -// ListByProduct ... -func (c ProductApiClient) ListByProduct(ctx context.Context, id ProductId, options ListByProductOperationOptions) (resp ListByProductOperationResponse, err error) { - req, err := c.preparerForListByProduct(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "productapi.ProductApiClient", "ListByProduct", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "productapi.ProductApiClient", "ListByProduct", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListByProduct(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "productapi.ProductApiClient", "ListByProduct", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListByProduct prepares the ListByProduct request. -func (c ProductApiClient) preparerForListByProduct(ctx context.Context, id ProductId, options ListByProductOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/apis", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListByProductWithNextLink prepares the ListByProduct request with the given nextLink token. -func (c ProductApiClient) preparerForListByProductWithNextLink(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)) -} - -// responderForListByProduct handles the response to the ListByProduct request. The method always -// closes the http.Response Body. -func (c ProductApiClient) responderForListByProduct(resp *http.Response) (result ListByProductOperationResponse, err error) { - type page struct { - Values []ApiContract `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 ListByProductOperationResponse, err error) { - req, err := c.preparerForListByProductWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "productapi.ProductApiClient", "ListByProduct", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "productapi.ProductApiClient", "ListByProduct", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByProduct(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "productapi.ProductApiClient", "ListByProduct", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListByProductComplete retrieves all of the results into a single object -func (c ProductApiClient) ListByProductComplete(ctx context.Context, id ProductId, options ListByProductOperationOptions) (ListByProductCompleteResult, error) { - return c.ListByProductCompleteMatchingPredicate(ctx, id, options, ApiContractOperationPredicate{}) -} - -// ListByProductCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c ProductApiClient) ListByProductCompleteMatchingPredicate(ctx context.Context, id ProductId, options ListByProductOperationOptions, predicate ApiContractOperationPredicate) (resp ListByProductCompleteResult, err error) { - items := make([]ApiContract, 0) - - page, err := c.ListByProduct(ctx, id, options) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListByProductCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/apimanagement/2021-08-01/productgroup/client.go b/resource-manager/apimanagement/2021-08-01/productgroup/client.go index 08ea091f6e7..6d12fafe195 100644 --- a/resource-manager/apimanagement/2021-08-01/productgroup/client.go +++ b/resource-manager/apimanagement/2021-08-01/productgroup/client.go @@ -1,18 +1,26 @@ package productgroup -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 ProductGroupClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewProductGroupClientWithBaseURI(endpoint string) ProductGroupClient { - return ProductGroupClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewProductGroupClientWithBaseURI(api environments.Api) (*ProductGroupClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "productgroup", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ProductGroupClient: %+v", err) } + + return &ProductGroupClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2021-08-01/productgroup/constants.go b/resource-manager/apimanagement/2021-08-01/productgroup/constants.go index 07ce1de89e9..6ff85f660bd 100644 --- a/resource-manager/apimanagement/2021-08-01/productgroup/constants.go +++ b/resource-manager/apimanagement/2021-08-01/productgroup/constants.go @@ -1,6 +1,10 @@ package productgroup -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 PossibleValuesForGroupType() []string { } } +func (s *GroupType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseGroupType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseGroupType(input string) (*GroupType, error) { vals := map[string]GroupType{ "custom": GroupTypeCustom, diff --git a/resource-manager/apimanagement/2021-08-01/productgroup/method_checkentityexists.go b/resource-manager/apimanagement/2021-08-01/productgroup/method_checkentityexists.go new file mode 100644 index 00000000000..fd90f4c41cf --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/productgroup/method_checkentityexists.go @@ -0,0 +1,46 @@ +package productgroup + +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 CheckEntityExistsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// CheckEntityExists ... +func (c ProductGroupClient) CheckEntityExists(ctx context.Context, id ProductGroupId) (result CheckEntityExistsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: http.MethodHead, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2021-08-01/productgroup/method_checkentityexists_autorest.go b/resource-manager/apimanagement/2021-08-01/productgroup/method_checkentityexists_autorest.go deleted file mode 100644 index 034a222674f..00000000000 --- a/resource-manager/apimanagement/2021-08-01/productgroup/method_checkentityexists_autorest.go +++ /dev/null @@ -1,66 +0,0 @@ -package productgroup - -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 CheckEntityExistsOperationResponse struct { - HttpResponse *http.Response -} - -// CheckEntityExists ... -func (c ProductGroupClient) CheckEntityExists(ctx context.Context, id ProductGroupId) (result CheckEntityExistsOperationResponse, err error) { - req, err := c.preparerForCheckEntityExists(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "productgroup.ProductGroupClient", "CheckEntityExists", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "productgroup.ProductGroupClient", "CheckEntityExists", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCheckEntityExists(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "productgroup.ProductGroupClient", "CheckEntityExists", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCheckEntityExists prepares the CheckEntityExists request. -func (c ProductGroupClient) preparerForCheckEntityExists(ctx context.Context, id ProductGroupId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsHead(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForCheckEntityExists handles the response to the CheckEntityExists request. The method always -// closes the http.Response Body. -func (c ProductGroupClient) responderForCheckEntityExists(resp *http.Response) (result CheckEntityExistsOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2021-08-01/productgroup/method_createorupdate.go b/resource-manager/apimanagement/2021-08-01/productgroup/method_createorupdate.go new file mode 100644 index 00000000000..20656a3ff19 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/productgroup/method_createorupdate.go @@ -0,0 +1,52 @@ +package productgroup + +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 *GroupContract +} + +// CreateOrUpdate ... +func (c ProductGroupClient) CreateOrUpdate(ctx context.Context, id ProductGroupId) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + 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/apimanagement/2021-08-01/productgroup/method_createorupdate_autorest.go b/resource-manager/apimanagement/2021-08-01/productgroup/method_createorupdate_autorest.go deleted file mode 100644 index 578f327aa82..00000000000 --- a/resource-manager/apimanagement/2021-08-01/productgroup/method_createorupdate_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package productgroup - -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 *GroupContract -} - -// CreateOrUpdate ... -func (c ProductGroupClient) CreateOrUpdate(ctx context.Context, id ProductGroupId) (result CreateOrUpdateOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdate(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "productgroup.ProductGroupClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "productgroup.ProductGroupClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCreateOrUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "productgroup.ProductGroupClient", "CreateOrUpdate", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCreateOrUpdate prepares the CreateOrUpdate request. -func (c ProductGroupClient) preparerForCreateOrUpdate(ctx context.Context, id ProductGroupId) (*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.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 ProductGroupClient) responderForCreateOrUpdate(resp *http.Response) (result CreateOrUpdateOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2021-08-01/productgroup/method_delete.go b/resource-manager/apimanagement/2021-08-01/productgroup/method_delete.go new file mode 100644 index 00000000000..3f6b1c8820e --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/productgroup/method_delete.go @@ -0,0 +1,47 @@ +package productgroup + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c ProductGroupClient) Delete(ctx context.Context, id ProductGroupId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2021-08-01/productgroup/method_delete_autorest.go b/resource-manager/apimanagement/2021-08-01/productgroup/method_delete_autorest.go deleted file mode 100644 index 0bc4bd9be4c..00000000000 --- a/resource-manager/apimanagement/2021-08-01/productgroup/method_delete_autorest.go +++ /dev/null @@ -1,66 +0,0 @@ -package productgroup - -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 DeleteOperationResponse struct { - HttpResponse *http.Response -} - -// Delete ... -func (c ProductGroupClient) Delete(ctx context.Context, id ProductGroupId) (result DeleteOperationResponse, err error) { - req, err := c.preparerForDelete(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "productgroup.ProductGroupClient", "Delete", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "productgroup.ProductGroupClient", "Delete", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForDelete(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "productgroup.ProductGroupClient", "Delete", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForDelete prepares the Delete request. -func (c ProductGroupClient) preparerForDelete(ctx context.Context, id ProductGroupId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForDelete handles the response to the Delete request. The method always -// closes the http.Response Body. -func (c ProductGroupClient) responderForDelete(resp *http.Response) (result DeleteOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2021-08-01/productgroup/method_listbyproduct.go b/resource-manager/apimanagement/2021-08-01/productgroup/method_listbyproduct.go new file mode 100644 index 00000000000..483d84c6da7 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/productgroup/method_listbyproduct.go @@ -0,0 +1,125 @@ +package productgroup + +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 ListByProductOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]GroupContract +} + +type ListByProductCompleteResult struct { + Items []GroupContract +} + +type ListByProductOperationOptions struct { + Filter *string + Skip *int64 + Top *int64 +} + +func DefaultListByProductOperationOptions() ListByProductOperationOptions { + return ListByProductOperationOptions{} +} + +func (o ListByProductOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListByProductOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListByProductOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.Skip != nil { + out.Append("$skip", fmt.Sprintf("%v", *o.Skip)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +// ListByProduct ... +func (c ProductGroupClient) ListByProduct(ctx context.Context, id ProductId, options ListByProductOperationOptions) (result ListByProductOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/groups", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]GroupContract `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByProductComplete retrieves all the results into a single object +func (c ProductGroupClient) ListByProductComplete(ctx context.Context, id ProductId, options ListByProductOperationOptions) (ListByProductCompleteResult, error) { + return c.ListByProductCompleteMatchingPredicate(ctx, id, options, GroupContractOperationPredicate{}) +} + +// ListByProductCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ProductGroupClient) ListByProductCompleteMatchingPredicate(ctx context.Context, id ProductId, options ListByProductOperationOptions, predicate GroupContractOperationPredicate) (result ListByProductCompleteResult, err error) { + items := make([]GroupContract, 0) + + resp, err := c.ListByProduct(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByProductCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/apimanagement/2021-08-01/productgroup/method_listbyproduct_autorest.go b/resource-manager/apimanagement/2021-08-01/productgroup/method_listbyproduct_autorest.go deleted file mode 100644 index f5f186c5b31..00000000000 --- a/resource-manager/apimanagement/2021-08-01/productgroup/method_listbyproduct_autorest.go +++ /dev/null @@ -1,225 +0,0 @@ -package productgroup - -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 ListByProductOperationResponse struct { - HttpResponse *http.Response - Model *[]GroupContract - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListByProductOperationResponse, error) -} - -type ListByProductCompleteResult struct { - Items []GroupContract -} - -func (r ListByProductOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListByProductOperationResponse) LoadMore(ctx context.Context) (resp ListByProductOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -type ListByProductOperationOptions struct { - Filter *string - Skip *int64 - Top *int64 -} - -func DefaultListByProductOperationOptions() ListByProductOperationOptions { - return ListByProductOperationOptions{} -} - -func (o ListByProductOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o ListByProductOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Filter != nil { - out["$filter"] = *o.Filter - } - - if o.Skip != nil { - out["$skip"] = *o.Skip - } - - if o.Top != nil { - out["$top"] = *o.Top - } - - return out -} - -// ListByProduct ... -func (c ProductGroupClient) ListByProduct(ctx context.Context, id ProductId, options ListByProductOperationOptions) (resp ListByProductOperationResponse, err error) { - req, err := c.preparerForListByProduct(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "productgroup.ProductGroupClient", "ListByProduct", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "productgroup.ProductGroupClient", "ListByProduct", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListByProduct(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "productgroup.ProductGroupClient", "ListByProduct", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListByProduct prepares the ListByProduct request. -func (c ProductGroupClient) preparerForListByProduct(ctx context.Context, id ProductId, options ListByProductOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/groups", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListByProductWithNextLink prepares the ListByProduct request with the given nextLink token. -func (c ProductGroupClient) preparerForListByProductWithNextLink(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)) -} - -// responderForListByProduct handles the response to the ListByProduct request. The method always -// closes the http.Response Body. -func (c ProductGroupClient) responderForListByProduct(resp *http.Response) (result ListByProductOperationResponse, err error) { - type page struct { - Values []GroupContract `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 ListByProductOperationResponse, err error) { - req, err := c.preparerForListByProductWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "productgroup.ProductGroupClient", "ListByProduct", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "productgroup.ProductGroupClient", "ListByProduct", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByProduct(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "productgroup.ProductGroupClient", "ListByProduct", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListByProductComplete retrieves all of the results into a single object -func (c ProductGroupClient) ListByProductComplete(ctx context.Context, id ProductId, options ListByProductOperationOptions) (ListByProductCompleteResult, error) { - return c.ListByProductCompleteMatchingPredicate(ctx, id, options, GroupContractOperationPredicate{}) -} - -// ListByProductCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c ProductGroupClient) ListByProductCompleteMatchingPredicate(ctx context.Context, id ProductId, options ListByProductOperationOptions, predicate GroupContractOperationPredicate) (resp ListByProductCompleteResult, err error) { - items := make([]GroupContract, 0) - - page, err := c.ListByProduct(ctx, id, options) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListByProductCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/apimanagement/2021-08-01/productpolicy/client.go b/resource-manager/apimanagement/2021-08-01/productpolicy/client.go index dfce4d67a5d..406874ed741 100644 --- a/resource-manager/apimanagement/2021-08-01/productpolicy/client.go +++ b/resource-manager/apimanagement/2021-08-01/productpolicy/client.go @@ -1,18 +1,26 @@ package productpolicy -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 ProductPolicyClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewProductPolicyClientWithBaseURI(endpoint string) ProductPolicyClient { - return ProductPolicyClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewProductPolicyClientWithBaseURI(api environments.Api) (*ProductPolicyClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "productpolicy", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ProductPolicyClient: %+v", err) } + + return &ProductPolicyClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2021-08-01/productpolicy/constants.go b/resource-manager/apimanagement/2021-08-01/productpolicy/constants.go index 9408a1eb3a8..196b57d596f 100644 --- a/resource-manager/apimanagement/2021-08-01/productpolicy/constants.go +++ b/resource-manager/apimanagement/2021-08-01/productpolicy/constants.go @@ -1,6 +1,10 @@ package productpolicy -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 PossibleValuesForPolicyContentFormat() []string { } } +func (s *PolicyContentFormat) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePolicyContentFormat(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parsePolicyContentFormat(input string) (*PolicyContentFormat, error) { vals := map[string]PolicyContentFormat{ "rawxml": PolicyContentFormatRawxml, @@ -53,6 +70,19 @@ func PossibleValuesForPolicyExportFormat() []string { } } +func (s *PolicyExportFormat) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePolicyExportFormat(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parsePolicyExportFormat(input string) (*PolicyExportFormat, error) { vals := map[string]PolicyExportFormat{ "rawxml": PolicyExportFormatRawxml, diff --git a/resource-manager/apimanagement/2021-08-01/productpolicy/method_createorupdate.go b/resource-manager/apimanagement/2021-08-01/productpolicy/method_createorupdate.go new file mode 100644 index 00000000000..0471e0e461f --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/productpolicy/method_createorupdate.go @@ -0,0 +1,85 @@ +package productpolicy + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PolicyContract +} + +type CreateOrUpdateOperationOptions struct { + IfMatch *string +} + +func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { + return CreateOrUpdateOperationOptions{} +} + +func (o CreateOrUpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o CreateOrUpdateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o CreateOrUpdateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// CreateOrUpdate ... +func (c ProductPolicyClient) CreateOrUpdate(ctx context.Context, id ProductId, input PolicyContract, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/policies/policy", id.ID()), + OptionsObject: options, + } + + 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/apimanagement/2021-08-01/productpolicy/method_createorupdate_autorest.go b/resource-manager/apimanagement/2021-08-01/productpolicy/method_createorupdate_autorest.go deleted file mode 100644 index 43f5c165d57..00000000000 --- a/resource-manager/apimanagement/2021-08-01/productpolicy/method_createorupdate_autorest.go +++ /dev/null @@ -1,99 +0,0 @@ -package productpolicy - -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 CreateOrUpdateOperationResponse struct { - HttpResponse *http.Response - Model *PolicyContract -} - -type CreateOrUpdateOperationOptions struct { - IfMatch *string -} - -func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { - return CreateOrUpdateOperationOptions{} -} - -func (o CreateOrUpdateOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o CreateOrUpdateOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// CreateOrUpdate ... -func (c ProductPolicyClient) CreateOrUpdate(ctx context.Context, id ProductId, input PolicyContract, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdate(ctx, id, input, options) - if err != nil { - err = autorest.NewErrorWithError(err, "productpolicy.ProductPolicyClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "productpolicy.ProductPolicyClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCreateOrUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "productpolicy.ProductPolicyClient", "CreateOrUpdate", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCreateOrUpdate prepares the CreateOrUpdate request. -func (c ProductPolicyClient) preparerForCreateOrUpdate(ctx context.Context, id ProductId, input PolicyContract, options CreateOrUpdateOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/policies/policy", 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 ProductPolicyClient) responderForCreateOrUpdate(resp *http.Response) (result CreateOrUpdateOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2021-08-01/productpolicy/method_delete.go b/resource-manager/apimanagement/2021-08-01/productpolicy/method_delete.go new file mode 100644 index 00000000000..09bc23bd22e --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/productpolicy/method_delete.go @@ -0,0 +1,76 @@ +package productpolicy + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +type DeleteOperationOptions struct { + IfMatch *string +} + +func DefaultDeleteOperationOptions() DeleteOperationOptions { + return DeleteOperationOptions{} +} + +func (o DeleteOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o DeleteOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o DeleteOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// Delete ... +func (c ProductPolicyClient) Delete(ctx context.Context, id ProductId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: fmt.Sprintf("%s/policies/policy", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2021-08-01/productpolicy/method_delete_autorest.go b/resource-manager/apimanagement/2021-08-01/productpolicy/method_delete_autorest.go deleted file mode 100644 index d18f700767f..00000000000 --- a/resource-manager/apimanagement/2021-08-01/productpolicy/method_delete_autorest.go +++ /dev/null @@ -1,96 +0,0 @@ -package productpolicy - -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 DeleteOperationResponse struct { - HttpResponse *http.Response -} - -type DeleteOperationOptions struct { - IfMatch *string -} - -func DefaultDeleteOperationOptions() DeleteOperationOptions { - return DeleteOperationOptions{} -} - -func (o DeleteOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o DeleteOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// Delete ... -func (c ProductPolicyClient) Delete(ctx context.Context, id ProductId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { - req, err := c.preparerForDelete(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "productpolicy.ProductPolicyClient", "Delete", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "productpolicy.ProductPolicyClient", "Delete", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForDelete(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "productpolicy.ProductPolicyClient", "Delete", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForDelete prepares the Delete request. -func (c ProductPolicyClient) preparerForDelete(ctx context.Context, id ProductId, options DeleteOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/policies/policy", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForDelete handles the response to the Delete request. The method always -// closes the http.Response Body. -func (c ProductPolicyClient) responderForDelete(resp *http.Response) (result DeleteOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2021-08-01/productpolicy/method_get.go b/resource-manager/apimanagement/2021-08-01/productpolicy/method_get.go new file mode 100644 index 00000000000..46284c64c32 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/productpolicy/method_get.go @@ -0,0 +1,80 @@ +package productpolicy + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PolicyContract +} + +type GetOperationOptions struct { + Format *PolicyExportFormat +} + +func DefaultGetOperationOptions() GetOperationOptions { + return GetOperationOptions{} +} + +func (o GetOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o GetOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o GetOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Format != nil { + out.Append("format", fmt.Sprintf("%v", *o.Format)) + } + return &out +} + +// Get ... +func (c ProductPolicyClient) Get(ctx context.Context, id ProductId, options GetOperationOptions) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/policies/policy", id.ID()), + OptionsObject: options, + } + + 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/apimanagement/2021-08-01/productpolicy/method_get_autorest.go b/resource-manager/apimanagement/2021-08-01/productpolicy/method_get_autorest.go deleted file mode 100644 index b2933e55f93..00000000000 --- a/resource-manager/apimanagement/2021-08-01/productpolicy/method_get_autorest.go +++ /dev/null @@ -1,98 +0,0 @@ -package productpolicy - -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 GetOperationResponse struct { - HttpResponse *http.Response - Model *PolicyContract -} - -type GetOperationOptions struct { - Format *PolicyExportFormat -} - -func DefaultGetOperationOptions() GetOperationOptions { - return GetOperationOptions{} -} - -func (o GetOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o GetOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Format != nil { - out["format"] = *o.Format - } - - return out -} - -// Get ... -func (c ProductPolicyClient) Get(ctx context.Context, id ProductId, options GetOperationOptions) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "productpolicy.ProductPolicyClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "productpolicy.ProductPolicyClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "productpolicy.ProductPolicyClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c ProductPolicyClient) preparerForGet(ctx context.Context, id ProductId, options GetOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/policies/policy", 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 ProductPolicyClient) 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/apimanagement/2021-08-01/productpolicy/method_getentitytag.go b/resource-manager/apimanagement/2021-08-01/productpolicy/method_getentitytag.go new file mode 100644 index 00000000000..3e3787982d6 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/productpolicy/method_getentitytag.go @@ -0,0 +1,47 @@ +package productpolicy + +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 GetEntityTagOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// GetEntityTag ... +func (c ProductPolicyClient) GetEntityTag(ctx context.Context, id ProductId) (result GetEntityTagOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodHead, + Path: fmt.Sprintf("%s/policies/policy", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2021-08-01/productpolicy/method_getentitytag_autorest.go b/resource-manager/apimanagement/2021-08-01/productpolicy/method_getentitytag_autorest.go deleted file mode 100644 index f446b88fb66..00000000000 --- a/resource-manager/apimanagement/2021-08-01/productpolicy/method_getentitytag_autorest.go +++ /dev/null @@ -1,67 +0,0 @@ -package productpolicy - -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 GetEntityTagOperationResponse struct { - HttpResponse *http.Response -} - -// GetEntityTag ... -func (c ProductPolicyClient) GetEntityTag(ctx context.Context, id ProductId) (result GetEntityTagOperationResponse, err error) { - req, err := c.preparerForGetEntityTag(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "productpolicy.ProductPolicyClient", "GetEntityTag", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "productpolicy.ProductPolicyClient", "GetEntityTag", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetEntityTag(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "productpolicy.ProductPolicyClient", "GetEntityTag", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetEntityTag prepares the GetEntityTag request. -func (c ProductPolicyClient) preparerForGetEntityTag(ctx context.Context, id ProductId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsHead(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/policies/policy", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetEntityTag handles the response to the GetEntityTag request. The method always -// closes the http.Response Body. -func (c ProductPolicyClient) responderForGetEntityTag(resp *http.Response) (result GetEntityTagOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2021-08-01/productpolicy/method_listbyproduct.go b/resource-manager/apimanagement/2021-08-01/productpolicy/method_listbyproduct.go new file mode 100644 index 00000000000..d9cbc9812e4 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/productpolicy/method_listbyproduct.go @@ -0,0 +1,52 @@ +package productpolicy + +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 ListByProductOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PolicyCollection +} + +// ListByProduct ... +func (c ProductPolicyClient) ListByProduct(ctx context.Context, id ProductId) (result ListByProductOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/policies", 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/apimanagement/2021-08-01/productpolicy/method_listbyproduct_autorest.go b/resource-manager/apimanagement/2021-08-01/productpolicy/method_listbyproduct_autorest.go deleted file mode 100644 index 40fab3bcf62..00000000000 --- a/resource-manager/apimanagement/2021-08-01/productpolicy/method_listbyproduct_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package productpolicy - -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 ListByProductOperationResponse struct { - HttpResponse *http.Response - Model *PolicyCollection -} - -// ListByProduct ... -func (c ProductPolicyClient) ListByProduct(ctx context.Context, id ProductId) (result ListByProductOperationResponse, err error) { - req, err := c.preparerForListByProduct(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "productpolicy.ProductPolicyClient", "ListByProduct", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "productpolicy.ProductPolicyClient", "ListByProduct", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByProduct(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "productpolicy.ProductPolicyClient", "ListByProduct", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForListByProduct prepares the ListByProduct request. -func (c ProductPolicyClient) preparerForListByProduct(ctx context.Context, id ProductId) (*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/policies", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListByProduct handles the response to the ListByProduct request. The method always -// closes the http.Response Body. -func (c ProductPolicyClient) responderForListByProduct(resp *http.Response) (result ListByProductOperationResponse, 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/apimanagement/2021-08-01/productsbytag/client.go b/resource-manager/apimanagement/2021-08-01/productsbytag/client.go index 819f4c151ff..88609064dad 100644 --- a/resource-manager/apimanagement/2021-08-01/productsbytag/client.go +++ b/resource-manager/apimanagement/2021-08-01/productsbytag/client.go @@ -1,18 +1,26 @@ package productsbytag -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 ProductsByTagClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewProductsByTagClientWithBaseURI(endpoint string) ProductsByTagClient { - return ProductsByTagClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewProductsByTagClientWithBaseURI(api environments.Api) (*ProductsByTagClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "productsbytag", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ProductsByTagClient: %+v", err) } + + return &ProductsByTagClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2021-08-01/productsbytag/constants.go b/resource-manager/apimanagement/2021-08-01/productsbytag/constants.go index a3a2af687c4..6380c578cd4 100644 --- a/resource-manager/apimanagement/2021-08-01/productsbytag/constants.go +++ b/resource-manager/apimanagement/2021-08-01/productsbytag/constants.go @@ -1,6 +1,10 @@ package productsbytag -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 PossibleValuesForApiType() []string { } } +func (s *ApiType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseApiType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseApiType(input string) (*ApiType, error) { vals := map[string]ApiType{ "graphql": ApiTypeGraphql, @@ -53,6 +70,19 @@ func PossibleValuesForBearerTokenSendingMethods() []string { } } +func (s *BearerTokenSendingMethods) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseBearerTokenSendingMethods(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseBearerTokenSendingMethods(input string) (*BearerTokenSendingMethods, error) { vals := map[string]BearerTokenSendingMethods{ "authorizationheader": BearerTokenSendingMethodsAuthorizationHeader, @@ -81,6 +111,19 @@ func PossibleValuesForProductState() []string { } } +func (s *ProductState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProductState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseProductState(input string) (*ProductState, error) { vals := map[string]ProductState{ "notpublished": ProductStateNotPublished, @@ -113,6 +156,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{ "http": ProtocolHTTP, diff --git a/resource-manager/apimanagement/2021-08-01/productsbytag/method_productlistbytags.go b/resource-manager/apimanagement/2021-08-01/productsbytag/method_productlistbytags.go new file mode 100644 index 00000000000..bd145c12a02 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/productsbytag/method_productlistbytags.go @@ -0,0 +1,129 @@ +package productsbytag + +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 ProductListByTagsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]TagResourceContract +} + +type ProductListByTagsCompleteResult struct { + Items []TagResourceContract +} + +type ProductListByTagsOperationOptions struct { + Filter *string + IncludeNotTaggedProducts *bool + Skip *int64 + Top *int64 +} + +func DefaultProductListByTagsOperationOptions() ProductListByTagsOperationOptions { + return ProductListByTagsOperationOptions{} +} + +func (o ProductListByTagsOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ProductListByTagsOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ProductListByTagsOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.IncludeNotTaggedProducts != nil { + out.Append("includeNotTaggedProducts", fmt.Sprintf("%v", *o.IncludeNotTaggedProducts)) + } + if o.Skip != nil { + out.Append("$skip", fmt.Sprintf("%v", *o.Skip)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +// ProductListByTags ... +func (c ProductsByTagClient) ProductListByTags(ctx context.Context, id ServiceId, options ProductListByTagsOperationOptions) (result ProductListByTagsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/productsByTags", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]TagResourceContract `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ProductListByTagsComplete retrieves all the results into a single object +func (c ProductsByTagClient) ProductListByTagsComplete(ctx context.Context, id ServiceId, options ProductListByTagsOperationOptions) (ProductListByTagsCompleteResult, error) { + return c.ProductListByTagsCompleteMatchingPredicate(ctx, id, options, TagResourceContractOperationPredicate{}) +} + +// ProductListByTagsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ProductsByTagClient) ProductListByTagsCompleteMatchingPredicate(ctx context.Context, id ServiceId, options ProductListByTagsOperationOptions, predicate TagResourceContractOperationPredicate) (result ProductListByTagsCompleteResult, err error) { + items := make([]TagResourceContract, 0) + + resp, err := c.ProductListByTags(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ProductListByTagsCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/apimanagement/2021-08-01/productsbytag/method_productlistbytags_autorest.go b/resource-manager/apimanagement/2021-08-01/productsbytag/method_productlistbytags_autorest.go deleted file mode 100644 index 2cff77a5a10..00000000000 --- a/resource-manager/apimanagement/2021-08-01/productsbytag/method_productlistbytags_autorest.go +++ /dev/null @@ -1,230 +0,0 @@ -package productsbytag - -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 ProductListByTagsOperationResponse struct { - HttpResponse *http.Response - Model *[]TagResourceContract - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ProductListByTagsOperationResponse, error) -} - -type ProductListByTagsCompleteResult struct { - Items []TagResourceContract -} - -func (r ProductListByTagsOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ProductListByTagsOperationResponse) LoadMore(ctx context.Context) (resp ProductListByTagsOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -type ProductListByTagsOperationOptions struct { - Filter *string - IncludeNotTaggedProducts *bool - Skip *int64 - Top *int64 -} - -func DefaultProductListByTagsOperationOptions() ProductListByTagsOperationOptions { - return ProductListByTagsOperationOptions{} -} - -func (o ProductListByTagsOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o ProductListByTagsOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Filter != nil { - out["$filter"] = *o.Filter - } - - if o.IncludeNotTaggedProducts != nil { - out["includeNotTaggedProducts"] = *o.IncludeNotTaggedProducts - } - - if o.Skip != nil { - out["$skip"] = *o.Skip - } - - if o.Top != nil { - out["$top"] = *o.Top - } - - return out -} - -// ProductListByTags ... -func (c ProductsByTagClient) ProductListByTags(ctx context.Context, id ServiceId, options ProductListByTagsOperationOptions) (resp ProductListByTagsOperationResponse, err error) { - req, err := c.preparerForProductListByTags(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "productsbytag.ProductsByTagClient", "ProductListByTags", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "productsbytag.ProductsByTagClient", "ProductListByTags", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForProductListByTags(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "productsbytag.ProductsByTagClient", "ProductListByTags", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForProductListByTags prepares the ProductListByTags request. -func (c ProductsByTagClient) preparerForProductListByTags(ctx context.Context, id ServiceId, options ProductListByTagsOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/productsByTags", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForProductListByTagsWithNextLink prepares the ProductListByTags request with the given nextLink token. -func (c ProductsByTagClient) preparerForProductListByTagsWithNextLink(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)) -} - -// responderForProductListByTags handles the response to the ProductListByTags request. The method always -// closes the http.Response Body. -func (c ProductsByTagClient) responderForProductListByTags(resp *http.Response) (result ProductListByTagsOperationResponse, err error) { - type page struct { - Values []TagResourceContract `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 ProductListByTagsOperationResponse, err error) { - req, err := c.preparerForProductListByTagsWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "productsbytag.ProductsByTagClient", "ProductListByTags", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "productsbytag.ProductsByTagClient", "ProductListByTags", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForProductListByTags(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "productsbytag.ProductsByTagClient", "ProductListByTags", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ProductListByTagsComplete retrieves all of the results into a single object -func (c ProductsByTagClient) ProductListByTagsComplete(ctx context.Context, id ServiceId, options ProductListByTagsOperationOptions) (ProductListByTagsCompleteResult, error) { - return c.ProductListByTagsCompleteMatchingPredicate(ctx, id, options, TagResourceContractOperationPredicate{}) -} - -// ProductListByTagsCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c ProductsByTagClient) ProductListByTagsCompleteMatchingPredicate(ctx context.Context, id ServiceId, options ProductListByTagsOperationOptions, predicate TagResourceContractOperationPredicate) (resp ProductListByTagsCompleteResult, err error) { - items := make([]TagResourceContract, 0) - - page, err := c.ProductListByTags(ctx, id, options) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ProductListByTagsCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/apimanagement/2021-08-01/productsubscription/client.go b/resource-manager/apimanagement/2021-08-01/productsubscription/client.go index e6fc998ab6f..d8a5835a232 100644 --- a/resource-manager/apimanagement/2021-08-01/productsubscription/client.go +++ b/resource-manager/apimanagement/2021-08-01/productsubscription/client.go @@ -1,18 +1,26 @@ package productsubscription -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 ProductSubscriptionClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewProductSubscriptionClientWithBaseURI(endpoint string) ProductSubscriptionClient { - return ProductSubscriptionClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewProductSubscriptionClientWithBaseURI(api environments.Api) (*ProductSubscriptionClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "productsubscription", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ProductSubscriptionClient: %+v", err) } + + return &ProductSubscriptionClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2021-08-01/productsubscription/constants.go b/resource-manager/apimanagement/2021-08-01/productsubscription/constants.go index 3d9bc9cb116..b701ce04fea 100644 --- a/resource-manager/apimanagement/2021-08-01/productsubscription/constants.go +++ b/resource-manager/apimanagement/2021-08-01/productsubscription/constants.go @@ -1,6 +1,10 @@ package productsubscription -import "strings" +import ( + "encoding/json" + "fmt" + "strings" +) // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See NOTICE.txt in the project root for license information. @@ -27,6 +31,19 @@ func PossibleValuesForSubscriptionState() []string { } } +func (s *SubscriptionState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSubscriptionState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseSubscriptionState(input string) (*SubscriptionState, error) { vals := map[string]SubscriptionState{ "active": SubscriptionStateActive, diff --git a/resource-manager/apimanagement/2021-08-01/productsubscription/method_list.go b/resource-manager/apimanagement/2021-08-01/productsubscription/method_list.go new file mode 100644 index 00000000000..6e4d8a7a32c --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/productsubscription/method_list.go @@ -0,0 +1,125 @@ +package productsubscription + +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 *[]SubscriptionContract +} + +type ListCompleteResult struct { + Items []SubscriptionContract +} + +type ListOperationOptions struct { + Filter *string + Skip *int64 + Top *int64 +} + +func DefaultListOperationOptions() ListOperationOptions { + return ListOperationOptions{} +} + +func (o ListOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.Skip != nil { + out.Append("$skip", fmt.Sprintf("%v", *o.Skip)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +// List ... +func (c ProductSubscriptionClient) List(ctx context.Context, id ProductId, options ListOperationOptions) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/subscriptions", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]SubscriptionContract `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 ProductSubscriptionClient) ListComplete(ctx context.Context, id ProductId, options ListOperationOptions) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, options, SubscriptionContractOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ProductSubscriptionClient) ListCompleteMatchingPredicate(ctx context.Context, id ProductId, options ListOperationOptions, predicate SubscriptionContractOperationPredicate) (result ListCompleteResult, err error) { + items := make([]SubscriptionContract, 0) + + resp, err := c.List(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/apimanagement/2021-08-01/productsubscription/method_list_autorest.go b/resource-manager/apimanagement/2021-08-01/productsubscription/method_list_autorest.go deleted file mode 100644 index c90464fedfa..00000000000 --- a/resource-manager/apimanagement/2021-08-01/productsubscription/method_list_autorest.go +++ /dev/null @@ -1,225 +0,0 @@ -package productsubscription - -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 *[]SubscriptionContract - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListOperationResponse, error) -} - -type ListCompleteResult struct { - Items []SubscriptionContract -} - -func (r ListOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListOperationResponse) LoadMore(ctx context.Context) (resp ListOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -type ListOperationOptions struct { - Filter *string - Skip *int64 - Top *int64 -} - -func DefaultListOperationOptions() ListOperationOptions { - return ListOperationOptions{} -} - -func (o ListOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o ListOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Filter != nil { - out["$filter"] = *o.Filter - } - - if o.Skip != nil { - out["$skip"] = *o.Skip - } - - if o.Top != nil { - out["$top"] = *o.Top - } - - return out -} - -// List ... -func (c ProductSubscriptionClient) List(ctx context.Context, id ProductId, options ListOperationOptions) (resp ListOperationResponse, err error) { - req, err := c.preparerForList(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "productsubscription.ProductSubscriptionClient", "List", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "productsubscription.ProductSubscriptionClient", "List", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForList(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "productsubscription.ProductSubscriptionClient", "List", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForList prepares the List request. -func (c ProductSubscriptionClient) preparerForList(ctx context.Context, id ProductId, options ListOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/subscriptions", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListWithNextLink prepares the List request with the given nextLink token. -func (c ProductSubscriptionClient) 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 ProductSubscriptionClient) responderForList(resp *http.Response) (result ListOperationResponse, err error) { - type page struct { - Values []SubscriptionContract `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, "productsubscription.ProductSubscriptionClient", "List", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "productsubscription.ProductSubscriptionClient", "List", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForList(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "productsubscription.ProductSubscriptionClient", "List", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListComplete retrieves all of the results into a single object -func (c ProductSubscriptionClient) ListComplete(ctx context.Context, id ProductId, options ListOperationOptions) (ListCompleteResult, error) { - return c.ListCompleteMatchingPredicate(ctx, id, options, SubscriptionContractOperationPredicate{}) -} - -// ListCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c ProductSubscriptionClient) ListCompleteMatchingPredicate(ctx context.Context, id ProductId, options ListOperationOptions, predicate SubscriptionContractOperationPredicate) (resp ListCompleteResult, err error) { - items := make([]SubscriptionContract, 0) - - page, err := c.List(ctx, id, options) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/apimanagement/2021-08-01/producttag/client.go b/resource-manager/apimanagement/2021-08-01/producttag/client.go index 852ad05f1e6..20b63f571e6 100644 --- a/resource-manager/apimanagement/2021-08-01/producttag/client.go +++ b/resource-manager/apimanagement/2021-08-01/producttag/client.go @@ -1,18 +1,26 @@ package producttag -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 ProductTagClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewProductTagClientWithBaseURI(endpoint string) ProductTagClient { - return ProductTagClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewProductTagClientWithBaseURI(api environments.Api) (*ProductTagClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "producttag", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ProductTagClient: %+v", err) } + + return &ProductTagClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2021-08-01/producttag/method_tagassigntoproduct.go b/resource-manager/apimanagement/2021-08-01/producttag/method_tagassigntoproduct.go new file mode 100644 index 00000000000..55885dbd935 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/producttag/method_tagassigntoproduct.go @@ -0,0 +1,52 @@ +package producttag + +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 TagAssignToProductOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *TagContract +} + +// TagAssignToProduct ... +func (c ProductTagClient) TagAssignToProduct(ctx context.Context, id ProductTagId) (result TagAssignToProductOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + 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/apimanagement/2021-08-01/producttag/method_tagassigntoproduct_autorest.go b/resource-manager/apimanagement/2021-08-01/producttag/method_tagassigntoproduct_autorest.go deleted file mode 100644 index 6a0b20cfc9a..00000000000 --- a/resource-manager/apimanagement/2021-08-01/producttag/method_tagassigntoproduct_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package producttag - -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 TagAssignToProductOperationResponse struct { - HttpResponse *http.Response - Model *TagContract -} - -// TagAssignToProduct ... -func (c ProductTagClient) TagAssignToProduct(ctx context.Context, id ProductTagId) (result TagAssignToProductOperationResponse, err error) { - req, err := c.preparerForTagAssignToProduct(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "producttag.ProductTagClient", "TagAssignToProduct", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "producttag.ProductTagClient", "TagAssignToProduct", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForTagAssignToProduct(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "producttag.ProductTagClient", "TagAssignToProduct", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForTagAssignToProduct prepares the TagAssignToProduct request. -func (c ProductTagClient) preparerForTagAssignToProduct(ctx context.Context, id ProductTagId) (*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.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForTagAssignToProduct handles the response to the TagAssignToProduct request. The method always -// closes the http.Response Body. -func (c ProductTagClient) responderForTagAssignToProduct(resp *http.Response) (result TagAssignToProductOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2021-08-01/producttag/method_tagdetachfromproduct.go b/resource-manager/apimanagement/2021-08-01/producttag/method_tagdetachfromproduct.go new file mode 100644 index 00000000000..9564ceb67e1 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/producttag/method_tagdetachfromproduct.go @@ -0,0 +1,47 @@ +package producttag + +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 TagDetachFromProductOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// TagDetachFromProduct ... +func (c ProductTagClient) TagDetachFromProduct(ctx context.Context, id ProductTagId) (result TagDetachFromProductOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2021-08-01/producttag/method_tagdetachfromproduct_autorest.go b/resource-manager/apimanagement/2021-08-01/producttag/method_tagdetachfromproduct_autorest.go deleted file mode 100644 index de37a803293..00000000000 --- a/resource-manager/apimanagement/2021-08-01/producttag/method_tagdetachfromproduct_autorest.go +++ /dev/null @@ -1,66 +0,0 @@ -package producttag - -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 TagDetachFromProductOperationResponse struct { - HttpResponse *http.Response -} - -// TagDetachFromProduct ... -func (c ProductTagClient) TagDetachFromProduct(ctx context.Context, id ProductTagId) (result TagDetachFromProductOperationResponse, err error) { - req, err := c.preparerForTagDetachFromProduct(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "producttag.ProductTagClient", "TagDetachFromProduct", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "producttag.ProductTagClient", "TagDetachFromProduct", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForTagDetachFromProduct(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "producttag.ProductTagClient", "TagDetachFromProduct", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForTagDetachFromProduct prepares the TagDetachFromProduct request. -func (c ProductTagClient) preparerForTagDetachFromProduct(ctx context.Context, id ProductTagId) (*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)) -} - -// responderForTagDetachFromProduct handles the response to the TagDetachFromProduct request. The method always -// closes the http.Response Body. -func (c ProductTagClient) responderForTagDetachFromProduct(resp *http.Response) (result TagDetachFromProductOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2021-08-01/producttag/method_taggetbyproduct.go b/resource-manager/apimanagement/2021-08-01/producttag/method_taggetbyproduct.go new file mode 100644 index 00000000000..413a4b52b72 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/producttag/method_taggetbyproduct.go @@ -0,0 +1,51 @@ +package producttag + +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 TagGetByProductOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *TagContract +} + +// TagGetByProduct ... +func (c ProductTagClient) TagGetByProduct(ctx context.Context, id ProductTagId) (result TagGetByProductOperationResponse, 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/apimanagement/2021-08-01/producttag/method_taggetbyproduct_autorest.go b/resource-manager/apimanagement/2021-08-01/producttag/method_taggetbyproduct_autorest.go deleted file mode 100644 index beb3693330c..00000000000 --- a/resource-manager/apimanagement/2021-08-01/producttag/method_taggetbyproduct_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package producttag - -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 TagGetByProductOperationResponse struct { - HttpResponse *http.Response - Model *TagContract -} - -// TagGetByProduct ... -func (c ProductTagClient) TagGetByProduct(ctx context.Context, id ProductTagId) (result TagGetByProductOperationResponse, err error) { - req, err := c.preparerForTagGetByProduct(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "producttag.ProductTagClient", "TagGetByProduct", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "producttag.ProductTagClient", "TagGetByProduct", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForTagGetByProduct(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "producttag.ProductTagClient", "TagGetByProduct", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForTagGetByProduct prepares the TagGetByProduct request. -func (c ProductTagClient) preparerForTagGetByProduct(ctx context.Context, id ProductTagId) (*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)) -} - -// responderForTagGetByProduct handles the response to the TagGetByProduct request. The method always -// closes the http.Response Body. -func (c ProductTagClient) responderForTagGetByProduct(resp *http.Response) (result TagGetByProductOperationResponse, 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/apimanagement/2021-08-01/producttag/method_taggetentitystatebyproduct.go b/resource-manager/apimanagement/2021-08-01/producttag/method_taggetentitystatebyproduct.go new file mode 100644 index 00000000000..8f023009406 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/producttag/method_taggetentitystatebyproduct.go @@ -0,0 +1,46 @@ +package producttag + +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 TagGetEntityStateByProductOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// TagGetEntityStateByProduct ... +func (c ProductTagClient) TagGetEntityStateByProduct(ctx context.Context, id ProductTagId) (result TagGetEntityStateByProductOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodHead, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2021-08-01/producttag/method_taggetentitystatebyproduct_autorest.go b/resource-manager/apimanagement/2021-08-01/producttag/method_taggetentitystatebyproduct_autorest.go deleted file mode 100644 index ba4e65f8cd1..00000000000 --- a/resource-manager/apimanagement/2021-08-01/producttag/method_taggetentitystatebyproduct_autorest.go +++ /dev/null @@ -1,66 +0,0 @@ -package producttag - -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 TagGetEntityStateByProductOperationResponse struct { - HttpResponse *http.Response -} - -// TagGetEntityStateByProduct ... -func (c ProductTagClient) TagGetEntityStateByProduct(ctx context.Context, id ProductTagId) (result TagGetEntityStateByProductOperationResponse, err error) { - req, err := c.preparerForTagGetEntityStateByProduct(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "producttag.ProductTagClient", "TagGetEntityStateByProduct", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "producttag.ProductTagClient", "TagGetEntityStateByProduct", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForTagGetEntityStateByProduct(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "producttag.ProductTagClient", "TagGetEntityStateByProduct", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForTagGetEntityStateByProduct prepares the TagGetEntityStateByProduct request. -func (c ProductTagClient) preparerForTagGetEntityStateByProduct(ctx context.Context, id ProductTagId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsHead(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForTagGetEntityStateByProduct handles the response to the TagGetEntityStateByProduct request. The method always -// closes the http.Response Body. -func (c ProductTagClient) responderForTagGetEntityStateByProduct(resp *http.Response) (result TagGetEntityStateByProductOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2021-08-01/producttag/method_taglistbyproduct.go b/resource-manager/apimanagement/2021-08-01/producttag/method_taglistbyproduct.go new file mode 100644 index 00000000000..0b73c472a25 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/producttag/method_taglistbyproduct.go @@ -0,0 +1,125 @@ +package producttag + +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 TagListByProductOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]TagContract +} + +type TagListByProductCompleteResult struct { + Items []TagContract +} + +type TagListByProductOperationOptions struct { + Filter *string + Skip *int64 + Top *int64 +} + +func DefaultTagListByProductOperationOptions() TagListByProductOperationOptions { + return TagListByProductOperationOptions{} +} + +func (o TagListByProductOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o TagListByProductOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o TagListByProductOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.Skip != nil { + out.Append("$skip", fmt.Sprintf("%v", *o.Skip)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +// TagListByProduct ... +func (c ProductTagClient) TagListByProduct(ctx context.Context, id ProductId, options TagListByProductOperationOptions) (result TagListByProductOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/tags", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]TagContract `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// TagListByProductComplete retrieves all the results into a single object +func (c ProductTagClient) TagListByProductComplete(ctx context.Context, id ProductId, options TagListByProductOperationOptions) (TagListByProductCompleteResult, error) { + return c.TagListByProductCompleteMatchingPredicate(ctx, id, options, TagContractOperationPredicate{}) +} + +// TagListByProductCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ProductTagClient) TagListByProductCompleteMatchingPredicate(ctx context.Context, id ProductId, options TagListByProductOperationOptions, predicate TagContractOperationPredicate) (result TagListByProductCompleteResult, err error) { + items := make([]TagContract, 0) + + resp, err := c.TagListByProduct(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = TagListByProductCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/apimanagement/2021-08-01/producttag/method_taglistbyproduct_autorest.go b/resource-manager/apimanagement/2021-08-01/producttag/method_taglistbyproduct_autorest.go deleted file mode 100644 index f0717ee0f77..00000000000 --- a/resource-manager/apimanagement/2021-08-01/producttag/method_taglistbyproduct_autorest.go +++ /dev/null @@ -1,225 +0,0 @@ -package producttag - -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 TagListByProductOperationResponse struct { - HttpResponse *http.Response - Model *[]TagContract - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (TagListByProductOperationResponse, error) -} - -type TagListByProductCompleteResult struct { - Items []TagContract -} - -func (r TagListByProductOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r TagListByProductOperationResponse) LoadMore(ctx context.Context) (resp TagListByProductOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -type TagListByProductOperationOptions struct { - Filter *string - Skip *int64 - Top *int64 -} - -func DefaultTagListByProductOperationOptions() TagListByProductOperationOptions { - return TagListByProductOperationOptions{} -} - -func (o TagListByProductOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o TagListByProductOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Filter != nil { - out["$filter"] = *o.Filter - } - - if o.Skip != nil { - out["$skip"] = *o.Skip - } - - if o.Top != nil { - out["$top"] = *o.Top - } - - return out -} - -// TagListByProduct ... -func (c ProductTagClient) TagListByProduct(ctx context.Context, id ProductId, options TagListByProductOperationOptions) (resp TagListByProductOperationResponse, err error) { - req, err := c.preparerForTagListByProduct(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "producttag.ProductTagClient", "TagListByProduct", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "producttag.ProductTagClient", "TagListByProduct", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForTagListByProduct(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "producttag.ProductTagClient", "TagListByProduct", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForTagListByProduct prepares the TagListByProduct request. -func (c ProductTagClient) preparerForTagListByProduct(ctx context.Context, id ProductId, options TagListByProductOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/tags", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForTagListByProductWithNextLink prepares the TagListByProduct request with the given nextLink token. -func (c ProductTagClient) preparerForTagListByProductWithNextLink(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)) -} - -// responderForTagListByProduct handles the response to the TagListByProduct request. The method always -// closes the http.Response Body. -func (c ProductTagClient) responderForTagListByProduct(resp *http.Response) (result TagListByProductOperationResponse, err error) { - type page struct { - Values []TagContract `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 TagListByProductOperationResponse, err error) { - req, err := c.preparerForTagListByProductWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "producttag.ProductTagClient", "TagListByProduct", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "producttag.ProductTagClient", "TagListByProduct", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForTagListByProduct(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "producttag.ProductTagClient", "TagListByProduct", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// TagListByProductComplete retrieves all of the results into a single object -func (c ProductTagClient) TagListByProductComplete(ctx context.Context, id ProductId, options TagListByProductOperationOptions) (TagListByProductCompleteResult, error) { - return c.TagListByProductCompleteMatchingPredicate(ctx, id, options, TagContractOperationPredicate{}) -} - -// TagListByProductCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c ProductTagClient) TagListByProductCompleteMatchingPredicate(ctx context.Context, id ProductId, options TagListByProductOperationOptions, predicate TagContractOperationPredicate) (resp TagListByProductCompleteResult, err error) { - items := make([]TagContract, 0) - - page, err := c.TagListByProduct(ctx, id, options) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := TagListByProductCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/apimanagement/2021-08-01/quotabycounterkeys/client.go b/resource-manager/apimanagement/2021-08-01/quotabycounterkeys/client.go index 2671480732c..fa7c3b75859 100644 --- a/resource-manager/apimanagement/2021-08-01/quotabycounterkeys/client.go +++ b/resource-manager/apimanagement/2021-08-01/quotabycounterkeys/client.go @@ -1,18 +1,26 @@ package quotabycounterkeys -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 QuotaByCounterKeysClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewQuotaByCounterKeysClientWithBaseURI(endpoint string) QuotaByCounterKeysClient { - return QuotaByCounterKeysClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewQuotaByCounterKeysClientWithBaseURI(api environments.Api) (*QuotaByCounterKeysClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "quotabycounterkeys", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating QuotaByCounterKeysClient: %+v", err) } + + return &QuotaByCounterKeysClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2021-08-01/quotabycounterkeys/method_listbyservice.go b/resource-manager/apimanagement/2021-08-01/quotabycounterkeys/method_listbyservice.go new file mode 100644 index 00000000000..dea7040ba8b --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/quotabycounterkeys/method_listbyservice.go @@ -0,0 +1,51 @@ +package quotabycounterkeys + +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 ListByServiceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *QuotaCounterCollection +} + +// ListByService ... +func (c QuotaByCounterKeysClient) ListByService(ctx context.Context, id QuotaId) (result ListByServiceOperationResponse, 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/apimanagement/2021-08-01/quotabycounterkeys/method_listbyservice_autorest.go b/resource-manager/apimanagement/2021-08-01/quotabycounterkeys/method_listbyservice_autorest.go deleted file mode 100644 index bc4c2e7a4c2..00000000000 --- a/resource-manager/apimanagement/2021-08-01/quotabycounterkeys/method_listbyservice_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package quotabycounterkeys - -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 ListByServiceOperationResponse struct { - HttpResponse *http.Response - Model *QuotaCounterCollection -} - -// ListByService ... -func (c QuotaByCounterKeysClient) ListByService(ctx context.Context, id QuotaId) (result ListByServiceOperationResponse, err error) { - req, err := c.preparerForListByService(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "quotabycounterkeys.QuotaByCounterKeysClient", "ListByService", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "quotabycounterkeys.QuotaByCounterKeysClient", "ListByService", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByService(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "quotabycounterkeys.QuotaByCounterKeysClient", "ListByService", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForListByService prepares the ListByService request. -func (c QuotaByCounterKeysClient) preparerForListByService(ctx context.Context, id QuotaId) (*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)) -} - -// responderForListByService handles the response to the ListByService request. The method always -// closes the http.Response Body. -func (c QuotaByCounterKeysClient) responderForListByService(resp *http.Response) (result ListByServiceOperationResponse, 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/apimanagement/2021-08-01/quotabycounterkeys/method_update.go b/resource-manager/apimanagement/2021-08-01/quotabycounterkeys/method_update.go new file mode 100644 index 00000000000..f9bc3fcc0d4 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/quotabycounterkeys/method_update.go @@ -0,0 +1,55 @@ +package quotabycounterkeys + +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 *QuotaCounterCollection +} + +// Update ... +func (c QuotaByCounterKeysClient) Update(ctx context.Context, id QuotaId, input QuotaCounterValueUpdateContract) (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/apimanagement/2021-08-01/quotabycounterkeys/method_update_autorest.go b/resource-manager/apimanagement/2021-08-01/quotabycounterkeys/method_update_autorest.go deleted file mode 100644 index 4acf4507ad4..00000000000 --- a/resource-manager/apimanagement/2021-08-01/quotabycounterkeys/method_update_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package quotabycounterkeys - -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 *QuotaCounterCollection -} - -// Update ... -func (c QuotaByCounterKeysClient) Update(ctx context.Context, id QuotaId, input QuotaCounterValueUpdateContract) (result UpdateOperationResponse, err error) { - req, err := c.preparerForUpdate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "quotabycounterkeys.QuotaByCounterKeysClient", "Update", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "quotabycounterkeys.QuotaByCounterKeysClient", "Update", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "quotabycounterkeys.QuotaByCounterKeysClient", "Update", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForUpdate prepares the Update request. -func (c QuotaByCounterKeysClient) preparerForUpdate(ctx context.Context, id QuotaId, input QuotaCounterValueUpdateContract) (*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 QuotaByCounterKeysClient) 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/apimanagement/2021-08-01/quotabyperiodkeys/client.go b/resource-manager/apimanagement/2021-08-01/quotabyperiodkeys/client.go index 09577f5147f..8798344eed8 100644 --- a/resource-manager/apimanagement/2021-08-01/quotabyperiodkeys/client.go +++ b/resource-manager/apimanagement/2021-08-01/quotabyperiodkeys/client.go @@ -1,18 +1,26 @@ package quotabyperiodkeys -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 QuotaByPeriodKeysClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewQuotaByPeriodKeysClientWithBaseURI(endpoint string) QuotaByPeriodKeysClient { - return QuotaByPeriodKeysClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewQuotaByPeriodKeysClientWithBaseURI(api environments.Api) (*QuotaByPeriodKeysClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "quotabyperiodkeys", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating QuotaByPeriodKeysClient: %+v", err) } + + return &QuotaByPeriodKeysClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2021-08-01/quotabyperiodkeys/method_get.go b/resource-manager/apimanagement/2021-08-01/quotabyperiodkeys/method_get.go new file mode 100644 index 00000000000..d5d20c15b6f --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/quotabyperiodkeys/method_get.go @@ -0,0 +1,51 @@ +package quotabyperiodkeys + +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 *QuotaCounterContract +} + +// Get ... +func (c QuotaByPeriodKeysClient) Get(ctx context.Context, id PeriodId) (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/apimanagement/2021-08-01/quotabyperiodkeys/method_get_autorest.go b/resource-manager/apimanagement/2021-08-01/quotabyperiodkeys/method_get_autorest.go deleted file mode 100644 index 01ee60c2d53..00000000000 --- a/resource-manager/apimanagement/2021-08-01/quotabyperiodkeys/method_get_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package quotabyperiodkeys - -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 *QuotaCounterContract -} - -// Get ... -func (c QuotaByPeriodKeysClient) Get(ctx context.Context, id PeriodId) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "quotabyperiodkeys.QuotaByPeriodKeysClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "quotabyperiodkeys.QuotaByPeriodKeysClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "quotabyperiodkeys.QuotaByPeriodKeysClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c QuotaByPeriodKeysClient) preparerForGet(ctx context.Context, id PeriodId) (*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 QuotaByPeriodKeysClient) 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/apimanagement/2021-08-01/quotabyperiodkeys/method_update.go b/resource-manager/apimanagement/2021-08-01/quotabyperiodkeys/method_update.go new file mode 100644 index 00000000000..0d078a397a0 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/quotabyperiodkeys/method_update.go @@ -0,0 +1,55 @@ +package quotabyperiodkeys + +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 *QuotaCounterContract +} + +// Update ... +func (c QuotaByPeriodKeysClient) Update(ctx context.Context, id PeriodId, input QuotaCounterValueUpdateContract) (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/apimanagement/2021-08-01/quotabyperiodkeys/method_update_autorest.go b/resource-manager/apimanagement/2021-08-01/quotabyperiodkeys/method_update_autorest.go deleted file mode 100644 index 40b49856a3c..00000000000 --- a/resource-manager/apimanagement/2021-08-01/quotabyperiodkeys/method_update_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package quotabyperiodkeys - -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 *QuotaCounterContract -} - -// Update ... -func (c QuotaByPeriodKeysClient) Update(ctx context.Context, id PeriodId, input QuotaCounterValueUpdateContract) (result UpdateOperationResponse, err error) { - req, err := c.preparerForUpdate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "quotabyperiodkeys.QuotaByPeriodKeysClient", "Update", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "quotabyperiodkeys.QuotaByPeriodKeysClient", "Update", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "quotabyperiodkeys.QuotaByPeriodKeysClient", "Update", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForUpdate prepares the Update request. -func (c QuotaByPeriodKeysClient) preparerForUpdate(ctx context.Context, id PeriodId, input QuotaCounterValueUpdateContract) (*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 QuotaByPeriodKeysClient) 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/apimanagement/2021-08-01/region/client.go b/resource-manager/apimanagement/2021-08-01/region/client.go index 68b48c48347..2222b891e03 100644 --- a/resource-manager/apimanagement/2021-08-01/region/client.go +++ b/resource-manager/apimanagement/2021-08-01/region/client.go @@ -1,18 +1,26 @@ package region -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 RegionClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewRegionClientWithBaseURI(endpoint string) RegionClient { - return RegionClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewRegionClientWithBaseURI(api environments.Api) (*RegionClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "region", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating RegionClient: %+v", err) } + + return &RegionClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2021-08-01/region/method_listbyservice.go b/resource-manager/apimanagement/2021-08-01/region/method_listbyservice.go new file mode 100644 index 00000000000..5969f7e8fea --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/region/method_listbyservice.go @@ -0,0 +1,89 @@ +package region + +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 ListByServiceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]RegionContract +} + +type ListByServiceCompleteResult struct { + Items []RegionContract +} + +// ListByService ... +func (c RegionClient) ListByService(ctx context.Context, id ServiceId) (result ListByServiceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/regions", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]RegionContract `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByServiceComplete retrieves all the results into a single object +func (c RegionClient) ListByServiceComplete(ctx context.Context, id ServiceId) (ListByServiceCompleteResult, error) { + return c.ListByServiceCompleteMatchingPredicate(ctx, id, RegionContractOperationPredicate{}) +} + +// ListByServiceCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c RegionClient) ListByServiceCompleteMatchingPredicate(ctx context.Context, id ServiceId, predicate RegionContractOperationPredicate) (result ListByServiceCompleteResult, err error) { + items := make([]RegionContract, 0) + + resp, err := c.ListByService(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 = ListByServiceCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/apimanagement/2021-08-01/region/method_listbyservice_autorest.go b/resource-manager/apimanagement/2021-08-01/region/method_listbyservice_autorest.go deleted file mode 100644 index f1bc29a5de4..00000000000 --- a/resource-manager/apimanagement/2021-08-01/region/method_listbyservice_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package region - -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 ListByServiceOperationResponse struct { - HttpResponse *http.Response - Model *[]RegionContract - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListByServiceOperationResponse, error) -} - -type ListByServiceCompleteResult struct { - Items []RegionContract -} - -func (r ListByServiceOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListByServiceOperationResponse) LoadMore(ctx context.Context) (resp ListByServiceOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListByService ... -func (c RegionClient) ListByService(ctx context.Context, id ServiceId) (resp ListByServiceOperationResponse, err error) { - req, err := c.preparerForListByService(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "region.RegionClient", "ListByService", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "region.RegionClient", "ListByService", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListByService(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "region.RegionClient", "ListByService", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListByService prepares the ListByService request. -func (c RegionClient) preparerForListByService(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(fmt.Sprintf("%s/regions", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListByServiceWithNextLink prepares the ListByService request with the given nextLink token. -func (c RegionClient) preparerForListByServiceWithNextLink(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)) -} - -// responderForListByService handles the response to the ListByService request. The method always -// closes the http.Response Body. -func (c RegionClient) responderForListByService(resp *http.Response) (result ListByServiceOperationResponse, err error) { - type page struct { - Values []RegionContract `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 ListByServiceOperationResponse, err error) { - req, err := c.preparerForListByServiceWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "region.RegionClient", "ListByService", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "region.RegionClient", "ListByService", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByService(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "region.RegionClient", "ListByService", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListByServiceComplete retrieves all of the results into a single object -func (c RegionClient) ListByServiceComplete(ctx context.Context, id ServiceId) (ListByServiceCompleteResult, error) { - return c.ListByServiceCompleteMatchingPredicate(ctx, id, RegionContractOperationPredicate{}) -} - -// ListByServiceCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c RegionClient) ListByServiceCompleteMatchingPredicate(ctx context.Context, id ServiceId, predicate RegionContractOperationPredicate) (resp ListByServiceCompleteResult, err error) { - items := make([]RegionContract, 0) - - page, err := c.ListByService(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 := ListByServiceCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/apimanagement/2021-08-01/reports/client.go b/resource-manager/apimanagement/2021-08-01/reports/client.go index 605c74c6124..205fdeee8dd 100644 --- a/resource-manager/apimanagement/2021-08-01/reports/client.go +++ b/resource-manager/apimanagement/2021-08-01/reports/client.go @@ -1,18 +1,26 @@ package reports -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 ReportsClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewReportsClientWithBaseURI(endpoint string) ReportsClient { - return ReportsClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewReportsClientWithBaseURI(api environments.Api) (*ReportsClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "reports", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ReportsClient: %+v", err) } + + return &ReportsClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2021-08-01/reports/method_listbyapi.go b/resource-manager/apimanagement/2021-08-01/reports/method_listbyapi.go new file mode 100644 index 00000000000..06522bae2a6 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/reports/method_listbyapi.go @@ -0,0 +1,129 @@ +package reports + +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 ListByApiOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ReportRecordContract +} + +type ListByApiCompleteResult struct { + Items []ReportRecordContract +} + +type ListByApiOperationOptions struct { + Filter *string + Orderby *string + Skip *int64 + Top *int64 +} + +func DefaultListByApiOperationOptions() ListByApiOperationOptions { + return ListByApiOperationOptions{} +} + +func (o ListByApiOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListByApiOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListByApiOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.Orderby != nil { + out.Append("$orderby", fmt.Sprintf("%v", *o.Orderby)) + } + if o.Skip != nil { + out.Append("$skip", fmt.Sprintf("%v", *o.Skip)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +// ListByApi ... +func (c ReportsClient) ListByApi(ctx context.Context, id ServiceId, options ListByApiOperationOptions) (result ListByApiOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/reports/byApi", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ReportRecordContract `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByApiComplete retrieves all the results into a single object +func (c ReportsClient) ListByApiComplete(ctx context.Context, id ServiceId, options ListByApiOperationOptions) (ListByApiCompleteResult, error) { + return c.ListByApiCompleteMatchingPredicate(ctx, id, options, ReportRecordContractOperationPredicate{}) +} + +// ListByApiCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ReportsClient) ListByApiCompleteMatchingPredicate(ctx context.Context, id ServiceId, options ListByApiOperationOptions, predicate ReportRecordContractOperationPredicate) (result ListByApiCompleteResult, err error) { + items := make([]ReportRecordContract, 0) + + resp, err := c.ListByApi(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByApiCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/apimanagement/2021-08-01/reports/method_listbyapi_autorest.go b/resource-manager/apimanagement/2021-08-01/reports/method_listbyapi_autorest.go deleted file mode 100644 index 61513c4e70d..00000000000 --- a/resource-manager/apimanagement/2021-08-01/reports/method_listbyapi_autorest.go +++ /dev/null @@ -1,230 +0,0 @@ -package reports - -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 ListByApiOperationResponse struct { - HttpResponse *http.Response - Model *[]ReportRecordContract - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListByApiOperationResponse, error) -} - -type ListByApiCompleteResult struct { - Items []ReportRecordContract -} - -func (r ListByApiOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListByApiOperationResponse) LoadMore(ctx context.Context) (resp ListByApiOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -type ListByApiOperationOptions struct { - Filter *string - Orderby *string - Skip *int64 - Top *int64 -} - -func DefaultListByApiOperationOptions() ListByApiOperationOptions { - return ListByApiOperationOptions{} -} - -func (o ListByApiOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o ListByApiOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Filter != nil { - out["$filter"] = *o.Filter - } - - if o.Orderby != nil { - out["$orderby"] = *o.Orderby - } - - if o.Skip != nil { - out["$skip"] = *o.Skip - } - - if o.Top != nil { - out["$top"] = *o.Top - } - - return out -} - -// ListByApi ... -func (c ReportsClient) ListByApi(ctx context.Context, id ServiceId, options ListByApiOperationOptions) (resp ListByApiOperationResponse, err error) { - req, err := c.preparerForListByApi(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "reports.ReportsClient", "ListByApi", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "reports.ReportsClient", "ListByApi", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListByApi(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "reports.ReportsClient", "ListByApi", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListByApi prepares the ListByApi request. -func (c ReportsClient) preparerForListByApi(ctx context.Context, id ServiceId, options ListByApiOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/reports/byApi", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListByApiWithNextLink prepares the ListByApi request with the given nextLink token. -func (c ReportsClient) preparerForListByApiWithNextLink(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)) -} - -// responderForListByApi handles the response to the ListByApi request. The method always -// closes the http.Response Body. -func (c ReportsClient) responderForListByApi(resp *http.Response) (result ListByApiOperationResponse, err error) { - type page struct { - Values []ReportRecordContract `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 ListByApiOperationResponse, err error) { - req, err := c.preparerForListByApiWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "reports.ReportsClient", "ListByApi", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "reports.ReportsClient", "ListByApi", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByApi(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "reports.ReportsClient", "ListByApi", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListByApiComplete retrieves all of the results into a single object -func (c ReportsClient) ListByApiComplete(ctx context.Context, id ServiceId, options ListByApiOperationOptions) (ListByApiCompleteResult, error) { - return c.ListByApiCompleteMatchingPredicate(ctx, id, options, ReportRecordContractOperationPredicate{}) -} - -// ListByApiCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c ReportsClient) ListByApiCompleteMatchingPredicate(ctx context.Context, id ServiceId, options ListByApiOperationOptions, predicate ReportRecordContractOperationPredicate) (resp ListByApiCompleteResult, err error) { - items := make([]ReportRecordContract, 0) - - page, err := c.ListByApi(ctx, id, options) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListByApiCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/apimanagement/2021-08-01/reports/method_listbygeo.go b/resource-manager/apimanagement/2021-08-01/reports/method_listbygeo.go new file mode 100644 index 00000000000..2532e17d25b --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/reports/method_listbygeo.go @@ -0,0 +1,125 @@ +package reports + +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 ListByGeoOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ReportRecordContract +} + +type ListByGeoCompleteResult struct { + Items []ReportRecordContract +} + +type ListByGeoOperationOptions struct { + Filter *string + Skip *int64 + Top *int64 +} + +func DefaultListByGeoOperationOptions() ListByGeoOperationOptions { + return ListByGeoOperationOptions{} +} + +func (o ListByGeoOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListByGeoOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListByGeoOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.Skip != nil { + out.Append("$skip", fmt.Sprintf("%v", *o.Skip)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +// ListByGeo ... +func (c ReportsClient) ListByGeo(ctx context.Context, id ServiceId, options ListByGeoOperationOptions) (result ListByGeoOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/reports/byGeo", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ReportRecordContract `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByGeoComplete retrieves all the results into a single object +func (c ReportsClient) ListByGeoComplete(ctx context.Context, id ServiceId, options ListByGeoOperationOptions) (ListByGeoCompleteResult, error) { + return c.ListByGeoCompleteMatchingPredicate(ctx, id, options, ReportRecordContractOperationPredicate{}) +} + +// ListByGeoCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ReportsClient) ListByGeoCompleteMatchingPredicate(ctx context.Context, id ServiceId, options ListByGeoOperationOptions, predicate ReportRecordContractOperationPredicate) (result ListByGeoCompleteResult, err error) { + items := make([]ReportRecordContract, 0) + + resp, err := c.ListByGeo(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByGeoCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/apimanagement/2021-08-01/reports/method_listbygeo_autorest.go b/resource-manager/apimanagement/2021-08-01/reports/method_listbygeo_autorest.go deleted file mode 100644 index 946c693c961..00000000000 --- a/resource-manager/apimanagement/2021-08-01/reports/method_listbygeo_autorest.go +++ /dev/null @@ -1,225 +0,0 @@ -package reports - -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 ListByGeoOperationResponse struct { - HttpResponse *http.Response - Model *[]ReportRecordContract - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListByGeoOperationResponse, error) -} - -type ListByGeoCompleteResult struct { - Items []ReportRecordContract -} - -func (r ListByGeoOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListByGeoOperationResponse) LoadMore(ctx context.Context) (resp ListByGeoOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -type ListByGeoOperationOptions struct { - Filter *string - Skip *int64 - Top *int64 -} - -func DefaultListByGeoOperationOptions() ListByGeoOperationOptions { - return ListByGeoOperationOptions{} -} - -func (o ListByGeoOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o ListByGeoOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Filter != nil { - out["$filter"] = *o.Filter - } - - if o.Skip != nil { - out["$skip"] = *o.Skip - } - - if o.Top != nil { - out["$top"] = *o.Top - } - - return out -} - -// ListByGeo ... -func (c ReportsClient) ListByGeo(ctx context.Context, id ServiceId, options ListByGeoOperationOptions) (resp ListByGeoOperationResponse, err error) { - req, err := c.preparerForListByGeo(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "reports.ReportsClient", "ListByGeo", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "reports.ReportsClient", "ListByGeo", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListByGeo(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "reports.ReportsClient", "ListByGeo", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListByGeo prepares the ListByGeo request. -func (c ReportsClient) preparerForListByGeo(ctx context.Context, id ServiceId, options ListByGeoOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/reports/byGeo", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListByGeoWithNextLink prepares the ListByGeo request with the given nextLink token. -func (c ReportsClient) preparerForListByGeoWithNextLink(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)) -} - -// responderForListByGeo handles the response to the ListByGeo request. The method always -// closes the http.Response Body. -func (c ReportsClient) responderForListByGeo(resp *http.Response) (result ListByGeoOperationResponse, err error) { - type page struct { - Values []ReportRecordContract `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 ListByGeoOperationResponse, err error) { - req, err := c.preparerForListByGeoWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "reports.ReportsClient", "ListByGeo", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "reports.ReportsClient", "ListByGeo", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByGeo(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "reports.ReportsClient", "ListByGeo", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListByGeoComplete retrieves all of the results into a single object -func (c ReportsClient) ListByGeoComplete(ctx context.Context, id ServiceId, options ListByGeoOperationOptions) (ListByGeoCompleteResult, error) { - return c.ListByGeoCompleteMatchingPredicate(ctx, id, options, ReportRecordContractOperationPredicate{}) -} - -// ListByGeoCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c ReportsClient) ListByGeoCompleteMatchingPredicate(ctx context.Context, id ServiceId, options ListByGeoOperationOptions, predicate ReportRecordContractOperationPredicate) (resp ListByGeoCompleteResult, err error) { - items := make([]ReportRecordContract, 0) - - page, err := c.ListByGeo(ctx, id, options) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListByGeoCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/apimanagement/2021-08-01/reports/method_listbyoperation.go b/resource-manager/apimanagement/2021-08-01/reports/method_listbyoperation.go new file mode 100644 index 00000000000..80567e9f209 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/reports/method_listbyoperation.go @@ -0,0 +1,129 @@ +package reports + +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 ListByOperationOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ReportRecordContract +} + +type ListByOperationCompleteResult struct { + Items []ReportRecordContract +} + +type ListByOperationOperationOptions struct { + Filter *string + Orderby *string + Skip *int64 + Top *int64 +} + +func DefaultListByOperationOperationOptions() ListByOperationOperationOptions { + return ListByOperationOperationOptions{} +} + +func (o ListByOperationOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListByOperationOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListByOperationOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.Orderby != nil { + out.Append("$orderby", fmt.Sprintf("%v", *o.Orderby)) + } + if o.Skip != nil { + out.Append("$skip", fmt.Sprintf("%v", *o.Skip)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +// ListByOperation ... +func (c ReportsClient) ListByOperation(ctx context.Context, id ServiceId, options ListByOperationOperationOptions) (result ListByOperationOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/reports/byOperation", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ReportRecordContract `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByOperationComplete retrieves all the results into a single object +func (c ReportsClient) ListByOperationComplete(ctx context.Context, id ServiceId, options ListByOperationOperationOptions) (ListByOperationCompleteResult, error) { + return c.ListByOperationCompleteMatchingPredicate(ctx, id, options, ReportRecordContractOperationPredicate{}) +} + +// ListByOperationCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ReportsClient) ListByOperationCompleteMatchingPredicate(ctx context.Context, id ServiceId, options ListByOperationOperationOptions, predicate ReportRecordContractOperationPredicate) (result ListByOperationCompleteResult, err error) { + items := make([]ReportRecordContract, 0) + + resp, err := c.ListByOperation(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByOperationCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/apimanagement/2021-08-01/reports/method_listbyoperation_autorest.go b/resource-manager/apimanagement/2021-08-01/reports/method_listbyoperation_autorest.go deleted file mode 100644 index 3aa660eb04c..00000000000 --- a/resource-manager/apimanagement/2021-08-01/reports/method_listbyoperation_autorest.go +++ /dev/null @@ -1,230 +0,0 @@ -package reports - -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 ListByOperationOperationResponse struct { - HttpResponse *http.Response - Model *[]ReportRecordContract - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListByOperationOperationResponse, error) -} - -type ListByOperationCompleteResult struct { - Items []ReportRecordContract -} - -func (r ListByOperationOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListByOperationOperationResponse) LoadMore(ctx context.Context) (resp ListByOperationOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -type ListByOperationOperationOptions struct { - Filter *string - Orderby *string - Skip *int64 - Top *int64 -} - -func DefaultListByOperationOperationOptions() ListByOperationOperationOptions { - return ListByOperationOperationOptions{} -} - -func (o ListByOperationOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o ListByOperationOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Filter != nil { - out["$filter"] = *o.Filter - } - - if o.Orderby != nil { - out["$orderby"] = *o.Orderby - } - - if o.Skip != nil { - out["$skip"] = *o.Skip - } - - if o.Top != nil { - out["$top"] = *o.Top - } - - return out -} - -// ListByOperation ... -func (c ReportsClient) ListByOperation(ctx context.Context, id ServiceId, options ListByOperationOperationOptions) (resp ListByOperationOperationResponse, err error) { - req, err := c.preparerForListByOperation(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "reports.ReportsClient", "ListByOperation", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "reports.ReportsClient", "ListByOperation", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListByOperation(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "reports.ReportsClient", "ListByOperation", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListByOperation prepares the ListByOperation request. -func (c ReportsClient) preparerForListByOperation(ctx context.Context, id ServiceId, options ListByOperationOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/reports/byOperation", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListByOperationWithNextLink prepares the ListByOperation request with the given nextLink token. -func (c ReportsClient) preparerForListByOperationWithNextLink(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)) -} - -// responderForListByOperation handles the response to the ListByOperation request. The method always -// closes the http.Response Body. -func (c ReportsClient) responderForListByOperation(resp *http.Response) (result ListByOperationOperationResponse, err error) { - type page struct { - Values []ReportRecordContract `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 ListByOperationOperationResponse, err error) { - req, err := c.preparerForListByOperationWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "reports.ReportsClient", "ListByOperation", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "reports.ReportsClient", "ListByOperation", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByOperation(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "reports.ReportsClient", "ListByOperation", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListByOperationComplete retrieves all of the results into a single object -func (c ReportsClient) ListByOperationComplete(ctx context.Context, id ServiceId, options ListByOperationOperationOptions) (ListByOperationCompleteResult, error) { - return c.ListByOperationCompleteMatchingPredicate(ctx, id, options, ReportRecordContractOperationPredicate{}) -} - -// ListByOperationCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c ReportsClient) ListByOperationCompleteMatchingPredicate(ctx context.Context, id ServiceId, options ListByOperationOperationOptions, predicate ReportRecordContractOperationPredicate) (resp ListByOperationCompleteResult, err error) { - items := make([]ReportRecordContract, 0) - - page, err := c.ListByOperation(ctx, id, options) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListByOperationCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/apimanagement/2021-08-01/reports/method_listbyproduct.go b/resource-manager/apimanagement/2021-08-01/reports/method_listbyproduct.go new file mode 100644 index 00000000000..de187303948 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/reports/method_listbyproduct.go @@ -0,0 +1,129 @@ +package reports + +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 ListByProductOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ReportRecordContract +} + +type ListByProductCompleteResult struct { + Items []ReportRecordContract +} + +type ListByProductOperationOptions struct { + Filter *string + Orderby *string + Skip *int64 + Top *int64 +} + +func DefaultListByProductOperationOptions() ListByProductOperationOptions { + return ListByProductOperationOptions{} +} + +func (o ListByProductOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListByProductOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListByProductOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.Orderby != nil { + out.Append("$orderby", fmt.Sprintf("%v", *o.Orderby)) + } + if o.Skip != nil { + out.Append("$skip", fmt.Sprintf("%v", *o.Skip)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +// ListByProduct ... +func (c ReportsClient) ListByProduct(ctx context.Context, id ServiceId, options ListByProductOperationOptions) (result ListByProductOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/reports/byProduct", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ReportRecordContract `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByProductComplete retrieves all the results into a single object +func (c ReportsClient) ListByProductComplete(ctx context.Context, id ServiceId, options ListByProductOperationOptions) (ListByProductCompleteResult, error) { + return c.ListByProductCompleteMatchingPredicate(ctx, id, options, ReportRecordContractOperationPredicate{}) +} + +// ListByProductCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ReportsClient) ListByProductCompleteMatchingPredicate(ctx context.Context, id ServiceId, options ListByProductOperationOptions, predicate ReportRecordContractOperationPredicate) (result ListByProductCompleteResult, err error) { + items := make([]ReportRecordContract, 0) + + resp, err := c.ListByProduct(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByProductCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/apimanagement/2021-08-01/reports/method_listbyproduct_autorest.go b/resource-manager/apimanagement/2021-08-01/reports/method_listbyproduct_autorest.go deleted file mode 100644 index 507a05240b8..00000000000 --- a/resource-manager/apimanagement/2021-08-01/reports/method_listbyproduct_autorest.go +++ /dev/null @@ -1,230 +0,0 @@ -package reports - -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 ListByProductOperationResponse struct { - HttpResponse *http.Response - Model *[]ReportRecordContract - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListByProductOperationResponse, error) -} - -type ListByProductCompleteResult struct { - Items []ReportRecordContract -} - -func (r ListByProductOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListByProductOperationResponse) LoadMore(ctx context.Context) (resp ListByProductOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -type ListByProductOperationOptions struct { - Filter *string - Orderby *string - Skip *int64 - Top *int64 -} - -func DefaultListByProductOperationOptions() ListByProductOperationOptions { - return ListByProductOperationOptions{} -} - -func (o ListByProductOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o ListByProductOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Filter != nil { - out["$filter"] = *o.Filter - } - - if o.Orderby != nil { - out["$orderby"] = *o.Orderby - } - - if o.Skip != nil { - out["$skip"] = *o.Skip - } - - if o.Top != nil { - out["$top"] = *o.Top - } - - return out -} - -// ListByProduct ... -func (c ReportsClient) ListByProduct(ctx context.Context, id ServiceId, options ListByProductOperationOptions) (resp ListByProductOperationResponse, err error) { - req, err := c.preparerForListByProduct(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "reports.ReportsClient", "ListByProduct", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "reports.ReportsClient", "ListByProduct", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListByProduct(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "reports.ReportsClient", "ListByProduct", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListByProduct prepares the ListByProduct request. -func (c ReportsClient) preparerForListByProduct(ctx context.Context, id ServiceId, options ListByProductOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/reports/byProduct", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListByProductWithNextLink prepares the ListByProduct request with the given nextLink token. -func (c ReportsClient) preparerForListByProductWithNextLink(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)) -} - -// responderForListByProduct handles the response to the ListByProduct request. The method always -// closes the http.Response Body. -func (c ReportsClient) responderForListByProduct(resp *http.Response) (result ListByProductOperationResponse, err error) { - type page struct { - Values []ReportRecordContract `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 ListByProductOperationResponse, err error) { - req, err := c.preparerForListByProductWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "reports.ReportsClient", "ListByProduct", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "reports.ReportsClient", "ListByProduct", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByProduct(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "reports.ReportsClient", "ListByProduct", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListByProductComplete retrieves all of the results into a single object -func (c ReportsClient) ListByProductComplete(ctx context.Context, id ServiceId, options ListByProductOperationOptions) (ListByProductCompleteResult, error) { - return c.ListByProductCompleteMatchingPredicate(ctx, id, options, ReportRecordContractOperationPredicate{}) -} - -// ListByProductCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c ReportsClient) ListByProductCompleteMatchingPredicate(ctx context.Context, id ServiceId, options ListByProductOperationOptions, predicate ReportRecordContractOperationPredicate) (resp ListByProductCompleteResult, err error) { - items := make([]ReportRecordContract, 0) - - page, err := c.ListByProduct(ctx, id, options) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListByProductCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/apimanagement/2021-08-01/reports/method_listbyrequest.go b/resource-manager/apimanagement/2021-08-01/reports/method_listbyrequest.go new file mode 100644 index 00000000000..bd4c8b54a0d --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/reports/method_listbyrequest.go @@ -0,0 +1,88 @@ +package reports + +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 ListByRequestOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *RequestReportCollection +} + +type ListByRequestOperationOptions struct { + Filter *string + Skip *int64 + Top *int64 +} + +func DefaultListByRequestOperationOptions() ListByRequestOperationOptions { + return ListByRequestOperationOptions{} +} + +func (o ListByRequestOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListByRequestOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListByRequestOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.Skip != nil { + out.Append("$skip", fmt.Sprintf("%v", *o.Skip)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +// ListByRequest ... +func (c ReportsClient) ListByRequest(ctx context.Context, id ServiceId, options ListByRequestOperationOptions) (result ListByRequestOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/reports/byRequest", id.ID()), + OptionsObject: options, + } + + 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/apimanagement/2021-08-01/reports/method_listbyrequest_autorest.go b/resource-manager/apimanagement/2021-08-01/reports/method_listbyrequest_autorest.go deleted file mode 100644 index 27f2a2395ef..00000000000 --- a/resource-manager/apimanagement/2021-08-01/reports/method_listbyrequest_autorest.go +++ /dev/null @@ -1,108 +0,0 @@ -package reports - -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 ListByRequestOperationResponse struct { - HttpResponse *http.Response - Model *RequestReportCollection -} - -type ListByRequestOperationOptions struct { - Filter *string - Skip *int64 - Top *int64 -} - -func DefaultListByRequestOperationOptions() ListByRequestOperationOptions { - return ListByRequestOperationOptions{} -} - -func (o ListByRequestOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o ListByRequestOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Filter != nil { - out["$filter"] = *o.Filter - } - - if o.Skip != nil { - out["$skip"] = *o.Skip - } - - if o.Top != nil { - out["$top"] = *o.Top - } - - return out -} - -// ListByRequest ... -func (c ReportsClient) ListByRequest(ctx context.Context, id ServiceId, options ListByRequestOperationOptions) (result ListByRequestOperationResponse, err error) { - req, err := c.preparerForListByRequest(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "reports.ReportsClient", "ListByRequest", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "reports.ReportsClient", "ListByRequest", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByRequest(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "reports.ReportsClient", "ListByRequest", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForListByRequest prepares the ListByRequest request. -func (c ReportsClient) preparerForListByRequest(ctx context.Context, id ServiceId, options ListByRequestOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/reports/byRequest", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListByRequest handles the response to the ListByRequest request. The method always -// closes the http.Response Body. -func (c ReportsClient) responderForListByRequest(resp *http.Response) (result ListByRequestOperationResponse, 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/apimanagement/2021-08-01/reports/method_listbysubscription.go b/resource-manager/apimanagement/2021-08-01/reports/method_listbysubscription.go new file mode 100644 index 00000000000..22df641c1c4 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/reports/method_listbysubscription.go @@ -0,0 +1,129 @@ +package reports + +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 ListBySubscriptionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ReportRecordContract +} + +type ListBySubscriptionCompleteResult struct { + Items []ReportRecordContract +} + +type ListBySubscriptionOperationOptions struct { + Filter *string + Orderby *string + Skip *int64 + Top *int64 +} + +func DefaultListBySubscriptionOperationOptions() ListBySubscriptionOperationOptions { + return ListBySubscriptionOperationOptions{} +} + +func (o ListBySubscriptionOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListBySubscriptionOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListBySubscriptionOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.Orderby != nil { + out.Append("$orderby", fmt.Sprintf("%v", *o.Orderby)) + } + if o.Skip != nil { + out.Append("$skip", fmt.Sprintf("%v", *o.Skip)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +// ListBySubscription ... +func (c ReportsClient) ListBySubscription(ctx context.Context, id ServiceId, options ListBySubscriptionOperationOptions) (result ListBySubscriptionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/reports/bySubscription", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ReportRecordContract `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 ReportsClient) ListBySubscriptionComplete(ctx context.Context, id ServiceId, options ListBySubscriptionOperationOptions) (ListBySubscriptionCompleteResult, error) { + return c.ListBySubscriptionCompleteMatchingPredicate(ctx, id, options, ReportRecordContractOperationPredicate{}) +} + +// ListBySubscriptionCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ReportsClient) ListBySubscriptionCompleteMatchingPredicate(ctx context.Context, id ServiceId, options ListBySubscriptionOperationOptions, predicate ReportRecordContractOperationPredicate) (result ListBySubscriptionCompleteResult, err error) { + items := make([]ReportRecordContract, 0) + + resp, err := c.ListBySubscription(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListBySubscriptionCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/apimanagement/2021-08-01/reports/method_listbysubscription_autorest.go b/resource-manager/apimanagement/2021-08-01/reports/method_listbysubscription_autorest.go deleted file mode 100644 index e0c5065d369..00000000000 --- a/resource-manager/apimanagement/2021-08-01/reports/method_listbysubscription_autorest.go +++ /dev/null @@ -1,230 +0,0 @@ -package reports - -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 ListBySubscriptionOperationResponse struct { - HttpResponse *http.Response - Model *[]ReportRecordContract - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListBySubscriptionOperationResponse, error) -} - -type ListBySubscriptionCompleteResult struct { - Items []ReportRecordContract -} - -func (r ListBySubscriptionOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListBySubscriptionOperationResponse) LoadMore(ctx context.Context) (resp ListBySubscriptionOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -type ListBySubscriptionOperationOptions struct { - Filter *string - Orderby *string - Skip *int64 - Top *int64 -} - -func DefaultListBySubscriptionOperationOptions() ListBySubscriptionOperationOptions { - return ListBySubscriptionOperationOptions{} -} - -func (o ListBySubscriptionOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o ListBySubscriptionOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Filter != nil { - out["$filter"] = *o.Filter - } - - if o.Orderby != nil { - out["$orderby"] = *o.Orderby - } - - if o.Skip != nil { - out["$skip"] = *o.Skip - } - - if o.Top != nil { - out["$top"] = *o.Top - } - - return out -} - -// ListBySubscription ... -func (c ReportsClient) ListBySubscription(ctx context.Context, id ServiceId, options ListBySubscriptionOperationOptions) (resp ListBySubscriptionOperationResponse, err error) { - req, err := c.preparerForListBySubscription(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "reports.ReportsClient", "ListBySubscription", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "reports.ReportsClient", "ListBySubscription", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListBySubscription(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "reports.ReportsClient", "ListBySubscription", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListBySubscription prepares the ListBySubscription request. -func (c ReportsClient) preparerForListBySubscription(ctx context.Context, id ServiceId, options ListBySubscriptionOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/reports/bySubscription", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListBySubscriptionWithNextLink prepares the ListBySubscription request with the given nextLink token. -func (c ReportsClient) 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 ReportsClient) responderForListBySubscription(resp *http.Response) (result ListBySubscriptionOperationResponse, err error) { - type page struct { - Values []ReportRecordContract `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, "reports.ReportsClient", "ListBySubscription", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "reports.ReportsClient", "ListBySubscription", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListBySubscription(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "reports.ReportsClient", "ListBySubscription", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListBySubscriptionComplete retrieves all of the results into a single object -func (c ReportsClient) ListBySubscriptionComplete(ctx context.Context, id ServiceId, options ListBySubscriptionOperationOptions) (ListBySubscriptionCompleteResult, error) { - return c.ListBySubscriptionCompleteMatchingPredicate(ctx, id, options, ReportRecordContractOperationPredicate{}) -} - -// ListBySubscriptionCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c ReportsClient) ListBySubscriptionCompleteMatchingPredicate(ctx context.Context, id ServiceId, options ListBySubscriptionOperationOptions, predicate ReportRecordContractOperationPredicate) (resp ListBySubscriptionCompleteResult, err error) { - items := make([]ReportRecordContract, 0) - - page, err := c.ListBySubscription(ctx, id, options) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListBySubscriptionCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/apimanagement/2021-08-01/reports/method_listbytime.go b/resource-manager/apimanagement/2021-08-01/reports/method_listbytime.go new file mode 100644 index 00000000000..7667748e6bb --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/reports/method_listbytime.go @@ -0,0 +1,133 @@ +package reports + +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 ListByTimeOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ReportRecordContract +} + +type ListByTimeCompleteResult struct { + Items []ReportRecordContract +} + +type ListByTimeOperationOptions struct { + Filter *string + Interval *string + Orderby *string + Skip *int64 + Top *int64 +} + +func DefaultListByTimeOperationOptions() ListByTimeOperationOptions { + return ListByTimeOperationOptions{} +} + +func (o ListByTimeOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListByTimeOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListByTimeOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.Interval != nil { + out.Append("interval", fmt.Sprintf("%v", *o.Interval)) + } + if o.Orderby != nil { + out.Append("$orderby", fmt.Sprintf("%v", *o.Orderby)) + } + if o.Skip != nil { + out.Append("$skip", fmt.Sprintf("%v", *o.Skip)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +// ListByTime ... +func (c ReportsClient) ListByTime(ctx context.Context, id ServiceId, options ListByTimeOperationOptions) (result ListByTimeOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/reports/byTime", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ReportRecordContract `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByTimeComplete retrieves all the results into a single object +func (c ReportsClient) ListByTimeComplete(ctx context.Context, id ServiceId, options ListByTimeOperationOptions) (ListByTimeCompleteResult, error) { + return c.ListByTimeCompleteMatchingPredicate(ctx, id, options, ReportRecordContractOperationPredicate{}) +} + +// ListByTimeCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ReportsClient) ListByTimeCompleteMatchingPredicate(ctx context.Context, id ServiceId, options ListByTimeOperationOptions, predicate ReportRecordContractOperationPredicate) (result ListByTimeCompleteResult, err error) { + items := make([]ReportRecordContract, 0) + + resp, err := c.ListByTime(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByTimeCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/apimanagement/2021-08-01/reports/method_listbytime_autorest.go b/resource-manager/apimanagement/2021-08-01/reports/method_listbytime_autorest.go deleted file mode 100644 index b13857ba750..00000000000 --- a/resource-manager/apimanagement/2021-08-01/reports/method_listbytime_autorest.go +++ /dev/null @@ -1,235 +0,0 @@ -package reports - -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 ListByTimeOperationResponse struct { - HttpResponse *http.Response - Model *[]ReportRecordContract - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListByTimeOperationResponse, error) -} - -type ListByTimeCompleteResult struct { - Items []ReportRecordContract -} - -func (r ListByTimeOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListByTimeOperationResponse) LoadMore(ctx context.Context) (resp ListByTimeOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -type ListByTimeOperationOptions struct { - Filter *string - Interval *string - Orderby *string - Skip *int64 - Top *int64 -} - -func DefaultListByTimeOperationOptions() ListByTimeOperationOptions { - return ListByTimeOperationOptions{} -} - -func (o ListByTimeOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o ListByTimeOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Filter != nil { - out["$filter"] = *o.Filter - } - - if o.Interval != nil { - out["interval"] = *o.Interval - } - - if o.Orderby != nil { - out["$orderby"] = *o.Orderby - } - - if o.Skip != nil { - out["$skip"] = *o.Skip - } - - if o.Top != nil { - out["$top"] = *o.Top - } - - return out -} - -// ListByTime ... -func (c ReportsClient) ListByTime(ctx context.Context, id ServiceId, options ListByTimeOperationOptions) (resp ListByTimeOperationResponse, err error) { - req, err := c.preparerForListByTime(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "reports.ReportsClient", "ListByTime", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "reports.ReportsClient", "ListByTime", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListByTime(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "reports.ReportsClient", "ListByTime", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListByTime prepares the ListByTime request. -func (c ReportsClient) preparerForListByTime(ctx context.Context, id ServiceId, options ListByTimeOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/reports/byTime", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListByTimeWithNextLink prepares the ListByTime request with the given nextLink token. -func (c ReportsClient) preparerForListByTimeWithNextLink(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)) -} - -// responderForListByTime handles the response to the ListByTime request. The method always -// closes the http.Response Body. -func (c ReportsClient) responderForListByTime(resp *http.Response) (result ListByTimeOperationResponse, err error) { - type page struct { - Values []ReportRecordContract `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 ListByTimeOperationResponse, err error) { - req, err := c.preparerForListByTimeWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "reports.ReportsClient", "ListByTime", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "reports.ReportsClient", "ListByTime", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByTime(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "reports.ReportsClient", "ListByTime", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListByTimeComplete retrieves all of the results into a single object -func (c ReportsClient) ListByTimeComplete(ctx context.Context, id ServiceId, options ListByTimeOperationOptions) (ListByTimeCompleteResult, error) { - return c.ListByTimeCompleteMatchingPredicate(ctx, id, options, ReportRecordContractOperationPredicate{}) -} - -// ListByTimeCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c ReportsClient) ListByTimeCompleteMatchingPredicate(ctx context.Context, id ServiceId, options ListByTimeOperationOptions, predicate ReportRecordContractOperationPredicate) (resp ListByTimeCompleteResult, err error) { - items := make([]ReportRecordContract, 0) - - page, err := c.ListByTime(ctx, id, options) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListByTimeCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/apimanagement/2021-08-01/reports/method_listbyuser.go b/resource-manager/apimanagement/2021-08-01/reports/method_listbyuser.go new file mode 100644 index 00000000000..66a39254bdc --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/reports/method_listbyuser.go @@ -0,0 +1,129 @@ +package reports + +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 ListByUserOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ReportRecordContract +} + +type ListByUserCompleteResult struct { + Items []ReportRecordContract +} + +type ListByUserOperationOptions struct { + Filter *string + Orderby *string + Skip *int64 + Top *int64 +} + +func DefaultListByUserOperationOptions() ListByUserOperationOptions { + return ListByUserOperationOptions{} +} + +func (o ListByUserOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListByUserOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListByUserOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.Orderby != nil { + out.Append("$orderby", fmt.Sprintf("%v", *o.Orderby)) + } + if o.Skip != nil { + out.Append("$skip", fmt.Sprintf("%v", *o.Skip)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +// ListByUser ... +func (c ReportsClient) ListByUser(ctx context.Context, id ServiceId, options ListByUserOperationOptions) (result ListByUserOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/reports/byUser", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ReportRecordContract `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByUserComplete retrieves all the results into a single object +func (c ReportsClient) ListByUserComplete(ctx context.Context, id ServiceId, options ListByUserOperationOptions) (ListByUserCompleteResult, error) { + return c.ListByUserCompleteMatchingPredicate(ctx, id, options, ReportRecordContractOperationPredicate{}) +} + +// ListByUserCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ReportsClient) ListByUserCompleteMatchingPredicate(ctx context.Context, id ServiceId, options ListByUserOperationOptions, predicate ReportRecordContractOperationPredicate) (result ListByUserCompleteResult, err error) { + items := make([]ReportRecordContract, 0) + + resp, err := c.ListByUser(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByUserCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/apimanagement/2021-08-01/reports/method_listbyuser_autorest.go b/resource-manager/apimanagement/2021-08-01/reports/method_listbyuser_autorest.go deleted file mode 100644 index 2bd9f434043..00000000000 --- a/resource-manager/apimanagement/2021-08-01/reports/method_listbyuser_autorest.go +++ /dev/null @@ -1,230 +0,0 @@ -package reports - -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 ListByUserOperationResponse struct { - HttpResponse *http.Response - Model *[]ReportRecordContract - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListByUserOperationResponse, error) -} - -type ListByUserCompleteResult struct { - Items []ReportRecordContract -} - -func (r ListByUserOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListByUserOperationResponse) LoadMore(ctx context.Context) (resp ListByUserOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -type ListByUserOperationOptions struct { - Filter *string - Orderby *string - Skip *int64 - Top *int64 -} - -func DefaultListByUserOperationOptions() ListByUserOperationOptions { - return ListByUserOperationOptions{} -} - -func (o ListByUserOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o ListByUserOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Filter != nil { - out["$filter"] = *o.Filter - } - - if o.Orderby != nil { - out["$orderby"] = *o.Orderby - } - - if o.Skip != nil { - out["$skip"] = *o.Skip - } - - if o.Top != nil { - out["$top"] = *o.Top - } - - return out -} - -// ListByUser ... -func (c ReportsClient) ListByUser(ctx context.Context, id ServiceId, options ListByUserOperationOptions) (resp ListByUserOperationResponse, err error) { - req, err := c.preparerForListByUser(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "reports.ReportsClient", "ListByUser", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "reports.ReportsClient", "ListByUser", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListByUser(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "reports.ReportsClient", "ListByUser", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListByUser prepares the ListByUser request. -func (c ReportsClient) preparerForListByUser(ctx context.Context, id ServiceId, options ListByUserOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/reports/byUser", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListByUserWithNextLink prepares the ListByUser request with the given nextLink token. -func (c ReportsClient) preparerForListByUserWithNextLink(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)) -} - -// responderForListByUser handles the response to the ListByUser request. The method always -// closes the http.Response Body. -func (c ReportsClient) responderForListByUser(resp *http.Response) (result ListByUserOperationResponse, err error) { - type page struct { - Values []ReportRecordContract `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 ListByUserOperationResponse, err error) { - req, err := c.preparerForListByUserWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "reports.ReportsClient", "ListByUser", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "reports.ReportsClient", "ListByUser", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByUser(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "reports.ReportsClient", "ListByUser", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListByUserComplete retrieves all of the results into a single object -func (c ReportsClient) ListByUserComplete(ctx context.Context, id ServiceId, options ListByUserOperationOptions) (ListByUserCompleteResult, error) { - return c.ListByUserCompleteMatchingPredicate(ctx, id, options, ReportRecordContractOperationPredicate{}) -} - -// ListByUserCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c ReportsClient) ListByUserCompleteMatchingPredicate(ctx context.Context, id ServiceId, options ListByUserOperationOptions, predicate ReportRecordContractOperationPredicate) (resp ListByUserCompleteResult, err error) { - items := make([]ReportRecordContract, 0) - - page, err := c.ListByUser(ctx, id, options) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListByUserCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/apimanagement/2021-08-01/schema/client.go b/resource-manager/apimanagement/2021-08-01/schema/client.go index 8905f2ce375..f9692a57f2f 100644 --- a/resource-manager/apimanagement/2021-08-01/schema/client.go +++ b/resource-manager/apimanagement/2021-08-01/schema/client.go @@ -1,18 +1,26 @@ package schema -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 SchemaClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewSchemaClientWithBaseURI(endpoint string) SchemaClient { - return SchemaClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewSchemaClientWithBaseURI(api environments.Api) (*SchemaClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "schema", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating SchemaClient: %+v", err) } + + return &SchemaClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2021-08-01/schema/constants.go b/resource-manager/apimanagement/2021-08-01/schema/constants.go index ab4513e2c37..fc6c0c9faf6 100644 --- a/resource-manager/apimanagement/2021-08-01/schema/constants.go +++ b/resource-manager/apimanagement/2021-08-01/schema/constants.go @@ -1,6 +1,10 @@ package schema -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 PossibleValuesForSchemaType() []string { } } +func (s *SchemaType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSchemaType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseSchemaType(input string) (*SchemaType, error) { vals := map[string]SchemaType{ "json": SchemaTypeJson, diff --git a/resource-manager/apimanagement/2021-08-01/schema/method_globalschemacreateorupdate.go b/resource-manager/apimanagement/2021-08-01/schema/method_globalschemacreateorupdate.go new file mode 100644 index 00000000000..3e9e658a682 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/schema/method_globalschemacreateorupdate.go @@ -0,0 +1,103 @@ +package schema + +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 GlobalSchemaCreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +type GlobalSchemaCreateOrUpdateOperationOptions struct { + IfMatch *string +} + +func DefaultGlobalSchemaCreateOrUpdateOperationOptions() GlobalSchemaCreateOrUpdateOperationOptions { + return GlobalSchemaCreateOrUpdateOperationOptions{} +} + +func (o GlobalSchemaCreateOrUpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o GlobalSchemaCreateOrUpdateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o GlobalSchemaCreateOrUpdateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// GlobalSchemaCreateOrUpdate ... +func (c SchemaClient) GlobalSchemaCreateOrUpdate(ctx context.Context, id SchemaId, input GlobalSchemaContract, options GlobalSchemaCreateOrUpdateOperationOptions) (result GlobalSchemaCreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + OptionsObject: options, + } + + 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 +} + +// GlobalSchemaCreateOrUpdateThenPoll performs GlobalSchemaCreateOrUpdate then polls until it's completed +func (c SchemaClient) GlobalSchemaCreateOrUpdateThenPoll(ctx context.Context, id SchemaId, input GlobalSchemaContract, options GlobalSchemaCreateOrUpdateOperationOptions) error { + result, err := c.GlobalSchemaCreateOrUpdate(ctx, id, input, options) + if err != nil { + return fmt.Errorf("performing GlobalSchemaCreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after GlobalSchemaCreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/apimanagement/2021-08-01/schema/method_globalschemacreateorupdate_autorest.go b/resource-manager/apimanagement/2021-08-01/schema/method_globalschemacreateorupdate_autorest.go deleted file mode 100644 index 169dc63374e..00000000000 --- a/resource-manager/apimanagement/2021-08-01/schema/method_globalschemacreateorupdate_autorest.go +++ /dev/null @@ -1,108 +0,0 @@ -package schema - -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 GlobalSchemaCreateOrUpdateOperationResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -type GlobalSchemaCreateOrUpdateOperationOptions struct { - IfMatch *string -} - -func DefaultGlobalSchemaCreateOrUpdateOperationOptions() GlobalSchemaCreateOrUpdateOperationOptions { - return GlobalSchemaCreateOrUpdateOperationOptions{} -} - -func (o GlobalSchemaCreateOrUpdateOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o GlobalSchemaCreateOrUpdateOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// GlobalSchemaCreateOrUpdate ... -func (c SchemaClient) GlobalSchemaCreateOrUpdate(ctx context.Context, id SchemaId, input GlobalSchemaContract, options GlobalSchemaCreateOrUpdateOperationOptions) (result GlobalSchemaCreateOrUpdateOperationResponse, err error) { - req, err := c.preparerForGlobalSchemaCreateOrUpdate(ctx, id, input, options) - if err != nil { - err = autorest.NewErrorWithError(err, "schema.SchemaClient", "GlobalSchemaCreateOrUpdate", nil, "Failure preparing request") - return - } - - result, err = c.senderForGlobalSchemaCreateOrUpdate(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "schema.SchemaClient", "GlobalSchemaCreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// GlobalSchemaCreateOrUpdateThenPoll performs GlobalSchemaCreateOrUpdate then polls until it's completed -func (c SchemaClient) GlobalSchemaCreateOrUpdateThenPoll(ctx context.Context, id SchemaId, input GlobalSchemaContract, options GlobalSchemaCreateOrUpdateOperationOptions) error { - result, err := c.GlobalSchemaCreateOrUpdate(ctx, id, input, options) - if err != nil { - return fmt.Errorf("performing GlobalSchemaCreateOrUpdate: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after GlobalSchemaCreateOrUpdate: %+v", err) - } - - return nil -} - -// preparerForGlobalSchemaCreateOrUpdate prepares the GlobalSchemaCreateOrUpdate request. -func (c SchemaClient) preparerForGlobalSchemaCreateOrUpdate(ctx context.Context, id SchemaId, input GlobalSchemaContract, options GlobalSchemaCreateOrUpdateOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForGlobalSchemaCreateOrUpdate sends the GlobalSchemaCreateOrUpdate request. The method will close the -// http.Response Body if it receives an error. -func (c SchemaClient) senderForGlobalSchemaCreateOrUpdate(ctx context.Context, req *http.Request) (future GlobalSchemaCreateOrUpdateOperationResponse, 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/apimanagement/2021-08-01/schema/method_globalschemadelete.go b/resource-manager/apimanagement/2021-08-01/schema/method_globalschemadelete.go new file mode 100644 index 00000000000..f7169489c2b --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/schema/method_globalschemadelete.go @@ -0,0 +1,76 @@ +package schema + +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 GlobalSchemaDeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +type GlobalSchemaDeleteOperationOptions struct { + IfMatch *string +} + +func DefaultGlobalSchemaDeleteOperationOptions() GlobalSchemaDeleteOperationOptions { + return GlobalSchemaDeleteOperationOptions{} +} + +func (o GlobalSchemaDeleteOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o GlobalSchemaDeleteOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o GlobalSchemaDeleteOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// GlobalSchemaDelete ... +func (c SchemaClient) GlobalSchemaDelete(ctx context.Context, id SchemaId, options GlobalSchemaDeleteOperationOptions) (result GlobalSchemaDeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2021-08-01/schema/method_globalschemadelete_autorest.go b/resource-manager/apimanagement/2021-08-01/schema/method_globalschemadelete_autorest.go deleted file mode 100644 index ec3f0417e40..00000000000 --- a/resource-manager/apimanagement/2021-08-01/schema/method_globalschemadelete_autorest.go +++ /dev/null @@ -1,95 +0,0 @@ -package schema - -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 GlobalSchemaDeleteOperationResponse struct { - HttpResponse *http.Response -} - -type GlobalSchemaDeleteOperationOptions struct { - IfMatch *string -} - -func DefaultGlobalSchemaDeleteOperationOptions() GlobalSchemaDeleteOperationOptions { - return GlobalSchemaDeleteOperationOptions{} -} - -func (o GlobalSchemaDeleteOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o GlobalSchemaDeleteOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// GlobalSchemaDelete ... -func (c SchemaClient) GlobalSchemaDelete(ctx context.Context, id SchemaId, options GlobalSchemaDeleteOperationOptions) (result GlobalSchemaDeleteOperationResponse, err error) { - req, err := c.preparerForGlobalSchemaDelete(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "schema.SchemaClient", "GlobalSchemaDelete", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "schema.SchemaClient", "GlobalSchemaDelete", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGlobalSchemaDelete(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "schema.SchemaClient", "GlobalSchemaDelete", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGlobalSchemaDelete prepares the GlobalSchemaDelete request. -func (c SchemaClient) preparerForGlobalSchemaDelete(ctx context.Context, id SchemaId, options GlobalSchemaDeleteOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGlobalSchemaDelete handles the response to the GlobalSchemaDelete request. The method always -// closes the http.Response Body. -func (c SchemaClient) responderForGlobalSchemaDelete(resp *http.Response) (result GlobalSchemaDeleteOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2021-08-01/schema/method_globalschemaget.go b/resource-manager/apimanagement/2021-08-01/schema/method_globalschemaget.go new file mode 100644 index 00000000000..3d7e9fd46ef --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/schema/method_globalschemaget.go @@ -0,0 +1,51 @@ +package schema + +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 GlobalSchemaGetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *GlobalSchemaContract +} + +// GlobalSchemaGet ... +func (c SchemaClient) GlobalSchemaGet(ctx context.Context, id SchemaId) (result GlobalSchemaGetOperationResponse, 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/apimanagement/2021-08-01/schema/method_globalschemaget_autorest.go b/resource-manager/apimanagement/2021-08-01/schema/method_globalschemaget_autorest.go deleted file mode 100644 index d87e67a9d30..00000000000 --- a/resource-manager/apimanagement/2021-08-01/schema/method_globalschemaget_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package schema - -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 GlobalSchemaGetOperationResponse struct { - HttpResponse *http.Response - Model *GlobalSchemaContract -} - -// GlobalSchemaGet ... -func (c SchemaClient) GlobalSchemaGet(ctx context.Context, id SchemaId) (result GlobalSchemaGetOperationResponse, err error) { - req, err := c.preparerForGlobalSchemaGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "schema.SchemaClient", "GlobalSchemaGet", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "schema.SchemaClient", "GlobalSchemaGet", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGlobalSchemaGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "schema.SchemaClient", "GlobalSchemaGet", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGlobalSchemaGet prepares the GlobalSchemaGet request. -func (c SchemaClient) preparerForGlobalSchemaGet(ctx context.Context, id SchemaId) (*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)) -} - -// responderForGlobalSchemaGet handles the response to the GlobalSchemaGet request. The method always -// closes the http.Response Body. -func (c SchemaClient) responderForGlobalSchemaGet(resp *http.Response) (result GlobalSchemaGetOperationResponse, 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/apimanagement/2021-08-01/schema/method_globalschemagetentitytag.go b/resource-manager/apimanagement/2021-08-01/schema/method_globalschemagetentitytag.go new file mode 100644 index 00000000000..b62a3956afc --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/schema/method_globalschemagetentitytag.go @@ -0,0 +1,46 @@ +package schema + +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 GlobalSchemaGetEntityTagOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// GlobalSchemaGetEntityTag ... +func (c SchemaClient) GlobalSchemaGetEntityTag(ctx context.Context, id SchemaId) (result GlobalSchemaGetEntityTagOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodHead, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2021-08-01/schema/method_globalschemagetentitytag_autorest.go b/resource-manager/apimanagement/2021-08-01/schema/method_globalschemagetentitytag_autorest.go deleted file mode 100644 index a02a95a3402..00000000000 --- a/resource-manager/apimanagement/2021-08-01/schema/method_globalschemagetentitytag_autorest.go +++ /dev/null @@ -1,66 +0,0 @@ -package schema - -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 GlobalSchemaGetEntityTagOperationResponse struct { - HttpResponse *http.Response -} - -// GlobalSchemaGetEntityTag ... -func (c SchemaClient) GlobalSchemaGetEntityTag(ctx context.Context, id SchemaId) (result GlobalSchemaGetEntityTagOperationResponse, err error) { - req, err := c.preparerForGlobalSchemaGetEntityTag(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "schema.SchemaClient", "GlobalSchemaGetEntityTag", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "schema.SchemaClient", "GlobalSchemaGetEntityTag", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGlobalSchemaGetEntityTag(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "schema.SchemaClient", "GlobalSchemaGetEntityTag", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGlobalSchemaGetEntityTag prepares the GlobalSchemaGetEntityTag request. -func (c SchemaClient) preparerForGlobalSchemaGetEntityTag(ctx context.Context, id SchemaId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsHead(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGlobalSchemaGetEntityTag handles the response to the GlobalSchemaGetEntityTag request. The method always -// closes the http.Response Body. -func (c SchemaClient) responderForGlobalSchemaGetEntityTag(resp *http.Response) (result GlobalSchemaGetEntityTagOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2021-08-01/schema/method_globalschemalistbyservice.go b/resource-manager/apimanagement/2021-08-01/schema/method_globalschemalistbyservice.go new file mode 100644 index 00000000000..739c27caee5 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/schema/method_globalschemalistbyservice.go @@ -0,0 +1,125 @@ +package schema + +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 GlobalSchemaListByServiceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]GlobalSchemaContract +} + +type GlobalSchemaListByServiceCompleteResult struct { + Items []GlobalSchemaContract +} + +type GlobalSchemaListByServiceOperationOptions struct { + Filter *string + Skip *int64 + Top *int64 +} + +func DefaultGlobalSchemaListByServiceOperationOptions() GlobalSchemaListByServiceOperationOptions { + return GlobalSchemaListByServiceOperationOptions{} +} + +func (o GlobalSchemaListByServiceOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o GlobalSchemaListByServiceOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o GlobalSchemaListByServiceOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.Skip != nil { + out.Append("$skip", fmt.Sprintf("%v", *o.Skip)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +// GlobalSchemaListByService ... +func (c SchemaClient) GlobalSchemaListByService(ctx context.Context, id ServiceId, options GlobalSchemaListByServiceOperationOptions) (result GlobalSchemaListByServiceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/schemas", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]GlobalSchemaContract `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// GlobalSchemaListByServiceComplete retrieves all the results into a single object +func (c SchemaClient) GlobalSchemaListByServiceComplete(ctx context.Context, id ServiceId, options GlobalSchemaListByServiceOperationOptions) (GlobalSchemaListByServiceCompleteResult, error) { + return c.GlobalSchemaListByServiceCompleteMatchingPredicate(ctx, id, options, GlobalSchemaContractOperationPredicate{}) +} + +// GlobalSchemaListByServiceCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c SchemaClient) GlobalSchemaListByServiceCompleteMatchingPredicate(ctx context.Context, id ServiceId, options GlobalSchemaListByServiceOperationOptions, predicate GlobalSchemaContractOperationPredicate) (result GlobalSchemaListByServiceCompleteResult, err error) { + items := make([]GlobalSchemaContract, 0) + + resp, err := c.GlobalSchemaListByService(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = GlobalSchemaListByServiceCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/apimanagement/2021-08-01/schema/method_globalschemalistbyservice_autorest.go b/resource-manager/apimanagement/2021-08-01/schema/method_globalschemalistbyservice_autorest.go deleted file mode 100644 index f69bb14a594..00000000000 --- a/resource-manager/apimanagement/2021-08-01/schema/method_globalschemalistbyservice_autorest.go +++ /dev/null @@ -1,225 +0,0 @@ -package schema - -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 GlobalSchemaListByServiceOperationResponse struct { - HttpResponse *http.Response - Model *[]GlobalSchemaContract - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (GlobalSchemaListByServiceOperationResponse, error) -} - -type GlobalSchemaListByServiceCompleteResult struct { - Items []GlobalSchemaContract -} - -func (r GlobalSchemaListByServiceOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r GlobalSchemaListByServiceOperationResponse) LoadMore(ctx context.Context) (resp GlobalSchemaListByServiceOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -type GlobalSchemaListByServiceOperationOptions struct { - Filter *string - Skip *int64 - Top *int64 -} - -func DefaultGlobalSchemaListByServiceOperationOptions() GlobalSchemaListByServiceOperationOptions { - return GlobalSchemaListByServiceOperationOptions{} -} - -func (o GlobalSchemaListByServiceOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o GlobalSchemaListByServiceOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Filter != nil { - out["$filter"] = *o.Filter - } - - if o.Skip != nil { - out["$skip"] = *o.Skip - } - - if o.Top != nil { - out["$top"] = *o.Top - } - - return out -} - -// GlobalSchemaListByService ... -func (c SchemaClient) GlobalSchemaListByService(ctx context.Context, id ServiceId, options GlobalSchemaListByServiceOperationOptions) (resp GlobalSchemaListByServiceOperationResponse, err error) { - req, err := c.preparerForGlobalSchemaListByService(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "schema.SchemaClient", "GlobalSchemaListByService", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "schema.SchemaClient", "GlobalSchemaListByService", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForGlobalSchemaListByService(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "schema.SchemaClient", "GlobalSchemaListByService", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForGlobalSchemaListByService prepares the GlobalSchemaListByService request. -func (c SchemaClient) preparerForGlobalSchemaListByService(ctx context.Context, id ServiceId, options GlobalSchemaListByServiceOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/schemas", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForGlobalSchemaListByServiceWithNextLink prepares the GlobalSchemaListByService request with the given nextLink token. -func (c SchemaClient) preparerForGlobalSchemaListByServiceWithNextLink(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)) -} - -// responderForGlobalSchemaListByService handles the response to the GlobalSchemaListByService request. The method always -// closes the http.Response Body. -func (c SchemaClient) responderForGlobalSchemaListByService(resp *http.Response) (result GlobalSchemaListByServiceOperationResponse, err error) { - type page struct { - Values []GlobalSchemaContract `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 GlobalSchemaListByServiceOperationResponse, err error) { - req, err := c.preparerForGlobalSchemaListByServiceWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "schema.SchemaClient", "GlobalSchemaListByService", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "schema.SchemaClient", "GlobalSchemaListByService", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGlobalSchemaListByService(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "schema.SchemaClient", "GlobalSchemaListByService", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// GlobalSchemaListByServiceComplete retrieves all of the results into a single object -func (c SchemaClient) GlobalSchemaListByServiceComplete(ctx context.Context, id ServiceId, options GlobalSchemaListByServiceOperationOptions) (GlobalSchemaListByServiceCompleteResult, error) { - return c.GlobalSchemaListByServiceCompleteMatchingPredicate(ctx, id, options, GlobalSchemaContractOperationPredicate{}) -} - -// GlobalSchemaListByServiceCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c SchemaClient) GlobalSchemaListByServiceCompleteMatchingPredicate(ctx context.Context, id ServiceId, options GlobalSchemaListByServiceOperationOptions, predicate GlobalSchemaContractOperationPredicate) (resp GlobalSchemaListByServiceCompleteResult, err error) { - items := make([]GlobalSchemaContract, 0) - - page, err := c.GlobalSchemaListByService(ctx, id, options) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := GlobalSchemaListByServiceCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/apimanagement/2021-08-01/signinsettings/client.go b/resource-manager/apimanagement/2021-08-01/signinsettings/client.go index b4213de27ba..56dc4b1871a 100644 --- a/resource-manager/apimanagement/2021-08-01/signinsettings/client.go +++ b/resource-manager/apimanagement/2021-08-01/signinsettings/client.go @@ -1,18 +1,26 @@ package signinsettings -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 SignInSettingsClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewSignInSettingsClientWithBaseURI(endpoint string) SignInSettingsClient { - return SignInSettingsClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewSignInSettingsClientWithBaseURI(api environments.Api) (*SignInSettingsClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "signinsettings", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating SignInSettingsClient: %+v", err) } + + return &SignInSettingsClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2021-08-01/signinsettings/method_createorupdate.go b/resource-manager/apimanagement/2021-08-01/signinsettings/method_createorupdate.go new file mode 100644 index 00000000000..7b9767c2fbe --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/signinsettings/method_createorupdate.go @@ -0,0 +1,84 @@ +package signinsettings + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PortalSigninSettings +} + +type CreateOrUpdateOperationOptions struct { + IfMatch *string +} + +func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { + return CreateOrUpdateOperationOptions{} +} + +func (o CreateOrUpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o CreateOrUpdateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o CreateOrUpdateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// CreateOrUpdate ... +func (c SignInSettingsClient) CreateOrUpdate(ctx context.Context, id ServiceId, input PortalSigninSettings, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/portalsettings/signin", id.ID()), + OptionsObject: options, + } + + 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/apimanagement/2021-08-01/signinsettings/method_createorupdate_autorest.go b/resource-manager/apimanagement/2021-08-01/signinsettings/method_createorupdate_autorest.go deleted file mode 100644 index b4f0296beba..00000000000 --- a/resource-manager/apimanagement/2021-08-01/signinsettings/method_createorupdate_autorest.go +++ /dev/null @@ -1,99 +0,0 @@ -package signinsettings - -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 CreateOrUpdateOperationResponse struct { - HttpResponse *http.Response - Model *PortalSigninSettings -} - -type CreateOrUpdateOperationOptions struct { - IfMatch *string -} - -func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { - return CreateOrUpdateOperationOptions{} -} - -func (o CreateOrUpdateOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o CreateOrUpdateOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// CreateOrUpdate ... -func (c SignInSettingsClient) CreateOrUpdate(ctx context.Context, id ServiceId, input PortalSigninSettings, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdate(ctx, id, input, options) - if err != nil { - err = autorest.NewErrorWithError(err, "signinsettings.SignInSettingsClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "signinsettings.SignInSettingsClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCreateOrUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "signinsettings.SignInSettingsClient", "CreateOrUpdate", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCreateOrUpdate prepares the CreateOrUpdate request. -func (c SignInSettingsClient) preparerForCreateOrUpdate(ctx context.Context, id ServiceId, input PortalSigninSettings, options CreateOrUpdateOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/portalsettings/signin", 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 SignInSettingsClient) 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/apimanagement/2021-08-01/signinsettings/method_get.go b/resource-manager/apimanagement/2021-08-01/signinsettings/method_get.go new file mode 100644 index 00000000000..173524f6cc7 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/signinsettings/method_get.go @@ -0,0 +1,52 @@ +package signinsettings + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PortalSigninSettings +} + +// Get ... +func (c SignInSettingsClient) 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: fmt.Sprintf("%s/portalsettings/signin", 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/apimanagement/2021-08-01/signinsettings/method_get_autorest.go b/resource-manager/apimanagement/2021-08-01/signinsettings/method_get_autorest.go deleted file mode 100644 index 3ac4891a75c..00000000000 --- a/resource-manager/apimanagement/2021-08-01/signinsettings/method_get_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package signinsettings - -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 GetOperationResponse struct { - HttpResponse *http.Response - Model *PortalSigninSettings -} - -// Get ... -func (c SignInSettingsClient) Get(ctx context.Context, id ServiceId) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "signinsettings.SignInSettingsClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "signinsettings.SignInSettingsClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "signinsettings.SignInSettingsClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c SignInSettingsClient) 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(fmt.Sprintf("%s/portalsettings/signin", 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 SignInSettingsClient) 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/apimanagement/2021-08-01/signinsettings/method_getentitytag.go b/resource-manager/apimanagement/2021-08-01/signinsettings/method_getentitytag.go new file mode 100644 index 00000000000..25861ccf2a4 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/signinsettings/method_getentitytag.go @@ -0,0 +1,47 @@ +package signinsettings + +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 GetEntityTagOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// GetEntityTag ... +func (c SignInSettingsClient) GetEntityTag(ctx context.Context, id ServiceId) (result GetEntityTagOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodHead, + Path: fmt.Sprintf("%s/portalsettings/signin", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2021-08-01/signinsettings/method_getentitytag_autorest.go b/resource-manager/apimanagement/2021-08-01/signinsettings/method_getentitytag_autorest.go deleted file mode 100644 index 1209ff66c99..00000000000 --- a/resource-manager/apimanagement/2021-08-01/signinsettings/method_getentitytag_autorest.go +++ /dev/null @@ -1,67 +0,0 @@ -package signinsettings - -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 GetEntityTagOperationResponse struct { - HttpResponse *http.Response -} - -// GetEntityTag ... -func (c SignInSettingsClient) GetEntityTag(ctx context.Context, id ServiceId) (result GetEntityTagOperationResponse, err error) { - req, err := c.preparerForGetEntityTag(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "signinsettings.SignInSettingsClient", "GetEntityTag", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "signinsettings.SignInSettingsClient", "GetEntityTag", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetEntityTag(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "signinsettings.SignInSettingsClient", "GetEntityTag", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetEntityTag prepares the GetEntityTag request. -func (c SignInSettingsClient) preparerForGetEntityTag(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.AsHead(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/portalsettings/signin", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetEntityTag handles the response to the GetEntityTag request. The method always -// closes the http.Response Body. -func (c SignInSettingsClient) responderForGetEntityTag(resp *http.Response) (result GetEntityTagOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2021-08-01/signinsettings/method_update.go b/resource-manager/apimanagement/2021-08-01/signinsettings/method_update.go new file mode 100644 index 00000000000..cdef3702ed0 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/signinsettings/method_update.go @@ -0,0 +1,79 @@ +package signinsettings + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +type UpdateOperationOptions struct { + IfMatch *string +} + +func DefaultUpdateOperationOptions() UpdateOperationOptions { + return UpdateOperationOptions{} +} + +func (o UpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o UpdateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o UpdateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// Update ... +func (c SignInSettingsClient) Update(ctx context.Context, id ServiceId, input PortalSigninSettings, options UpdateOperationOptions) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: http.MethodPatch, + Path: fmt.Sprintf("%s/portalsettings/signin", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2021-08-01/signinsettings/method_update_autorest.go b/resource-manager/apimanagement/2021-08-01/signinsettings/method_update_autorest.go deleted file mode 100644 index 0a95b9f7fa1..00000000000 --- a/resource-manager/apimanagement/2021-08-01/signinsettings/method_update_autorest.go +++ /dev/null @@ -1,97 +0,0 @@ -package signinsettings - -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 UpdateOperationResponse struct { - HttpResponse *http.Response -} - -type UpdateOperationOptions struct { - IfMatch *string -} - -func DefaultUpdateOperationOptions() UpdateOperationOptions { - return UpdateOperationOptions{} -} - -func (o UpdateOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o UpdateOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// Update ... -func (c SignInSettingsClient) Update(ctx context.Context, id ServiceId, input PortalSigninSettings, options UpdateOperationOptions) (result UpdateOperationResponse, err error) { - req, err := c.preparerForUpdate(ctx, id, input, options) - if err != nil { - err = autorest.NewErrorWithError(err, "signinsettings.SignInSettingsClient", "Update", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "signinsettings.SignInSettingsClient", "Update", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "signinsettings.SignInSettingsClient", "Update", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForUpdate prepares the Update request. -func (c SignInSettingsClient) preparerForUpdate(ctx context.Context, id ServiceId, input PortalSigninSettings, options UpdateOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPatch(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/portalsettings/signin", 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 SignInSettingsClient) responderForUpdate(resp *http.Response) (result UpdateOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2021-08-01/signupsettings/client.go b/resource-manager/apimanagement/2021-08-01/signupsettings/client.go index 539431c37b7..2926b188065 100644 --- a/resource-manager/apimanagement/2021-08-01/signupsettings/client.go +++ b/resource-manager/apimanagement/2021-08-01/signupsettings/client.go @@ -1,18 +1,26 @@ package signupsettings -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 SignUpSettingsClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewSignUpSettingsClientWithBaseURI(endpoint string) SignUpSettingsClient { - return SignUpSettingsClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewSignUpSettingsClientWithBaseURI(api environments.Api) (*SignUpSettingsClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "signupsettings", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating SignUpSettingsClient: %+v", err) } + + return &SignUpSettingsClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2021-08-01/signupsettings/method_createorupdate.go b/resource-manager/apimanagement/2021-08-01/signupsettings/method_createorupdate.go new file mode 100644 index 00000000000..7269ad66a33 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/signupsettings/method_createorupdate.go @@ -0,0 +1,84 @@ +package signupsettings + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PortalSignupSettings +} + +type CreateOrUpdateOperationOptions struct { + IfMatch *string +} + +func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { + return CreateOrUpdateOperationOptions{} +} + +func (o CreateOrUpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o CreateOrUpdateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o CreateOrUpdateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// CreateOrUpdate ... +func (c SignUpSettingsClient) CreateOrUpdate(ctx context.Context, id ServiceId, input PortalSignupSettings, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/portalsettings/signup", id.ID()), + OptionsObject: options, + } + + 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/apimanagement/2021-08-01/signupsettings/method_createorupdate_autorest.go b/resource-manager/apimanagement/2021-08-01/signupsettings/method_createorupdate_autorest.go deleted file mode 100644 index 096041ff364..00000000000 --- a/resource-manager/apimanagement/2021-08-01/signupsettings/method_createorupdate_autorest.go +++ /dev/null @@ -1,99 +0,0 @@ -package signupsettings - -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 CreateOrUpdateOperationResponse struct { - HttpResponse *http.Response - Model *PortalSignupSettings -} - -type CreateOrUpdateOperationOptions struct { - IfMatch *string -} - -func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { - return CreateOrUpdateOperationOptions{} -} - -func (o CreateOrUpdateOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o CreateOrUpdateOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// CreateOrUpdate ... -func (c SignUpSettingsClient) CreateOrUpdate(ctx context.Context, id ServiceId, input PortalSignupSettings, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdate(ctx, id, input, options) - if err != nil { - err = autorest.NewErrorWithError(err, "signupsettings.SignUpSettingsClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "signupsettings.SignUpSettingsClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCreateOrUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "signupsettings.SignUpSettingsClient", "CreateOrUpdate", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCreateOrUpdate prepares the CreateOrUpdate request. -func (c SignUpSettingsClient) preparerForCreateOrUpdate(ctx context.Context, id ServiceId, input PortalSignupSettings, options CreateOrUpdateOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/portalsettings/signup", 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 SignUpSettingsClient) 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/apimanagement/2021-08-01/signupsettings/method_get.go b/resource-manager/apimanagement/2021-08-01/signupsettings/method_get.go new file mode 100644 index 00000000000..9c83e5e83ec --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/signupsettings/method_get.go @@ -0,0 +1,52 @@ +package signupsettings + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PortalSignupSettings +} + +// Get ... +func (c SignUpSettingsClient) 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: fmt.Sprintf("%s/portalsettings/signup", 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/apimanagement/2021-08-01/signupsettings/method_get_autorest.go b/resource-manager/apimanagement/2021-08-01/signupsettings/method_get_autorest.go deleted file mode 100644 index 0f67ad8685a..00000000000 --- a/resource-manager/apimanagement/2021-08-01/signupsettings/method_get_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package signupsettings - -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 GetOperationResponse struct { - HttpResponse *http.Response - Model *PortalSignupSettings -} - -// Get ... -func (c SignUpSettingsClient) Get(ctx context.Context, id ServiceId) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "signupsettings.SignUpSettingsClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "signupsettings.SignUpSettingsClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "signupsettings.SignUpSettingsClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c SignUpSettingsClient) 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(fmt.Sprintf("%s/portalsettings/signup", 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 SignUpSettingsClient) 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/apimanagement/2021-08-01/signupsettings/method_getentitytag.go b/resource-manager/apimanagement/2021-08-01/signupsettings/method_getentitytag.go new file mode 100644 index 00000000000..c664f2c2ea8 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/signupsettings/method_getentitytag.go @@ -0,0 +1,47 @@ +package signupsettings + +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 GetEntityTagOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// GetEntityTag ... +func (c SignUpSettingsClient) GetEntityTag(ctx context.Context, id ServiceId) (result GetEntityTagOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodHead, + Path: fmt.Sprintf("%s/portalsettings/signup", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2021-08-01/signupsettings/method_getentitytag_autorest.go b/resource-manager/apimanagement/2021-08-01/signupsettings/method_getentitytag_autorest.go deleted file mode 100644 index 3fa59c81432..00000000000 --- a/resource-manager/apimanagement/2021-08-01/signupsettings/method_getentitytag_autorest.go +++ /dev/null @@ -1,67 +0,0 @@ -package signupsettings - -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 GetEntityTagOperationResponse struct { - HttpResponse *http.Response -} - -// GetEntityTag ... -func (c SignUpSettingsClient) GetEntityTag(ctx context.Context, id ServiceId) (result GetEntityTagOperationResponse, err error) { - req, err := c.preparerForGetEntityTag(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "signupsettings.SignUpSettingsClient", "GetEntityTag", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "signupsettings.SignUpSettingsClient", "GetEntityTag", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetEntityTag(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "signupsettings.SignUpSettingsClient", "GetEntityTag", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetEntityTag prepares the GetEntityTag request. -func (c SignUpSettingsClient) preparerForGetEntityTag(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.AsHead(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/portalsettings/signup", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetEntityTag handles the response to the GetEntityTag request. The method always -// closes the http.Response Body. -func (c SignUpSettingsClient) responderForGetEntityTag(resp *http.Response) (result GetEntityTagOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2021-08-01/signupsettings/method_update.go b/resource-manager/apimanagement/2021-08-01/signupsettings/method_update.go new file mode 100644 index 00000000000..fd56de21870 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/signupsettings/method_update.go @@ -0,0 +1,79 @@ +package signupsettings + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +type UpdateOperationOptions struct { + IfMatch *string +} + +func DefaultUpdateOperationOptions() UpdateOperationOptions { + return UpdateOperationOptions{} +} + +func (o UpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o UpdateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o UpdateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// Update ... +func (c SignUpSettingsClient) Update(ctx context.Context, id ServiceId, input PortalSignupSettings, options UpdateOperationOptions) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: http.MethodPatch, + Path: fmt.Sprintf("%s/portalsettings/signup", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2021-08-01/signupsettings/method_update_autorest.go b/resource-manager/apimanagement/2021-08-01/signupsettings/method_update_autorest.go deleted file mode 100644 index 6ab1c8cf856..00000000000 --- a/resource-manager/apimanagement/2021-08-01/signupsettings/method_update_autorest.go +++ /dev/null @@ -1,97 +0,0 @@ -package signupsettings - -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 UpdateOperationResponse struct { - HttpResponse *http.Response -} - -type UpdateOperationOptions struct { - IfMatch *string -} - -func DefaultUpdateOperationOptions() UpdateOperationOptions { - return UpdateOperationOptions{} -} - -func (o UpdateOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o UpdateOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// Update ... -func (c SignUpSettingsClient) Update(ctx context.Context, id ServiceId, input PortalSignupSettings, options UpdateOperationOptions) (result UpdateOperationResponse, err error) { - req, err := c.preparerForUpdate(ctx, id, input, options) - if err != nil { - err = autorest.NewErrorWithError(err, "signupsettings.SignUpSettingsClient", "Update", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "signupsettings.SignUpSettingsClient", "Update", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "signupsettings.SignUpSettingsClient", "Update", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForUpdate prepares the Update request. -func (c SignUpSettingsClient) preparerForUpdate(ctx context.Context, id ServiceId, input PortalSignupSettings, options UpdateOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPatch(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/portalsettings/signup", 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 SignUpSettingsClient) responderForUpdate(resp *http.Response) (result UpdateOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2021-08-01/skus/client.go b/resource-manager/apimanagement/2021-08-01/skus/client.go index bb4f8409006..a561bc4ec71 100644 --- a/resource-manager/apimanagement/2021-08-01/skus/client.go +++ b/resource-manager/apimanagement/2021-08-01/skus/client.go @@ -1,18 +1,26 @@ package skus -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 SkusClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewSkusClientWithBaseURI(endpoint string) SkusClient { - return SkusClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewSkusClientWithBaseURI(api environments.Api) (*SkusClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "skus", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating SkusClient: %+v", err) } + + return &SkusClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2021-08-01/skus/constants.go b/resource-manager/apimanagement/2021-08-01/skus/constants.go index 0e5b4b734b7..97daf30eeec 100644 --- a/resource-manager/apimanagement/2021-08-01/skus/constants.go +++ b/resource-manager/apimanagement/2021-08-01/skus/constants.go @@ -1,6 +1,10 @@ package skus -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 PossibleValuesForApiManagementSkuCapacityScaleType() []string { } } +func (s *ApiManagementSkuCapacityScaleType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseApiManagementSkuCapacityScaleType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseApiManagementSkuCapacityScaleType(input string) (*ApiManagementSkuCapacityScaleType, error) { vals := map[string]ApiManagementSkuCapacityScaleType{ "automatic": ApiManagementSkuCapacityScaleTypeAutomatic, @@ -50,6 +67,19 @@ func PossibleValuesForApiManagementSkuRestrictionsReasonCode() []string { } } +func (s *ApiManagementSkuRestrictionsReasonCode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseApiManagementSkuRestrictionsReasonCode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseApiManagementSkuRestrictionsReasonCode(input string) (*ApiManagementSkuRestrictionsReasonCode, error) { vals := map[string]ApiManagementSkuRestrictionsReasonCode{ "notavailableforsubscription": ApiManagementSkuRestrictionsReasonCodeNotAvailableForSubscription, @@ -78,6 +108,19 @@ func PossibleValuesForApiManagementSkuRestrictionsType() []string { } } +func (s *ApiManagementSkuRestrictionsType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseApiManagementSkuRestrictionsType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseApiManagementSkuRestrictionsType(input string) (*ApiManagementSkuRestrictionsType, error) { vals := map[string]ApiManagementSkuRestrictionsType{ "location": ApiManagementSkuRestrictionsTypeLocation, diff --git a/resource-manager/apimanagement/2021-08-01/skus/method_apimanagementskuslist.go b/resource-manager/apimanagement/2021-08-01/skus/method_apimanagementskuslist.go new file mode 100644 index 00000000000..4818d802b31 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/skus/method_apimanagementskuslist.go @@ -0,0 +1,90 @@ +package skus + +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 ApiManagementSkusListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ApiManagementSku +} + +type ApiManagementSkusListCompleteResult struct { + Items []ApiManagementSku +} + +// ApiManagementSkusList ... +func (c SkusClient) ApiManagementSkusList(ctx context.Context, id commonids.SubscriptionId) (result ApiManagementSkusListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.ApiManagement/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 *[]ApiManagementSku `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ApiManagementSkusListComplete retrieves all the results into a single object +func (c SkusClient) ApiManagementSkusListComplete(ctx context.Context, id commonids.SubscriptionId) (ApiManagementSkusListCompleteResult, error) { + return c.ApiManagementSkusListCompleteMatchingPredicate(ctx, id, ApiManagementSkuOperationPredicate{}) +} + +// ApiManagementSkusListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c SkusClient) ApiManagementSkusListCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate ApiManagementSkuOperationPredicate) (result ApiManagementSkusListCompleteResult, err error) { + items := make([]ApiManagementSku, 0) + + resp, err := c.ApiManagementSkusList(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 = ApiManagementSkusListCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/apimanagement/2021-08-01/skus/method_apimanagementskuslist_autorest.go b/resource-manager/apimanagement/2021-08-01/skus/method_apimanagementskuslist_autorest.go deleted file mode 100644 index d9bb79afd90..00000000000 --- a/resource-manager/apimanagement/2021-08-01/skus/method_apimanagementskuslist_autorest.go +++ /dev/null @@ -1,187 +0,0 @@ -package skus - -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 ApiManagementSkusListOperationResponse struct { - HttpResponse *http.Response - Model *[]ApiManagementSku - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ApiManagementSkusListOperationResponse, error) -} - -type ApiManagementSkusListCompleteResult struct { - Items []ApiManagementSku -} - -func (r ApiManagementSkusListOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ApiManagementSkusListOperationResponse) LoadMore(ctx context.Context) (resp ApiManagementSkusListOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ApiManagementSkusList ... -func (c SkusClient) ApiManagementSkusList(ctx context.Context, id commonids.SubscriptionId) (resp ApiManagementSkusListOperationResponse, err error) { - req, err := c.preparerForApiManagementSkusList(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "skus.SkusClient", "ApiManagementSkusList", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "skus.SkusClient", "ApiManagementSkusList", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForApiManagementSkusList(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "skus.SkusClient", "ApiManagementSkusList", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForApiManagementSkusList prepares the ApiManagementSkusList request. -func (c SkusClient) preparerForApiManagementSkusList(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.ApiManagement/skus", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForApiManagementSkusListWithNextLink prepares the ApiManagementSkusList request with the given nextLink token. -func (c SkusClient) preparerForApiManagementSkusListWithNextLink(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)) -} - -// responderForApiManagementSkusList handles the response to the ApiManagementSkusList request. The method always -// closes the http.Response Body. -func (c SkusClient) responderForApiManagementSkusList(resp *http.Response) (result ApiManagementSkusListOperationResponse, err error) { - type page struct { - Values []ApiManagementSku `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 ApiManagementSkusListOperationResponse, err error) { - req, err := c.preparerForApiManagementSkusListWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "skus.SkusClient", "ApiManagementSkusList", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "skus.SkusClient", "ApiManagementSkusList", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForApiManagementSkusList(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "skus.SkusClient", "ApiManagementSkusList", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ApiManagementSkusListComplete retrieves all of the results into a single object -func (c SkusClient) ApiManagementSkusListComplete(ctx context.Context, id commonids.SubscriptionId) (ApiManagementSkusListCompleteResult, error) { - return c.ApiManagementSkusListCompleteMatchingPredicate(ctx, id, ApiManagementSkuOperationPredicate{}) -} - -// ApiManagementSkusListCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c SkusClient) ApiManagementSkusListCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate ApiManagementSkuOperationPredicate) (resp ApiManagementSkusListCompleteResult, err error) { - items := make([]ApiManagementSku, 0) - - page, err := c.ApiManagementSkusList(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 := ApiManagementSkusListCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/apimanagement/2021-08-01/subscription/client.go b/resource-manager/apimanagement/2021-08-01/subscription/client.go index 9b6b77e38d7..da411d23aaa 100644 --- a/resource-manager/apimanagement/2021-08-01/subscription/client.go +++ b/resource-manager/apimanagement/2021-08-01/subscription/client.go @@ -1,18 +1,26 @@ package subscription -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 SubscriptionClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewSubscriptionClientWithBaseURI(endpoint string) SubscriptionClient { - return SubscriptionClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewSubscriptionClientWithBaseURI(api environments.Api) (*SubscriptionClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "subscription", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating SubscriptionClient: %+v", err) } + + return &SubscriptionClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2021-08-01/subscription/constants.go b/resource-manager/apimanagement/2021-08-01/subscription/constants.go index 720ab13b7df..71ac415eaca 100644 --- a/resource-manager/apimanagement/2021-08-01/subscription/constants.go +++ b/resource-manager/apimanagement/2021-08-01/subscription/constants.go @@ -1,6 +1,10 @@ package subscription -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 PossibleValuesForAppType() []string { } } +func (s *AppType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAppType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseAppType(input string) (*AppType, error) { vals := map[string]AppType{ "developerportal": AppTypeDeveloperPortal, @@ -55,6 +72,19 @@ func PossibleValuesForSubscriptionState() []string { } } +func (s *SubscriptionState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSubscriptionState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseSubscriptionState(input string) (*SubscriptionState, error) { vals := map[string]SubscriptionState{ "active": SubscriptionStateActive, diff --git a/resource-manager/apimanagement/2021-08-01/subscription/method_createorupdate.go b/resource-manager/apimanagement/2021-08-01/subscription/method_createorupdate.go new file mode 100644 index 00000000000..d69e1efca03 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/subscription/method_createorupdate.go @@ -0,0 +1,92 @@ +package subscription + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SubscriptionContract +} + +type CreateOrUpdateOperationOptions struct { + AppType *AppType + IfMatch *string + Notify *bool +} + +func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { + return CreateOrUpdateOperationOptions{} +} + +func (o CreateOrUpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o CreateOrUpdateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o CreateOrUpdateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.AppType != nil { + out.Append("appType", fmt.Sprintf("%v", *o.AppType)) + } + if o.Notify != nil { + out.Append("notify", fmt.Sprintf("%v", *o.Notify)) + } + return &out +} + +// CreateOrUpdate ... +func (c SubscriptionClient) CreateOrUpdate(ctx context.Context, id Subscriptions2Id, input SubscriptionCreateParameters, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + OptionsObject: options, + } + + 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/apimanagement/2021-08-01/subscription/method_createorupdate_autorest.go b/resource-manager/apimanagement/2021-08-01/subscription/method_createorupdate_autorest.go deleted file mode 100644 index a0ed6895a04..00000000000 --- a/resource-manager/apimanagement/2021-08-01/subscription/method_createorupdate_autorest.go +++ /dev/null @@ -1,108 +0,0 @@ -package subscription - -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 *SubscriptionContract -} - -type CreateOrUpdateOperationOptions struct { - AppType *AppType - IfMatch *string - Notify *bool -} - -func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { - return CreateOrUpdateOperationOptions{} -} - -func (o CreateOrUpdateOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o CreateOrUpdateOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.AppType != nil { - out["appType"] = *o.AppType - } - - if o.Notify != nil { - out["notify"] = *o.Notify - } - - return out -} - -// CreateOrUpdate ... -func (c SubscriptionClient) CreateOrUpdate(ctx context.Context, id Subscriptions2Id, input SubscriptionCreateParameters, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdate(ctx, id, input, options) - if err != nil { - err = autorest.NewErrorWithError(err, "subscription.SubscriptionClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "subscription.SubscriptionClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCreateOrUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "subscription.SubscriptionClient", "CreateOrUpdate", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCreateOrUpdate prepares the CreateOrUpdate request. -func (c SubscriptionClient) preparerForCreateOrUpdate(ctx context.Context, id Subscriptions2Id, input SubscriptionCreateParameters, options CreateOrUpdateOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - 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 SubscriptionClient) responderForCreateOrUpdate(resp *http.Response) (result CreateOrUpdateOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2021-08-01/subscription/method_delete.go b/resource-manager/apimanagement/2021-08-01/subscription/method_delete.go new file mode 100644 index 00000000000..a14c0ad04e1 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/subscription/method_delete.go @@ -0,0 +1,76 @@ +package subscription + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +type DeleteOperationOptions struct { + IfMatch *string +} + +func DefaultDeleteOperationOptions() DeleteOperationOptions { + return DeleteOperationOptions{} +} + +func (o DeleteOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o DeleteOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o DeleteOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// Delete ... +func (c SubscriptionClient) Delete(ctx context.Context, id Subscriptions2Id, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2021-08-01/subscription/method_delete_autorest.go b/resource-manager/apimanagement/2021-08-01/subscription/method_delete_autorest.go deleted file mode 100644 index e9f7fe282a7..00000000000 --- a/resource-manager/apimanagement/2021-08-01/subscription/method_delete_autorest.go +++ /dev/null @@ -1,95 +0,0 @@ -package subscription - -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 DeleteOperationResponse struct { - HttpResponse *http.Response -} - -type DeleteOperationOptions struct { - IfMatch *string -} - -func DefaultDeleteOperationOptions() DeleteOperationOptions { - return DeleteOperationOptions{} -} - -func (o DeleteOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o DeleteOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// Delete ... -func (c SubscriptionClient) Delete(ctx context.Context, id Subscriptions2Id, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { - req, err := c.preparerForDelete(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "subscription.SubscriptionClient", "Delete", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "subscription.SubscriptionClient", "Delete", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForDelete(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "subscription.SubscriptionClient", "Delete", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForDelete prepares the Delete request. -func (c SubscriptionClient) preparerForDelete(ctx context.Context, id Subscriptions2Id, options DeleteOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForDelete handles the response to the Delete request. The method always -// closes the http.Response Body. -func (c SubscriptionClient) responderForDelete(resp *http.Response) (result DeleteOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2021-08-01/subscription/method_get.go b/resource-manager/apimanagement/2021-08-01/subscription/method_get.go new file mode 100644 index 00000000000..8aabef6e59e --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/subscription/method_get.go @@ -0,0 +1,51 @@ +package subscription + +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 *SubscriptionContract +} + +// Get ... +func (c SubscriptionClient) Get(ctx context.Context, id Subscriptions2Id) (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/apimanagement/2021-08-01/subscription/method_get_autorest.go b/resource-manager/apimanagement/2021-08-01/subscription/method_get_autorest.go deleted file mode 100644 index 5c650032d00..00000000000 --- a/resource-manager/apimanagement/2021-08-01/subscription/method_get_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package subscription - -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 *SubscriptionContract -} - -// Get ... -func (c SubscriptionClient) Get(ctx context.Context, id Subscriptions2Id) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "subscription.SubscriptionClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "subscription.SubscriptionClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "subscription.SubscriptionClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c SubscriptionClient) preparerForGet(ctx context.Context, id Subscriptions2Id) (*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 SubscriptionClient) 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/apimanagement/2021-08-01/subscription/method_getentitytag.go b/resource-manager/apimanagement/2021-08-01/subscription/method_getentitytag.go new file mode 100644 index 00000000000..70173b87ce1 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/subscription/method_getentitytag.go @@ -0,0 +1,46 @@ +package subscription + +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 GetEntityTagOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// GetEntityTag ... +func (c SubscriptionClient) GetEntityTag(ctx context.Context, id Subscriptions2Id) (result GetEntityTagOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodHead, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2021-08-01/subscription/method_getentitytag_autorest.go b/resource-manager/apimanagement/2021-08-01/subscription/method_getentitytag_autorest.go deleted file mode 100644 index e088e054ada..00000000000 --- a/resource-manager/apimanagement/2021-08-01/subscription/method_getentitytag_autorest.go +++ /dev/null @@ -1,66 +0,0 @@ -package subscription - -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 GetEntityTagOperationResponse struct { - HttpResponse *http.Response -} - -// GetEntityTag ... -func (c SubscriptionClient) GetEntityTag(ctx context.Context, id Subscriptions2Id) (result GetEntityTagOperationResponse, err error) { - req, err := c.preparerForGetEntityTag(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "subscription.SubscriptionClient", "GetEntityTag", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "subscription.SubscriptionClient", "GetEntityTag", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetEntityTag(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "subscription.SubscriptionClient", "GetEntityTag", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetEntityTag prepares the GetEntityTag request. -func (c SubscriptionClient) preparerForGetEntityTag(ctx context.Context, id Subscriptions2Id) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsHead(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetEntityTag handles the response to the GetEntityTag request. The method always -// closes the http.Response Body. -func (c SubscriptionClient) responderForGetEntityTag(resp *http.Response) (result GetEntityTagOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2021-08-01/subscription/method_list.go b/resource-manager/apimanagement/2021-08-01/subscription/method_list.go new file mode 100644 index 00000000000..5a583cace4b --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/subscription/method_list.go @@ -0,0 +1,125 @@ +package subscription + +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 *[]SubscriptionContract +} + +type ListCompleteResult struct { + Items []SubscriptionContract +} + +type ListOperationOptions struct { + Filter *string + Skip *int64 + Top *int64 +} + +func DefaultListOperationOptions() ListOperationOptions { + return ListOperationOptions{} +} + +func (o ListOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.Skip != nil { + out.Append("$skip", fmt.Sprintf("%v", *o.Skip)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +// List ... +func (c SubscriptionClient) List(ctx context.Context, id ServiceId, options ListOperationOptions) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/subscriptions", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]SubscriptionContract `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 SubscriptionClient) ListComplete(ctx context.Context, id ServiceId, options ListOperationOptions) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, options, SubscriptionContractOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c SubscriptionClient) ListCompleteMatchingPredicate(ctx context.Context, id ServiceId, options ListOperationOptions, predicate SubscriptionContractOperationPredicate) (result ListCompleteResult, err error) { + items := make([]SubscriptionContract, 0) + + resp, err := c.List(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/apimanagement/2021-08-01/subscription/method_list_autorest.go b/resource-manager/apimanagement/2021-08-01/subscription/method_list_autorest.go deleted file mode 100644 index 7cf7939d59c..00000000000 --- a/resource-manager/apimanagement/2021-08-01/subscription/method_list_autorest.go +++ /dev/null @@ -1,225 +0,0 @@ -package subscription - -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 *[]SubscriptionContract - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListOperationResponse, error) -} - -type ListCompleteResult struct { - Items []SubscriptionContract -} - -func (r ListOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListOperationResponse) LoadMore(ctx context.Context) (resp ListOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -type ListOperationOptions struct { - Filter *string - Skip *int64 - Top *int64 -} - -func DefaultListOperationOptions() ListOperationOptions { - return ListOperationOptions{} -} - -func (o ListOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o ListOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Filter != nil { - out["$filter"] = *o.Filter - } - - if o.Skip != nil { - out["$skip"] = *o.Skip - } - - if o.Top != nil { - out["$top"] = *o.Top - } - - return out -} - -// List ... -func (c SubscriptionClient) List(ctx context.Context, id ServiceId, options ListOperationOptions) (resp ListOperationResponse, err error) { - req, err := c.preparerForList(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "subscription.SubscriptionClient", "List", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "subscription.SubscriptionClient", "List", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForList(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "subscription.SubscriptionClient", "List", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForList prepares the List request. -func (c SubscriptionClient) preparerForList(ctx context.Context, id ServiceId, options ListOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/subscriptions", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListWithNextLink prepares the List request with the given nextLink token. -func (c SubscriptionClient) 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 SubscriptionClient) responderForList(resp *http.Response) (result ListOperationResponse, err error) { - type page struct { - Values []SubscriptionContract `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, "subscription.SubscriptionClient", "List", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "subscription.SubscriptionClient", "List", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForList(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "subscription.SubscriptionClient", "List", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListComplete retrieves all of the results into a single object -func (c SubscriptionClient) ListComplete(ctx context.Context, id ServiceId, options ListOperationOptions) (ListCompleteResult, error) { - return c.ListCompleteMatchingPredicate(ctx, id, options, SubscriptionContractOperationPredicate{}) -} - -// ListCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c SubscriptionClient) ListCompleteMatchingPredicate(ctx context.Context, id ServiceId, options ListOperationOptions, predicate SubscriptionContractOperationPredicate) (resp ListCompleteResult, err error) { - items := make([]SubscriptionContract, 0) - - page, err := c.List(ctx, id, options) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/apimanagement/2021-08-01/subscription/method_listsecrets.go b/resource-manager/apimanagement/2021-08-01/subscription/method_listsecrets.go new file mode 100644 index 00000000000..f204e457940 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/subscription/method_listsecrets.go @@ -0,0 +1,52 @@ +package subscription + +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 ListSecretsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SubscriptionKeysContract +} + +// ListSecrets ... +func (c SubscriptionClient) ListSecrets(ctx context.Context, id Subscriptions2Id) (result ListSecretsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/listSecrets", 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/apimanagement/2021-08-01/subscription/method_listsecrets_autorest.go b/resource-manager/apimanagement/2021-08-01/subscription/method_listsecrets_autorest.go deleted file mode 100644 index 0e76aeca560..00000000000 --- a/resource-manager/apimanagement/2021-08-01/subscription/method_listsecrets_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package subscription - -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 ListSecretsOperationResponse struct { - HttpResponse *http.Response - Model *SubscriptionKeysContract -} - -// ListSecrets ... -func (c SubscriptionClient) ListSecrets(ctx context.Context, id Subscriptions2Id) (result ListSecretsOperationResponse, err error) { - req, err := c.preparerForListSecrets(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "subscription.SubscriptionClient", "ListSecrets", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "subscription.SubscriptionClient", "ListSecrets", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListSecrets(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "subscription.SubscriptionClient", "ListSecrets", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForListSecrets prepares the ListSecrets request. -func (c SubscriptionClient) preparerForListSecrets(ctx context.Context, id Subscriptions2Id) (*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/listSecrets", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListSecrets handles the response to the ListSecrets request. The method always -// closes the http.Response Body. -func (c SubscriptionClient) responderForListSecrets(resp *http.Response) (result ListSecretsOperationResponse, 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/apimanagement/2021-08-01/subscription/method_regenerateprimarykey.go b/resource-manager/apimanagement/2021-08-01/subscription/method_regenerateprimarykey.go new file mode 100644 index 00000000000..d2ae52bbb7c --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/subscription/method_regenerateprimarykey.go @@ -0,0 +1,47 @@ +package subscription + +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 RegeneratePrimaryKeyOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// RegeneratePrimaryKey ... +func (c SubscriptionClient) RegeneratePrimaryKey(ctx context.Context, id Subscriptions2Id) (result RegeneratePrimaryKeyOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/regeneratePrimaryKey", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2021-08-01/subscription/method_regenerateprimarykey_autorest.go b/resource-manager/apimanagement/2021-08-01/subscription/method_regenerateprimarykey_autorest.go deleted file mode 100644 index 846602df9ec..00000000000 --- a/resource-manager/apimanagement/2021-08-01/subscription/method_regenerateprimarykey_autorest.go +++ /dev/null @@ -1,67 +0,0 @@ -package subscription - -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 RegeneratePrimaryKeyOperationResponse struct { - HttpResponse *http.Response -} - -// RegeneratePrimaryKey ... -func (c SubscriptionClient) RegeneratePrimaryKey(ctx context.Context, id Subscriptions2Id) (result RegeneratePrimaryKeyOperationResponse, err error) { - req, err := c.preparerForRegeneratePrimaryKey(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "subscription.SubscriptionClient", "RegeneratePrimaryKey", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "subscription.SubscriptionClient", "RegeneratePrimaryKey", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForRegeneratePrimaryKey(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "subscription.SubscriptionClient", "RegeneratePrimaryKey", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForRegeneratePrimaryKey prepares the RegeneratePrimaryKey request. -func (c SubscriptionClient) preparerForRegeneratePrimaryKey(ctx context.Context, id Subscriptions2Id) (*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/regeneratePrimaryKey", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForRegeneratePrimaryKey handles the response to the RegeneratePrimaryKey request. The method always -// closes the http.Response Body. -func (c SubscriptionClient) responderForRegeneratePrimaryKey(resp *http.Response) (result RegeneratePrimaryKeyOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2021-08-01/subscription/method_regeneratesecondarykey.go b/resource-manager/apimanagement/2021-08-01/subscription/method_regeneratesecondarykey.go new file mode 100644 index 00000000000..7e3998ced00 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/subscription/method_regeneratesecondarykey.go @@ -0,0 +1,47 @@ +package subscription + +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 RegenerateSecondaryKeyOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// RegenerateSecondaryKey ... +func (c SubscriptionClient) RegenerateSecondaryKey(ctx context.Context, id Subscriptions2Id) (result RegenerateSecondaryKeyOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/regenerateSecondaryKey", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2021-08-01/subscription/method_regeneratesecondarykey_autorest.go b/resource-manager/apimanagement/2021-08-01/subscription/method_regeneratesecondarykey_autorest.go deleted file mode 100644 index 44faa9e3409..00000000000 --- a/resource-manager/apimanagement/2021-08-01/subscription/method_regeneratesecondarykey_autorest.go +++ /dev/null @@ -1,67 +0,0 @@ -package subscription - -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 RegenerateSecondaryKeyOperationResponse struct { - HttpResponse *http.Response -} - -// RegenerateSecondaryKey ... -func (c SubscriptionClient) RegenerateSecondaryKey(ctx context.Context, id Subscriptions2Id) (result RegenerateSecondaryKeyOperationResponse, err error) { - req, err := c.preparerForRegenerateSecondaryKey(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "subscription.SubscriptionClient", "RegenerateSecondaryKey", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "subscription.SubscriptionClient", "RegenerateSecondaryKey", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForRegenerateSecondaryKey(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "subscription.SubscriptionClient", "RegenerateSecondaryKey", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForRegenerateSecondaryKey prepares the RegenerateSecondaryKey request. -func (c SubscriptionClient) preparerForRegenerateSecondaryKey(ctx context.Context, id Subscriptions2Id) (*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/regenerateSecondaryKey", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForRegenerateSecondaryKey handles the response to the RegenerateSecondaryKey request. The method always -// closes the http.Response Body. -func (c SubscriptionClient) responderForRegenerateSecondaryKey(resp *http.Response) (result RegenerateSecondaryKeyOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2021-08-01/subscription/method_update.go b/resource-manager/apimanagement/2021-08-01/subscription/method_update.go new file mode 100644 index 00000000000..f01dc48db34 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/subscription/method_update.go @@ -0,0 +1,91 @@ +package subscription + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SubscriptionContract +} + +type UpdateOperationOptions struct { + AppType *AppType + IfMatch *string + Notify *bool +} + +func DefaultUpdateOperationOptions() UpdateOperationOptions { + return UpdateOperationOptions{} +} + +func (o UpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o UpdateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o UpdateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.AppType != nil { + out.Append("appType", fmt.Sprintf("%v", *o.AppType)) + } + if o.Notify != nil { + out.Append("notify", fmt.Sprintf("%v", *o.Notify)) + } + return &out +} + +// Update ... +func (c SubscriptionClient) Update(ctx context.Context, id Subscriptions2Id, input SubscriptionUpdateParameters, options UpdateOperationOptions) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + OptionsObject: options, + } + + 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/apimanagement/2021-08-01/subscription/method_update_autorest.go b/resource-manager/apimanagement/2021-08-01/subscription/method_update_autorest.go deleted file mode 100644 index 000a788ba77..00000000000 --- a/resource-manager/apimanagement/2021-08-01/subscription/method_update_autorest.go +++ /dev/null @@ -1,108 +0,0 @@ -package subscription - -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 *SubscriptionContract -} - -type UpdateOperationOptions struct { - AppType *AppType - IfMatch *string - Notify *bool -} - -func DefaultUpdateOperationOptions() UpdateOperationOptions { - return UpdateOperationOptions{} -} - -func (o UpdateOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o UpdateOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.AppType != nil { - out["appType"] = *o.AppType - } - - if o.Notify != nil { - out["notify"] = *o.Notify - } - - return out -} - -// Update ... -func (c SubscriptionClient) Update(ctx context.Context, id Subscriptions2Id, input SubscriptionUpdateParameters, options UpdateOperationOptions) (result UpdateOperationResponse, err error) { - req, err := c.preparerForUpdate(ctx, id, input, options) - if err != nil { - err = autorest.NewErrorWithError(err, "subscription.SubscriptionClient", "Update", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "subscription.SubscriptionClient", "Update", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "subscription.SubscriptionClient", "Update", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForUpdate prepares the Update request. -func (c SubscriptionClient) preparerForUpdate(ctx context.Context, id Subscriptions2Id, input SubscriptionUpdateParameters, options UpdateOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPatch(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - 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 SubscriptionClient) 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/apimanagement/2021-08-01/subscription/method_usersubscriptionget.go b/resource-manager/apimanagement/2021-08-01/subscription/method_usersubscriptionget.go new file mode 100644 index 00000000000..7553f7391d9 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/subscription/method_usersubscriptionget.go @@ -0,0 +1,51 @@ +package subscription + +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 UserSubscriptionGetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SubscriptionContract +} + +// UserSubscriptionGet ... +func (c SubscriptionClient) UserSubscriptionGet(ctx context.Context, id UserSubscriptions2Id) (result UserSubscriptionGetOperationResponse, 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/apimanagement/2021-08-01/subscription/method_usersubscriptionget_autorest.go b/resource-manager/apimanagement/2021-08-01/subscription/method_usersubscriptionget_autorest.go deleted file mode 100644 index cc4667c6c9c..00000000000 --- a/resource-manager/apimanagement/2021-08-01/subscription/method_usersubscriptionget_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package subscription - -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 UserSubscriptionGetOperationResponse struct { - HttpResponse *http.Response - Model *SubscriptionContract -} - -// UserSubscriptionGet ... -func (c SubscriptionClient) UserSubscriptionGet(ctx context.Context, id UserSubscriptions2Id) (result UserSubscriptionGetOperationResponse, err error) { - req, err := c.preparerForUserSubscriptionGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "subscription.SubscriptionClient", "UserSubscriptionGet", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "subscription.SubscriptionClient", "UserSubscriptionGet", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForUserSubscriptionGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "subscription.SubscriptionClient", "UserSubscriptionGet", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForUserSubscriptionGet prepares the UserSubscriptionGet request. -func (c SubscriptionClient) preparerForUserSubscriptionGet(ctx context.Context, id UserSubscriptions2Id) (*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)) -} - -// responderForUserSubscriptionGet handles the response to the UserSubscriptionGet request. The method always -// closes the http.Response Body. -func (c SubscriptionClient) responderForUserSubscriptionGet(resp *http.Response) (result UserSubscriptionGetOperationResponse, 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/apimanagement/2021-08-01/tag/client.go b/resource-manager/apimanagement/2021-08-01/tag/client.go index 859dfa3f85e..02bade47a01 100644 --- a/resource-manager/apimanagement/2021-08-01/tag/client.go +++ b/resource-manager/apimanagement/2021-08-01/tag/client.go @@ -1,18 +1,26 @@ package tag -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 TagClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewTagClientWithBaseURI(endpoint string) TagClient { - return TagClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewTagClientWithBaseURI(api environments.Api) (*TagClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "tag", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating TagClient: %+v", err) } + + return &TagClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2021-08-01/tag/method_createorupdate.go b/resource-manager/apimanagement/2021-08-01/tag/method_createorupdate.go new file mode 100644 index 00000000000..b7c955b4480 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/tag/method_createorupdate.go @@ -0,0 +1,85 @@ +package tag + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *TagContract +} + +type CreateOrUpdateOperationOptions struct { + IfMatch *string +} + +func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { + return CreateOrUpdateOperationOptions{} +} + +func (o CreateOrUpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o CreateOrUpdateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o CreateOrUpdateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// CreateOrUpdate ... +func (c TagClient) CreateOrUpdate(ctx context.Context, id TagId, input TagCreateUpdateParameters, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + OptionsObject: options, + } + + 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/apimanagement/2021-08-01/tag/method_createorupdate_autorest.go b/resource-manager/apimanagement/2021-08-01/tag/method_createorupdate_autorest.go deleted file mode 100644 index 48f02bbd515..00000000000 --- a/resource-manager/apimanagement/2021-08-01/tag/method_createorupdate_autorest.go +++ /dev/null @@ -1,98 +0,0 @@ -package tag - -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 *TagContract -} - -type CreateOrUpdateOperationOptions struct { - IfMatch *string -} - -func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { - return CreateOrUpdateOperationOptions{} -} - -func (o CreateOrUpdateOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o CreateOrUpdateOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// CreateOrUpdate ... -func (c TagClient) CreateOrUpdate(ctx context.Context, id TagId, input TagCreateUpdateParameters, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdate(ctx, id, input, options) - if err != nil { - err = autorest.NewErrorWithError(err, "tag.TagClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "tag.TagClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCreateOrUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "tag.TagClient", "CreateOrUpdate", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCreateOrUpdate prepares the CreateOrUpdate request. -func (c TagClient) preparerForCreateOrUpdate(ctx context.Context, id TagId, input TagCreateUpdateParameters, options CreateOrUpdateOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - 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 TagClient) responderForCreateOrUpdate(resp *http.Response) (result CreateOrUpdateOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2021-08-01/tag/method_delete.go b/resource-manager/apimanagement/2021-08-01/tag/method_delete.go new file mode 100644 index 00000000000..01b72128471 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/tag/method_delete.go @@ -0,0 +1,76 @@ +package tag + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +type DeleteOperationOptions struct { + IfMatch *string +} + +func DefaultDeleteOperationOptions() DeleteOperationOptions { + return DeleteOperationOptions{} +} + +func (o DeleteOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o DeleteOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o DeleteOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// Delete ... +func (c TagClient) Delete(ctx context.Context, id TagId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2021-08-01/tag/method_delete_autorest.go b/resource-manager/apimanagement/2021-08-01/tag/method_delete_autorest.go deleted file mode 100644 index fad1b450db3..00000000000 --- a/resource-manager/apimanagement/2021-08-01/tag/method_delete_autorest.go +++ /dev/null @@ -1,95 +0,0 @@ -package tag - -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 DeleteOperationResponse struct { - HttpResponse *http.Response -} - -type DeleteOperationOptions struct { - IfMatch *string -} - -func DefaultDeleteOperationOptions() DeleteOperationOptions { - return DeleteOperationOptions{} -} - -func (o DeleteOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o DeleteOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// Delete ... -func (c TagClient) Delete(ctx context.Context, id TagId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { - req, err := c.preparerForDelete(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "tag.TagClient", "Delete", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "tag.TagClient", "Delete", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForDelete(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "tag.TagClient", "Delete", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForDelete prepares the Delete request. -func (c TagClient) preparerForDelete(ctx context.Context, id TagId, options DeleteOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForDelete handles the response to the Delete request. The method always -// closes the http.Response Body. -func (c TagClient) responderForDelete(resp *http.Response) (result DeleteOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2021-08-01/tag/method_get.go b/resource-manager/apimanagement/2021-08-01/tag/method_get.go new file mode 100644 index 00000000000..340922be21e --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/tag/method_get.go @@ -0,0 +1,51 @@ +package tag + +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 *TagContract +} + +// Get ... +func (c TagClient) Get(ctx context.Context, id TagId) (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/apimanagement/2021-08-01/tag/method_get_autorest.go b/resource-manager/apimanagement/2021-08-01/tag/method_get_autorest.go deleted file mode 100644 index 0a9cd67ede7..00000000000 --- a/resource-manager/apimanagement/2021-08-01/tag/method_get_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package tag - -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 *TagContract -} - -// Get ... -func (c TagClient) Get(ctx context.Context, id TagId) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "tag.TagClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "tag.TagClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "tag.TagClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c TagClient) preparerForGet(ctx context.Context, id TagId) (*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 TagClient) 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/apimanagement/2021-08-01/tag/method_getentitystate.go b/resource-manager/apimanagement/2021-08-01/tag/method_getentitystate.go new file mode 100644 index 00000000000..b56c0026a99 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/tag/method_getentitystate.go @@ -0,0 +1,46 @@ +package tag + +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 GetEntityStateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// GetEntityState ... +func (c TagClient) GetEntityState(ctx context.Context, id TagId) (result GetEntityStateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodHead, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2021-08-01/tag/method_getentitystate_autorest.go b/resource-manager/apimanagement/2021-08-01/tag/method_getentitystate_autorest.go deleted file mode 100644 index a058ebd7e9b..00000000000 --- a/resource-manager/apimanagement/2021-08-01/tag/method_getentitystate_autorest.go +++ /dev/null @@ -1,66 +0,0 @@ -package tag - -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 GetEntityStateOperationResponse struct { - HttpResponse *http.Response -} - -// GetEntityState ... -func (c TagClient) GetEntityState(ctx context.Context, id TagId) (result GetEntityStateOperationResponse, err error) { - req, err := c.preparerForGetEntityState(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "tag.TagClient", "GetEntityState", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "tag.TagClient", "GetEntityState", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetEntityState(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "tag.TagClient", "GetEntityState", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetEntityState prepares the GetEntityState request. -func (c TagClient) preparerForGetEntityState(ctx context.Context, id TagId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsHead(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetEntityState handles the response to the GetEntityState request. The method always -// closes the http.Response Body. -func (c TagClient) responderForGetEntityState(resp *http.Response) (result GetEntityStateOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2021-08-01/tag/method_listbyservice.go b/resource-manager/apimanagement/2021-08-01/tag/method_listbyservice.go new file mode 100644 index 00000000000..110e8d13d3c --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/tag/method_listbyservice.go @@ -0,0 +1,129 @@ +package tag + +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 ListByServiceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]TagContract +} + +type ListByServiceCompleteResult struct { + Items []TagContract +} + +type ListByServiceOperationOptions struct { + Filter *string + Scope *string + Skip *int64 + Top *int64 +} + +func DefaultListByServiceOperationOptions() ListByServiceOperationOptions { + return ListByServiceOperationOptions{} +} + +func (o ListByServiceOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListByServiceOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListByServiceOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.Scope != nil { + out.Append("scope", fmt.Sprintf("%v", *o.Scope)) + } + if o.Skip != nil { + out.Append("$skip", fmt.Sprintf("%v", *o.Skip)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +// ListByService ... +func (c TagClient) ListByService(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (result ListByServiceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/tags", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]TagContract `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByServiceComplete retrieves all the results into a single object +func (c TagClient) ListByServiceComplete(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (ListByServiceCompleteResult, error) { + return c.ListByServiceCompleteMatchingPredicate(ctx, id, options, TagContractOperationPredicate{}) +} + +// ListByServiceCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c TagClient) ListByServiceCompleteMatchingPredicate(ctx context.Context, id ServiceId, options ListByServiceOperationOptions, predicate TagContractOperationPredicate) (result ListByServiceCompleteResult, err error) { + items := make([]TagContract, 0) + + resp, err := c.ListByService(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByServiceCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/apimanagement/2021-08-01/tag/method_listbyservice_autorest.go b/resource-manager/apimanagement/2021-08-01/tag/method_listbyservice_autorest.go deleted file mode 100644 index 1e241c14508..00000000000 --- a/resource-manager/apimanagement/2021-08-01/tag/method_listbyservice_autorest.go +++ /dev/null @@ -1,230 +0,0 @@ -package tag - -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 ListByServiceOperationResponse struct { - HttpResponse *http.Response - Model *[]TagContract - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListByServiceOperationResponse, error) -} - -type ListByServiceCompleteResult struct { - Items []TagContract -} - -func (r ListByServiceOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListByServiceOperationResponse) LoadMore(ctx context.Context) (resp ListByServiceOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -type ListByServiceOperationOptions struct { - Filter *string - Scope *string - Skip *int64 - Top *int64 -} - -func DefaultListByServiceOperationOptions() ListByServiceOperationOptions { - return ListByServiceOperationOptions{} -} - -func (o ListByServiceOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o ListByServiceOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Filter != nil { - out["$filter"] = *o.Filter - } - - if o.Scope != nil { - out["scope"] = *o.Scope - } - - if o.Skip != nil { - out["$skip"] = *o.Skip - } - - if o.Top != nil { - out["$top"] = *o.Top - } - - return out -} - -// ListByService ... -func (c TagClient) ListByService(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (resp ListByServiceOperationResponse, err error) { - req, err := c.preparerForListByService(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "tag.TagClient", "ListByService", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "tag.TagClient", "ListByService", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListByService(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "tag.TagClient", "ListByService", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListByService prepares the ListByService request. -func (c TagClient) preparerForListByService(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/tags", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListByServiceWithNextLink prepares the ListByService request with the given nextLink token. -func (c TagClient) preparerForListByServiceWithNextLink(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)) -} - -// responderForListByService handles the response to the ListByService request. The method always -// closes the http.Response Body. -func (c TagClient) responderForListByService(resp *http.Response) (result ListByServiceOperationResponse, err error) { - type page struct { - Values []TagContract `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 ListByServiceOperationResponse, err error) { - req, err := c.preparerForListByServiceWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "tag.TagClient", "ListByService", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "tag.TagClient", "ListByService", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByService(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "tag.TagClient", "ListByService", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListByServiceComplete retrieves all of the results into a single object -func (c TagClient) ListByServiceComplete(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (ListByServiceCompleteResult, error) { - return c.ListByServiceCompleteMatchingPredicate(ctx, id, options, TagContractOperationPredicate{}) -} - -// ListByServiceCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c TagClient) ListByServiceCompleteMatchingPredicate(ctx context.Context, id ServiceId, options ListByServiceOperationOptions, predicate TagContractOperationPredicate) (resp ListByServiceCompleteResult, err error) { - items := make([]TagContract, 0) - - page, err := c.ListByService(ctx, id, options) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListByServiceCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/apimanagement/2021-08-01/tag/method_update.go b/resource-manager/apimanagement/2021-08-01/tag/method_update.go new file mode 100644 index 00000000000..a301e054137 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/tag/method_update.go @@ -0,0 +1,84 @@ +package tag + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *TagContract +} + +type UpdateOperationOptions struct { + IfMatch *string +} + +func DefaultUpdateOperationOptions() UpdateOperationOptions { + return UpdateOperationOptions{} +} + +func (o UpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o UpdateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o UpdateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// Update ... +func (c TagClient) Update(ctx context.Context, id TagId, input TagCreateUpdateParameters, options UpdateOperationOptions) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + OptionsObject: options, + } + + 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/apimanagement/2021-08-01/tag/method_update_autorest.go b/resource-manager/apimanagement/2021-08-01/tag/method_update_autorest.go deleted file mode 100644 index 6a13a61027d..00000000000 --- a/resource-manager/apimanagement/2021-08-01/tag/method_update_autorest.go +++ /dev/null @@ -1,98 +0,0 @@ -package tag - -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 *TagContract -} - -type UpdateOperationOptions struct { - IfMatch *string -} - -func DefaultUpdateOperationOptions() UpdateOperationOptions { - return UpdateOperationOptions{} -} - -func (o UpdateOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o UpdateOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// Update ... -func (c TagClient) Update(ctx context.Context, id TagId, input TagCreateUpdateParameters, options UpdateOperationOptions) (result UpdateOperationResponse, err error) { - req, err := c.preparerForUpdate(ctx, id, input, options) - if err != nil { - err = autorest.NewErrorWithError(err, "tag.TagClient", "Update", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "tag.TagClient", "Update", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "tag.TagClient", "Update", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForUpdate prepares the Update request. -func (c TagClient) preparerForUpdate(ctx context.Context, id TagId, input TagCreateUpdateParameters, options UpdateOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPatch(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - 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 TagClient) 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/apimanagement/2021-08-01/tagresource/client.go b/resource-manager/apimanagement/2021-08-01/tagresource/client.go index 10f42e3996e..64e4eff38a8 100644 --- a/resource-manager/apimanagement/2021-08-01/tagresource/client.go +++ b/resource-manager/apimanagement/2021-08-01/tagresource/client.go @@ -1,18 +1,26 @@ package tagresource -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 TagResourceClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewTagResourceClientWithBaseURI(endpoint string) TagResourceClient { - return TagResourceClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewTagResourceClientWithBaseURI(api environments.Api) (*TagResourceClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "tagresource", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating TagResourceClient: %+v", err) } + + return &TagResourceClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2021-08-01/tagresource/constants.go b/resource-manager/apimanagement/2021-08-01/tagresource/constants.go index 97e2cdd7620..93cbbc002a0 100644 --- a/resource-manager/apimanagement/2021-08-01/tagresource/constants.go +++ b/resource-manager/apimanagement/2021-08-01/tagresource/constants.go @@ -1,6 +1,10 @@ package tagresource -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 PossibleValuesForApiType() []string { } } +func (s *ApiType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseApiType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseApiType(input string) (*ApiType, error) { vals := map[string]ApiType{ "graphql": ApiTypeGraphql, @@ -53,6 +70,19 @@ func PossibleValuesForBearerTokenSendingMethods() []string { } } +func (s *BearerTokenSendingMethods) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseBearerTokenSendingMethods(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseBearerTokenSendingMethods(input string) (*BearerTokenSendingMethods, error) { vals := map[string]BearerTokenSendingMethods{ "authorizationheader": BearerTokenSendingMethodsAuthorizationHeader, @@ -81,6 +111,19 @@ func PossibleValuesForProductState() []string { } } +func (s *ProductState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProductState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseProductState(input string) (*ProductState, error) { vals := map[string]ProductState{ "notpublished": ProductStateNotPublished, @@ -113,6 +156,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{ "http": ProtocolHTTP, diff --git a/resource-manager/apimanagement/2021-08-01/tagresource/method_listbyservice.go b/resource-manager/apimanagement/2021-08-01/tagresource/method_listbyservice.go new file mode 100644 index 00000000000..c896fcb2dfc --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/tagresource/method_listbyservice.go @@ -0,0 +1,125 @@ +package tagresource + +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 ListByServiceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]TagResourceContract +} + +type ListByServiceCompleteResult struct { + Items []TagResourceContract +} + +type ListByServiceOperationOptions struct { + Filter *string + Skip *int64 + Top *int64 +} + +func DefaultListByServiceOperationOptions() ListByServiceOperationOptions { + return ListByServiceOperationOptions{} +} + +func (o ListByServiceOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListByServiceOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListByServiceOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.Skip != nil { + out.Append("$skip", fmt.Sprintf("%v", *o.Skip)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +// ListByService ... +func (c TagResourceClient) ListByService(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (result ListByServiceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/tagResources", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]TagResourceContract `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByServiceComplete retrieves all the results into a single object +func (c TagResourceClient) ListByServiceComplete(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (ListByServiceCompleteResult, error) { + return c.ListByServiceCompleteMatchingPredicate(ctx, id, options, TagResourceContractOperationPredicate{}) +} + +// ListByServiceCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c TagResourceClient) ListByServiceCompleteMatchingPredicate(ctx context.Context, id ServiceId, options ListByServiceOperationOptions, predicate TagResourceContractOperationPredicate) (result ListByServiceCompleteResult, err error) { + items := make([]TagResourceContract, 0) + + resp, err := c.ListByService(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByServiceCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/apimanagement/2021-08-01/tagresource/method_listbyservice_autorest.go b/resource-manager/apimanagement/2021-08-01/tagresource/method_listbyservice_autorest.go deleted file mode 100644 index b86fedc24e7..00000000000 --- a/resource-manager/apimanagement/2021-08-01/tagresource/method_listbyservice_autorest.go +++ /dev/null @@ -1,225 +0,0 @@ -package tagresource - -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 ListByServiceOperationResponse struct { - HttpResponse *http.Response - Model *[]TagResourceContract - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListByServiceOperationResponse, error) -} - -type ListByServiceCompleteResult struct { - Items []TagResourceContract -} - -func (r ListByServiceOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListByServiceOperationResponse) LoadMore(ctx context.Context) (resp ListByServiceOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -type ListByServiceOperationOptions struct { - Filter *string - Skip *int64 - Top *int64 -} - -func DefaultListByServiceOperationOptions() ListByServiceOperationOptions { - return ListByServiceOperationOptions{} -} - -func (o ListByServiceOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o ListByServiceOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Filter != nil { - out["$filter"] = *o.Filter - } - - if o.Skip != nil { - out["$skip"] = *o.Skip - } - - if o.Top != nil { - out["$top"] = *o.Top - } - - return out -} - -// ListByService ... -func (c TagResourceClient) ListByService(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (resp ListByServiceOperationResponse, err error) { - req, err := c.preparerForListByService(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "tagresource.TagResourceClient", "ListByService", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "tagresource.TagResourceClient", "ListByService", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListByService(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "tagresource.TagResourceClient", "ListByService", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListByService prepares the ListByService request. -func (c TagResourceClient) preparerForListByService(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/tagResources", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListByServiceWithNextLink prepares the ListByService request with the given nextLink token. -func (c TagResourceClient) preparerForListByServiceWithNextLink(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)) -} - -// responderForListByService handles the response to the ListByService request. The method always -// closes the http.Response Body. -func (c TagResourceClient) responderForListByService(resp *http.Response) (result ListByServiceOperationResponse, err error) { - type page struct { - Values []TagResourceContract `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 ListByServiceOperationResponse, err error) { - req, err := c.preparerForListByServiceWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "tagresource.TagResourceClient", "ListByService", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "tagresource.TagResourceClient", "ListByService", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByService(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "tagresource.TagResourceClient", "ListByService", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListByServiceComplete retrieves all of the results into a single object -func (c TagResourceClient) ListByServiceComplete(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (ListByServiceCompleteResult, error) { - return c.ListByServiceCompleteMatchingPredicate(ctx, id, options, TagResourceContractOperationPredicate{}) -} - -// ListByServiceCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c TagResourceClient) ListByServiceCompleteMatchingPredicate(ctx context.Context, id ServiceId, options ListByServiceOperationOptions, predicate TagResourceContractOperationPredicate) (resp ListByServiceCompleteResult, err error) { - items := make([]TagResourceContract, 0) - - page, err := c.ListByService(ctx, id, options) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListByServiceCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/apimanagement/2021-08-01/tenantaccess/client.go b/resource-manager/apimanagement/2021-08-01/tenantaccess/client.go index 7a6208f3d69..57a892bf074 100644 --- a/resource-manager/apimanagement/2021-08-01/tenantaccess/client.go +++ b/resource-manager/apimanagement/2021-08-01/tenantaccess/client.go @@ -1,18 +1,26 @@ package tenantaccess -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 TenantAccessClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewTenantAccessClientWithBaseURI(endpoint string) TenantAccessClient { - return TenantAccessClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewTenantAccessClientWithBaseURI(api environments.Api) (*TenantAccessClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "tenantaccess", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating TenantAccessClient: %+v", err) } + + return &TenantAccessClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2021-08-01/tenantaccess/constants.go b/resource-manager/apimanagement/2021-08-01/tenantaccess/constants.go index 3fe8372dbcb..0a9a890aae2 100644 --- a/resource-manager/apimanagement/2021-08-01/tenantaccess/constants.go +++ b/resource-manager/apimanagement/2021-08-01/tenantaccess/constants.go @@ -1,6 +1,10 @@ package tenantaccess -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 PossibleValuesForAccessIdName() []string { } } +func (s *AccessIdName) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAccessIdName(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseAccessIdName(input string) (*AccessIdName, error) { vals := map[string]AccessIdName{ "access": AccessIdNameAccess, diff --git a/resource-manager/apimanagement/2021-08-01/tenantaccess/method_create.go b/resource-manager/apimanagement/2021-08-01/tenantaccess/method_create.go new file mode 100644 index 00000000000..cf2902da389 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/tenantaccess/method_create.go @@ -0,0 +1,84 @@ +package tenantaccess + +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 CreateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *AccessInformationContract +} + +type CreateOperationOptions struct { + IfMatch *string +} + +func DefaultCreateOperationOptions() CreateOperationOptions { + return CreateOperationOptions{} +} + +func (o CreateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o CreateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o CreateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// Create ... +func (c TenantAccessClient) Create(ctx context.Context, id AccessId, input AccessInformationCreateParameters, options CreateOperationOptions) (result CreateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + OptionsObject: options, + } + + 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/apimanagement/2021-08-01/tenantaccess/method_create_autorest.go b/resource-manager/apimanagement/2021-08-01/tenantaccess/method_create_autorest.go deleted file mode 100644 index cc2d34137c2..00000000000 --- a/resource-manager/apimanagement/2021-08-01/tenantaccess/method_create_autorest.go +++ /dev/null @@ -1,98 +0,0 @@ -package tenantaccess - -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 CreateOperationResponse struct { - HttpResponse *http.Response - Model *AccessInformationContract -} - -type CreateOperationOptions struct { - IfMatch *string -} - -func DefaultCreateOperationOptions() CreateOperationOptions { - return CreateOperationOptions{} -} - -func (o CreateOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o CreateOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// Create ... -func (c TenantAccessClient) Create(ctx context.Context, id AccessId, input AccessInformationCreateParameters, options CreateOperationOptions) (result CreateOperationResponse, err error) { - req, err := c.preparerForCreate(ctx, id, input, options) - if err != nil { - err = autorest.NewErrorWithError(err, "tenantaccess.TenantAccessClient", "Create", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "tenantaccess.TenantAccessClient", "Create", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCreate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "tenantaccess.TenantAccessClient", "Create", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCreate prepares the Create request. -func (c TenantAccessClient) preparerForCreate(ctx context.Context, id AccessId, input AccessInformationCreateParameters, options CreateOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForCreate handles the response to the Create request. The method always -// closes the http.Response Body. -func (c TenantAccessClient) responderForCreate(resp *http.Response) (result CreateOperationResponse, 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/apimanagement/2021-08-01/tenantaccess/method_get.go b/resource-manager/apimanagement/2021-08-01/tenantaccess/method_get.go new file mode 100644 index 00000000000..b1f7d18cc3b --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/tenantaccess/method_get.go @@ -0,0 +1,51 @@ +package tenantaccess + +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 *AccessInformationContract +} + +// Get ... +func (c TenantAccessClient) Get(ctx context.Context, id AccessId) (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/apimanagement/2021-08-01/tenantaccess/method_get_autorest.go b/resource-manager/apimanagement/2021-08-01/tenantaccess/method_get_autorest.go deleted file mode 100644 index 3a070ae9892..00000000000 --- a/resource-manager/apimanagement/2021-08-01/tenantaccess/method_get_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package tenantaccess - -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 *AccessInformationContract -} - -// Get ... -func (c TenantAccessClient) Get(ctx context.Context, id AccessId) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "tenantaccess.TenantAccessClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "tenantaccess.TenantAccessClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "tenantaccess.TenantAccessClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c TenantAccessClient) preparerForGet(ctx context.Context, id AccessId) (*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 TenantAccessClient) 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/apimanagement/2021-08-01/tenantaccess/method_getentitytag.go b/resource-manager/apimanagement/2021-08-01/tenantaccess/method_getentitytag.go new file mode 100644 index 00000000000..d1d42ee00fd --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/tenantaccess/method_getentitytag.go @@ -0,0 +1,46 @@ +package tenantaccess + +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 GetEntityTagOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// GetEntityTag ... +func (c TenantAccessClient) GetEntityTag(ctx context.Context, id AccessId) (result GetEntityTagOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodHead, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2021-08-01/tenantaccess/method_getentitytag_autorest.go b/resource-manager/apimanagement/2021-08-01/tenantaccess/method_getentitytag_autorest.go deleted file mode 100644 index 8300d23c3f6..00000000000 --- a/resource-manager/apimanagement/2021-08-01/tenantaccess/method_getentitytag_autorest.go +++ /dev/null @@ -1,66 +0,0 @@ -package tenantaccess - -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 GetEntityTagOperationResponse struct { - HttpResponse *http.Response -} - -// GetEntityTag ... -func (c TenantAccessClient) GetEntityTag(ctx context.Context, id AccessId) (result GetEntityTagOperationResponse, err error) { - req, err := c.preparerForGetEntityTag(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "tenantaccess.TenantAccessClient", "GetEntityTag", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "tenantaccess.TenantAccessClient", "GetEntityTag", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetEntityTag(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "tenantaccess.TenantAccessClient", "GetEntityTag", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetEntityTag prepares the GetEntityTag request. -func (c TenantAccessClient) preparerForGetEntityTag(ctx context.Context, id AccessId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsHead(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetEntityTag handles the response to the GetEntityTag request. The method always -// closes the http.Response Body. -func (c TenantAccessClient) responderForGetEntityTag(resp *http.Response) (result GetEntityTagOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2021-08-01/tenantaccess/method_listbyservice.go b/resource-manager/apimanagement/2021-08-01/tenantaccess/method_listbyservice.go new file mode 100644 index 00000000000..d332a10b9d5 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/tenantaccess/method_listbyservice.go @@ -0,0 +1,117 @@ +package tenantaccess + +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 ListByServiceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]AccessInformationContract +} + +type ListByServiceCompleteResult struct { + Items []AccessInformationContract +} + +type ListByServiceOperationOptions struct { + Filter *string +} + +func DefaultListByServiceOperationOptions() ListByServiceOperationOptions { + return ListByServiceOperationOptions{} +} + +func (o ListByServiceOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListByServiceOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListByServiceOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + return &out +} + +// ListByService ... +func (c TenantAccessClient) ListByService(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (result ListByServiceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/tenant", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]AccessInformationContract `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByServiceComplete retrieves all the results into a single object +func (c TenantAccessClient) ListByServiceComplete(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (ListByServiceCompleteResult, error) { + return c.ListByServiceCompleteMatchingPredicate(ctx, id, options, AccessInformationContractOperationPredicate{}) +} + +// ListByServiceCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c TenantAccessClient) ListByServiceCompleteMatchingPredicate(ctx context.Context, id ServiceId, options ListByServiceOperationOptions, predicate AccessInformationContractOperationPredicate) (result ListByServiceCompleteResult, err error) { + items := make([]AccessInformationContract, 0) + + resp, err := c.ListByService(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByServiceCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/apimanagement/2021-08-01/tenantaccess/method_listbyservice_autorest.go b/resource-manager/apimanagement/2021-08-01/tenantaccess/method_listbyservice_autorest.go deleted file mode 100644 index 8e83891260f..00000000000 --- a/resource-manager/apimanagement/2021-08-01/tenantaccess/method_listbyservice_autorest.go +++ /dev/null @@ -1,215 +0,0 @@ -package tenantaccess - -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 ListByServiceOperationResponse struct { - HttpResponse *http.Response - Model *[]AccessInformationContract - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListByServiceOperationResponse, error) -} - -type ListByServiceCompleteResult struct { - Items []AccessInformationContract -} - -func (r ListByServiceOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListByServiceOperationResponse) LoadMore(ctx context.Context) (resp ListByServiceOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -type ListByServiceOperationOptions struct { - Filter *string -} - -func DefaultListByServiceOperationOptions() ListByServiceOperationOptions { - return ListByServiceOperationOptions{} -} - -func (o ListByServiceOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o ListByServiceOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Filter != nil { - out["$filter"] = *o.Filter - } - - return out -} - -// ListByService ... -func (c TenantAccessClient) ListByService(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (resp ListByServiceOperationResponse, err error) { - req, err := c.preparerForListByService(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "tenantaccess.TenantAccessClient", "ListByService", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "tenantaccess.TenantAccessClient", "ListByService", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListByService(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "tenantaccess.TenantAccessClient", "ListByService", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListByService prepares the ListByService request. -func (c TenantAccessClient) preparerForListByService(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/tenant", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListByServiceWithNextLink prepares the ListByService request with the given nextLink token. -func (c TenantAccessClient) preparerForListByServiceWithNextLink(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)) -} - -// responderForListByService handles the response to the ListByService request. The method always -// closes the http.Response Body. -func (c TenantAccessClient) responderForListByService(resp *http.Response) (result ListByServiceOperationResponse, err error) { - type page struct { - Values []AccessInformationContract `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 ListByServiceOperationResponse, err error) { - req, err := c.preparerForListByServiceWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "tenantaccess.TenantAccessClient", "ListByService", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "tenantaccess.TenantAccessClient", "ListByService", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByService(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "tenantaccess.TenantAccessClient", "ListByService", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListByServiceComplete retrieves all of the results into a single object -func (c TenantAccessClient) ListByServiceComplete(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (ListByServiceCompleteResult, error) { - return c.ListByServiceCompleteMatchingPredicate(ctx, id, options, AccessInformationContractOperationPredicate{}) -} - -// ListByServiceCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c TenantAccessClient) ListByServiceCompleteMatchingPredicate(ctx context.Context, id ServiceId, options ListByServiceOperationOptions, predicate AccessInformationContractOperationPredicate) (resp ListByServiceCompleteResult, err error) { - items := make([]AccessInformationContract, 0) - - page, err := c.ListByService(ctx, id, options) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListByServiceCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/apimanagement/2021-08-01/tenantaccess/method_listsecrets.go b/resource-manager/apimanagement/2021-08-01/tenantaccess/method_listsecrets.go new file mode 100644 index 00000000000..67b0b5f3a0b --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/tenantaccess/method_listsecrets.go @@ -0,0 +1,52 @@ +package tenantaccess + +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 ListSecretsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *AccessInformationSecretsContract +} + +// ListSecrets ... +func (c TenantAccessClient) ListSecrets(ctx context.Context, id AccessId) (result ListSecretsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/listSecrets", 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/apimanagement/2021-08-01/tenantaccess/method_listsecrets_autorest.go b/resource-manager/apimanagement/2021-08-01/tenantaccess/method_listsecrets_autorest.go deleted file mode 100644 index 2a1515ff216..00000000000 --- a/resource-manager/apimanagement/2021-08-01/tenantaccess/method_listsecrets_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package tenantaccess - -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 ListSecretsOperationResponse struct { - HttpResponse *http.Response - Model *AccessInformationSecretsContract -} - -// ListSecrets ... -func (c TenantAccessClient) ListSecrets(ctx context.Context, id AccessId) (result ListSecretsOperationResponse, err error) { - req, err := c.preparerForListSecrets(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "tenantaccess.TenantAccessClient", "ListSecrets", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "tenantaccess.TenantAccessClient", "ListSecrets", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListSecrets(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "tenantaccess.TenantAccessClient", "ListSecrets", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForListSecrets prepares the ListSecrets request. -func (c TenantAccessClient) preparerForListSecrets(ctx context.Context, id AccessId) (*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/listSecrets", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListSecrets handles the response to the ListSecrets request. The method always -// closes the http.Response Body. -func (c TenantAccessClient) responderForListSecrets(resp *http.Response) (result ListSecretsOperationResponse, 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/apimanagement/2021-08-01/tenantaccess/method_regenerateprimarykey.go b/resource-manager/apimanagement/2021-08-01/tenantaccess/method_regenerateprimarykey.go new file mode 100644 index 00000000000..6d6aa0f1ccf --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/tenantaccess/method_regenerateprimarykey.go @@ -0,0 +1,47 @@ +package tenantaccess + +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 RegeneratePrimaryKeyOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// RegeneratePrimaryKey ... +func (c TenantAccessClient) RegeneratePrimaryKey(ctx context.Context, id AccessId) (result RegeneratePrimaryKeyOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/regeneratePrimaryKey", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2021-08-01/tenantaccess/method_regenerateprimarykey_autorest.go b/resource-manager/apimanagement/2021-08-01/tenantaccess/method_regenerateprimarykey_autorest.go deleted file mode 100644 index 18cb875e657..00000000000 --- a/resource-manager/apimanagement/2021-08-01/tenantaccess/method_regenerateprimarykey_autorest.go +++ /dev/null @@ -1,67 +0,0 @@ -package tenantaccess - -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 RegeneratePrimaryKeyOperationResponse struct { - HttpResponse *http.Response -} - -// RegeneratePrimaryKey ... -func (c TenantAccessClient) RegeneratePrimaryKey(ctx context.Context, id AccessId) (result RegeneratePrimaryKeyOperationResponse, err error) { - req, err := c.preparerForRegeneratePrimaryKey(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "tenantaccess.TenantAccessClient", "RegeneratePrimaryKey", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "tenantaccess.TenantAccessClient", "RegeneratePrimaryKey", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForRegeneratePrimaryKey(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "tenantaccess.TenantAccessClient", "RegeneratePrimaryKey", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForRegeneratePrimaryKey prepares the RegeneratePrimaryKey request. -func (c TenantAccessClient) preparerForRegeneratePrimaryKey(ctx context.Context, id AccessId) (*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/regeneratePrimaryKey", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForRegeneratePrimaryKey handles the response to the RegeneratePrimaryKey request. The method always -// closes the http.Response Body. -func (c TenantAccessClient) responderForRegeneratePrimaryKey(resp *http.Response) (result RegeneratePrimaryKeyOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2021-08-01/tenantaccess/method_regeneratesecondarykey.go b/resource-manager/apimanagement/2021-08-01/tenantaccess/method_regeneratesecondarykey.go new file mode 100644 index 00000000000..0fd0b8fd296 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/tenantaccess/method_regeneratesecondarykey.go @@ -0,0 +1,47 @@ +package tenantaccess + +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 RegenerateSecondaryKeyOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// RegenerateSecondaryKey ... +func (c TenantAccessClient) RegenerateSecondaryKey(ctx context.Context, id AccessId) (result RegenerateSecondaryKeyOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/regenerateSecondaryKey", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2021-08-01/tenantaccess/method_regeneratesecondarykey_autorest.go b/resource-manager/apimanagement/2021-08-01/tenantaccess/method_regeneratesecondarykey_autorest.go deleted file mode 100644 index 60839456731..00000000000 --- a/resource-manager/apimanagement/2021-08-01/tenantaccess/method_regeneratesecondarykey_autorest.go +++ /dev/null @@ -1,67 +0,0 @@ -package tenantaccess - -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 RegenerateSecondaryKeyOperationResponse struct { - HttpResponse *http.Response -} - -// RegenerateSecondaryKey ... -func (c TenantAccessClient) RegenerateSecondaryKey(ctx context.Context, id AccessId) (result RegenerateSecondaryKeyOperationResponse, err error) { - req, err := c.preparerForRegenerateSecondaryKey(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "tenantaccess.TenantAccessClient", "RegenerateSecondaryKey", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "tenantaccess.TenantAccessClient", "RegenerateSecondaryKey", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForRegenerateSecondaryKey(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "tenantaccess.TenantAccessClient", "RegenerateSecondaryKey", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForRegenerateSecondaryKey prepares the RegenerateSecondaryKey request. -func (c TenantAccessClient) preparerForRegenerateSecondaryKey(ctx context.Context, id AccessId) (*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/regenerateSecondaryKey", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForRegenerateSecondaryKey handles the response to the RegenerateSecondaryKey request. The method always -// closes the http.Response Body. -func (c TenantAccessClient) responderForRegenerateSecondaryKey(resp *http.Response) (result RegenerateSecondaryKeyOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2021-08-01/tenantaccess/method_update.go b/resource-manager/apimanagement/2021-08-01/tenantaccess/method_update.go new file mode 100644 index 00000000000..255888180b3 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/tenantaccess/method_update.go @@ -0,0 +1,84 @@ +package tenantaccess + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *AccessInformationContract +} + +type UpdateOperationOptions struct { + IfMatch *string +} + +func DefaultUpdateOperationOptions() UpdateOperationOptions { + return UpdateOperationOptions{} +} + +func (o UpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o UpdateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o UpdateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// Update ... +func (c TenantAccessClient) Update(ctx context.Context, id AccessId, input AccessInformationUpdateParameters, options UpdateOperationOptions) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + OptionsObject: options, + } + + 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/apimanagement/2021-08-01/tenantaccess/method_update_autorest.go b/resource-manager/apimanagement/2021-08-01/tenantaccess/method_update_autorest.go deleted file mode 100644 index 87eb5439426..00000000000 --- a/resource-manager/apimanagement/2021-08-01/tenantaccess/method_update_autorest.go +++ /dev/null @@ -1,98 +0,0 @@ -package tenantaccess - -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 *AccessInformationContract -} - -type UpdateOperationOptions struct { - IfMatch *string -} - -func DefaultUpdateOperationOptions() UpdateOperationOptions { - return UpdateOperationOptions{} -} - -func (o UpdateOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o UpdateOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// Update ... -func (c TenantAccessClient) Update(ctx context.Context, id AccessId, input AccessInformationUpdateParameters, options UpdateOperationOptions) (result UpdateOperationResponse, err error) { - req, err := c.preparerForUpdate(ctx, id, input, options) - if err != nil { - err = autorest.NewErrorWithError(err, "tenantaccess.TenantAccessClient", "Update", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "tenantaccess.TenantAccessClient", "Update", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "tenantaccess.TenantAccessClient", "Update", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForUpdate prepares the Update request. -func (c TenantAccessClient) preparerForUpdate(ctx context.Context, id AccessId, input AccessInformationUpdateParameters, options UpdateOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPatch(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - 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 TenantAccessClient) 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/apimanagement/2021-08-01/tenantaccessgit/client.go b/resource-manager/apimanagement/2021-08-01/tenantaccessgit/client.go index 015bab0d24f..91b616be2c8 100644 --- a/resource-manager/apimanagement/2021-08-01/tenantaccessgit/client.go +++ b/resource-manager/apimanagement/2021-08-01/tenantaccessgit/client.go @@ -1,18 +1,26 @@ package tenantaccessgit -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 TenantAccessGitClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewTenantAccessGitClientWithBaseURI(endpoint string) TenantAccessGitClient { - return TenantAccessGitClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewTenantAccessGitClientWithBaseURI(api environments.Api) (*TenantAccessGitClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "tenantaccessgit", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating TenantAccessGitClient: %+v", err) } + + return &TenantAccessGitClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2021-08-01/tenantaccessgit/constants.go b/resource-manager/apimanagement/2021-08-01/tenantaccessgit/constants.go index b35272377f3..0423218f1c5 100644 --- a/resource-manager/apimanagement/2021-08-01/tenantaccessgit/constants.go +++ b/resource-manager/apimanagement/2021-08-01/tenantaccessgit/constants.go @@ -1,6 +1,10 @@ package tenantaccessgit -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 PossibleValuesForAccessIdName() []string { } } +func (s *AccessIdName) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAccessIdName(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseAccessIdName(input string) (*AccessIdName, error) { vals := map[string]AccessIdName{ "access": AccessIdNameAccess, diff --git a/resource-manager/apimanagement/2021-08-01/tenantaccessgit/method_regenerateprimarykey.go b/resource-manager/apimanagement/2021-08-01/tenantaccessgit/method_regenerateprimarykey.go new file mode 100644 index 00000000000..5b6c503576f --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/tenantaccessgit/method_regenerateprimarykey.go @@ -0,0 +1,47 @@ +package tenantaccessgit + +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 RegeneratePrimaryKeyOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// RegeneratePrimaryKey ... +func (c TenantAccessGitClient) RegeneratePrimaryKey(ctx context.Context, id AccessId) (result RegeneratePrimaryKeyOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/git/regeneratePrimaryKey", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2021-08-01/tenantaccessgit/method_regenerateprimarykey_autorest.go b/resource-manager/apimanagement/2021-08-01/tenantaccessgit/method_regenerateprimarykey_autorest.go deleted file mode 100644 index 4783b820c9d..00000000000 --- a/resource-manager/apimanagement/2021-08-01/tenantaccessgit/method_regenerateprimarykey_autorest.go +++ /dev/null @@ -1,67 +0,0 @@ -package tenantaccessgit - -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 RegeneratePrimaryKeyOperationResponse struct { - HttpResponse *http.Response -} - -// RegeneratePrimaryKey ... -func (c TenantAccessGitClient) RegeneratePrimaryKey(ctx context.Context, id AccessId) (result RegeneratePrimaryKeyOperationResponse, err error) { - req, err := c.preparerForRegeneratePrimaryKey(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "tenantaccessgit.TenantAccessGitClient", "RegeneratePrimaryKey", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "tenantaccessgit.TenantAccessGitClient", "RegeneratePrimaryKey", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForRegeneratePrimaryKey(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "tenantaccessgit.TenantAccessGitClient", "RegeneratePrimaryKey", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForRegeneratePrimaryKey prepares the RegeneratePrimaryKey request. -func (c TenantAccessGitClient) preparerForRegeneratePrimaryKey(ctx context.Context, id AccessId) (*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/git/regeneratePrimaryKey", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForRegeneratePrimaryKey handles the response to the RegeneratePrimaryKey request. The method always -// closes the http.Response Body. -func (c TenantAccessGitClient) responderForRegeneratePrimaryKey(resp *http.Response) (result RegeneratePrimaryKeyOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2021-08-01/tenantaccessgit/method_regeneratesecondarykey.go b/resource-manager/apimanagement/2021-08-01/tenantaccessgit/method_regeneratesecondarykey.go new file mode 100644 index 00000000000..fa55bca8deb --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/tenantaccessgit/method_regeneratesecondarykey.go @@ -0,0 +1,47 @@ +package tenantaccessgit + +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 RegenerateSecondaryKeyOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// RegenerateSecondaryKey ... +func (c TenantAccessGitClient) RegenerateSecondaryKey(ctx context.Context, id AccessId) (result RegenerateSecondaryKeyOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/git/regenerateSecondaryKey", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2021-08-01/tenantaccessgit/method_regeneratesecondarykey_autorest.go b/resource-manager/apimanagement/2021-08-01/tenantaccessgit/method_regeneratesecondarykey_autorest.go deleted file mode 100644 index d0375fcb447..00000000000 --- a/resource-manager/apimanagement/2021-08-01/tenantaccessgit/method_regeneratesecondarykey_autorest.go +++ /dev/null @@ -1,67 +0,0 @@ -package tenantaccessgit - -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 RegenerateSecondaryKeyOperationResponse struct { - HttpResponse *http.Response -} - -// RegenerateSecondaryKey ... -func (c TenantAccessGitClient) RegenerateSecondaryKey(ctx context.Context, id AccessId) (result RegenerateSecondaryKeyOperationResponse, err error) { - req, err := c.preparerForRegenerateSecondaryKey(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "tenantaccessgit.TenantAccessGitClient", "RegenerateSecondaryKey", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "tenantaccessgit.TenantAccessGitClient", "RegenerateSecondaryKey", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForRegenerateSecondaryKey(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "tenantaccessgit.TenantAccessGitClient", "RegenerateSecondaryKey", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForRegenerateSecondaryKey prepares the RegenerateSecondaryKey request. -func (c TenantAccessGitClient) preparerForRegenerateSecondaryKey(ctx context.Context, id AccessId) (*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/git/regenerateSecondaryKey", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForRegenerateSecondaryKey handles the response to the RegenerateSecondaryKey request. The method always -// closes the http.Response Body. -func (c TenantAccessGitClient) responderForRegenerateSecondaryKey(resp *http.Response) (result RegenerateSecondaryKeyOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2021-08-01/tenantconfiguration/client.go b/resource-manager/apimanagement/2021-08-01/tenantconfiguration/client.go index b4cf4a17cf2..30299aa4773 100644 --- a/resource-manager/apimanagement/2021-08-01/tenantconfiguration/client.go +++ b/resource-manager/apimanagement/2021-08-01/tenantconfiguration/client.go @@ -1,18 +1,26 @@ package tenantconfiguration -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 TenantConfigurationClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewTenantConfigurationClientWithBaseURI(endpoint string) TenantConfigurationClient { - return TenantConfigurationClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewTenantConfigurationClientWithBaseURI(api environments.Api) (*TenantConfigurationClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "tenantconfiguration", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating TenantConfigurationClient: %+v", err) } + + return &TenantConfigurationClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2021-08-01/tenantconfiguration/constants.go b/resource-manager/apimanagement/2021-08-01/tenantconfiguration/constants.go index 68f7b36814f..c896fa35bce 100644 --- a/resource-manager/apimanagement/2021-08-01/tenantconfiguration/constants.go +++ b/resource-manager/apimanagement/2021-08-01/tenantconfiguration/constants.go @@ -1,6 +1,10 @@ package tenantconfiguration -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 PossibleValuesForAsyncOperationStatus() []string { } } +func (s *AsyncOperationStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAsyncOperationStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseAsyncOperationStatus(input string) (*AsyncOperationStatus, error) { vals := map[string]AsyncOperationStatus{ "failed": AsyncOperationStatusFailed, diff --git a/resource-manager/apimanagement/2021-08-01/tenantconfiguration/method_deploy.go b/resource-manager/apimanagement/2021-08-01/tenantconfiguration/method_deploy.go new file mode 100644 index 00000000000..e71bf7ad1b6 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/tenantconfiguration/method_deploy.go @@ -0,0 +1,74 @@ +package tenantconfiguration + +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 DeployOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Deploy ... +func (c TenantConfigurationClient) Deploy(ctx context.Context, id ServiceId, input DeployConfigurationParameters) (result DeployOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/tenant/configuration/deploy", 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 +} + +// DeployThenPoll performs Deploy then polls until it's completed +func (c TenantConfigurationClient) DeployThenPoll(ctx context.Context, id ServiceId, input DeployConfigurationParameters) error { + result, err := c.Deploy(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Deploy: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Deploy: %+v", err) + } + + return nil +} diff --git a/resource-manager/apimanagement/2021-08-01/tenantconfiguration/method_deploy_autorest.go b/resource-manager/apimanagement/2021-08-01/tenantconfiguration/method_deploy_autorest.go deleted file mode 100644 index 659a8ef5465..00000000000 --- a/resource-manager/apimanagement/2021-08-01/tenantconfiguration/method_deploy_autorest.go +++ /dev/null @@ -1,79 +0,0 @@ -package tenantconfiguration - -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 DeployOperationResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// Deploy ... -func (c TenantConfigurationClient) Deploy(ctx context.Context, id ServiceId, input DeployConfigurationParameters) (result DeployOperationResponse, err error) { - req, err := c.preparerForDeploy(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "tenantconfiguration.TenantConfigurationClient", "Deploy", nil, "Failure preparing request") - return - } - - result, err = c.senderForDeploy(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "tenantconfiguration.TenantConfigurationClient", "Deploy", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// DeployThenPoll performs Deploy then polls until it's completed -func (c TenantConfigurationClient) DeployThenPoll(ctx context.Context, id ServiceId, input DeployConfigurationParameters) error { - result, err := c.Deploy(ctx, id, input) - if err != nil { - return fmt.Errorf("performing Deploy: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after Deploy: %+v", err) - } - - return nil -} - -// preparerForDeploy prepares the Deploy request. -func (c TenantConfigurationClient) preparerForDeploy(ctx context.Context, id ServiceId, input DeployConfigurationParameters) (*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/tenant/configuration/deploy", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForDeploy sends the Deploy request. The method will close the -// http.Response Body if it receives an error. -func (c TenantConfigurationClient) senderForDeploy(ctx context.Context, req *http.Request) (future DeployOperationResponse, 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/apimanagement/2021-08-01/tenantconfiguration/method_save.go b/resource-manager/apimanagement/2021-08-01/tenantconfiguration/method_save.go new file mode 100644 index 00000000000..c261c455120 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/tenantconfiguration/method_save.go @@ -0,0 +1,74 @@ +package tenantconfiguration + +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 SaveOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Save ... +func (c TenantConfigurationClient) Save(ctx context.Context, id ServiceId, input SaveConfigurationParameter) (result SaveOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/tenant/configuration/save", 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 +} + +// SaveThenPoll performs Save then polls until it's completed +func (c TenantConfigurationClient) SaveThenPoll(ctx context.Context, id ServiceId, input SaveConfigurationParameter) error { + result, err := c.Save(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Save: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Save: %+v", err) + } + + return nil +} diff --git a/resource-manager/apimanagement/2021-08-01/tenantconfiguration/method_save_autorest.go b/resource-manager/apimanagement/2021-08-01/tenantconfiguration/method_save_autorest.go deleted file mode 100644 index 989e1db8216..00000000000 --- a/resource-manager/apimanagement/2021-08-01/tenantconfiguration/method_save_autorest.go +++ /dev/null @@ -1,79 +0,0 @@ -package tenantconfiguration - -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 SaveOperationResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// Save ... -func (c TenantConfigurationClient) Save(ctx context.Context, id ServiceId, input SaveConfigurationParameter) (result SaveOperationResponse, err error) { - req, err := c.preparerForSave(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "tenantconfiguration.TenantConfigurationClient", "Save", nil, "Failure preparing request") - return - } - - result, err = c.senderForSave(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "tenantconfiguration.TenantConfigurationClient", "Save", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// SaveThenPoll performs Save then polls until it's completed -func (c TenantConfigurationClient) SaveThenPoll(ctx context.Context, id ServiceId, input SaveConfigurationParameter) error { - result, err := c.Save(ctx, id, input) - if err != nil { - return fmt.Errorf("performing Save: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after Save: %+v", err) - } - - return nil -} - -// preparerForSave prepares the Save request. -func (c TenantConfigurationClient) preparerForSave(ctx context.Context, id ServiceId, input SaveConfigurationParameter) (*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/tenant/configuration/save", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForSave sends the Save request. The method will close the -// http.Response Body if it receives an error. -func (c TenantConfigurationClient) senderForSave(ctx context.Context, req *http.Request) (future SaveOperationResponse, 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/apimanagement/2021-08-01/tenantconfiguration/method_validate.go b/resource-manager/apimanagement/2021-08-01/tenantconfiguration/method_validate.go new file mode 100644 index 00000000000..26401e0e77f --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/tenantconfiguration/method_validate.go @@ -0,0 +1,74 @@ +package tenantconfiguration + +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 ValidateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Validate ... +func (c TenantConfigurationClient) Validate(ctx context.Context, id ServiceId, input DeployConfigurationParameters) (result ValidateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/tenant/configuration/validate", 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 +} + +// ValidateThenPoll performs Validate then polls until it's completed +func (c TenantConfigurationClient) ValidateThenPoll(ctx context.Context, id ServiceId, input DeployConfigurationParameters) error { + result, err := c.Validate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Validate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Validate: %+v", err) + } + + return nil +} diff --git a/resource-manager/apimanagement/2021-08-01/tenantconfiguration/method_validate_autorest.go b/resource-manager/apimanagement/2021-08-01/tenantconfiguration/method_validate_autorest.go deleted file mode 100644 index 64e2904b423..00000000000 --- a/resource-manager/apimanagement/2021-08-01/tenantconfiguration/method_validate_autorest.go +++ /dev/null @@ -1,79 +0,0 @@ -package tenantconfiguration - -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 ValidateOperationResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// Validate ... -func (c TenantConfigurationClient) Validate(ctx context.Context, id ServiceId, input DeployConfigurationParameters) (result ValidateOperationResponse, err error) { - req, err := c.preparerForValidate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "tenantconfiguration.TenantConfigurationClient", "Validate", nil, "Failure preparing request") - return - } - - result, err = c.senderForValidate(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "tenantconfiguration.TenantConfigurationClient", "Validate", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// ValidateThenPoll performs Validate then polls until it's completed -func (c TenantConfigurationClient) ValidateThenPoll(ctx context.Context, id ServiceId, input DeployConfigurationParameters) error { - result, err := c.Validate(ctx, id, input) - if err != nil { - return fmt.Errorf("performing Validate: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after Validate: %+v", err) - } - - return nil -} - -// preparerForValidate prepares the Validate request. -func (c TenantConfigurationClient) preparerForValidate(ctx context.Context, id ServiceId, input DeployConfigurationParameters) (*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/tenant/configuration/validate", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForValidate sends the Validate request. The method will close the -// http.Response Body if it receives an error. -func (c TenantConfigurationClient) senderForValidate(ctx context.Context, req *http.Request) (future ValidateOperationResponse, 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/apimanagement/2021-08-01/tenantconfigurationsyncstate/client.go b/resource-manager/apimanagement/2021-08-01/tenantconfigurationsyncstate/client.go index b005ecbaebc..a92b3f0029b 100644 --- a/resource-manager/apimanagement/2021-08-01/tenantconfigurationsyncstate/client.go +++ b/resource-manager/apimanagement/2021-08-01/tenantconfigurationsyncstate/client.go @@ -1,18 +1,26 @@ package tenantconfigurationsyncstate -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 TenantConfigurationSyncStateClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewTenantConfigurationSyncStateClientWithBaseURI(endpoint string) TenantConfigurationSyncStateClient { - return TenantConfigurationSyncStateClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewTenantConfigurationSyncStateClientWithBaseURI(api environments.Api) (*TenantConfigurationSyncStateClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "tenantconfigurationsyncstate", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating TenantConfigurationSyncStateClient: %+v", err) } + + return &TenantConfigurationSyncStateClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2021-08-01/tenantconfigurationsyncstate/method_tenantconfigurationgetsyncstate.go b/resource-manager/apimanagement/2021-08-01/tenantconfigurationsyncstate/method_tenantconfigurationgetsyncstate.go new file mode 100644 index 00000000000..4ea64f710b0 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/tenantconfigurationsyncstate/method_tenantconfigurationgetsyncstate.go @@ -0,0 +1,52 @@ +package tenantconfigurationsyncstate + +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 TenantConfigurationGetSyncStateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *TenantConfigurationSyncStateContract +} + +// TenantConfigurationGetSyncState ... +func (c TenantConfigurationSyncStateClient) TenantConfigurationGetSyncState(ctx context.Context, id ServiceId) (result TenantConfigurationGetSyncStateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/tenant/configuration/syncState", 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/apimanagement/2021-08-01/tenantconfigurationsyncstate/method_tenantconfigurationgetsyncstate_autorest.go b/resource-manager/apimanagement/2021-08-01/tenantconfigurationsyncstate/method_tenantconfigurationgetsyncstate_autorest.go deleted file mode 100644 index 8761b63aaa1..00000000000 --- a/resource-manager/apimanagement/2021-08-01/tenantconfigurationsyncstate/method_tenantconfigurationgetsyncstate_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package tenantconfigurationsyncstate - -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 TenantConfigurationGetSyncStateOperationResponse struct { - HttpResponse *http.Response - Model *TenantConfigurationSyncStateContract -} - -// TenantConfigurationGetSyncState ... -func (c TenantConfigurationSyncStateClient) TenantConfigurationGetSyncState(ctx context.Context, id ServiceId) (result TenantConfigurationGetSyncStateOperationResponse, err error) { - req, err := c.preparerForTenantConfigurationGetSyncState(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "tenantconfigurationsyncstate.TenantConfigurationSyncStateClient", "TenantConfigurationGetSyncState", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "tenantconfigurationsyncstate.TenantConfigurationSyncStateClient", "TenantConfigurationGetSyncState", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForTenantConfigurationGetSyncState(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "tenantconfigurationsyncstate.TenantConfigurationSyncStateClient", "TenantConfigurationGetSyncState", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForTenantConfigurationGetSyncState prepares the TenantConfigurationGetSyncState request. -func (c TenantConfigurationSyncStateClient) preparerForTenantConfigurationGetSyncState(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(fmt.Sprintf("%s/tenant/configuration/syncState", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForTenantConfigurationGetSyncState handles the response to the TenantConfigurationGetSyncState request. The method always -// closes the http.Response Body. -func (c TenantConfigurationSyncStateClient) responderForTenantConfigurationGetSyncState(resp *http.Response) (result TenantConfigurationGetSyncStateOperationResponse, 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/apimanagement/2021-08-01/tenantsettings/client.go b/resource-manager/apimanagement/2021-08-01/tenantsettings/client.go index 1e3e819d2fe..fe0b39c0a78 100644 --- a/resource-manager/apimanagement/2021-08-01/tenantsettings/client.go +++ b/resource-manager/apimanagement/2021-08-01/tenantsettings/client.go @@ -1,18 +1,26 @@ package tenantsettings -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 TenantSettingsClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewTenantSettingsClientWithBaseURI(endpoint string) TenantSettingsClient { - return TenantSettingsClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewTenantSettingsClientWithBaseURI(api environments.Api) (*TenantSettingsClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "tenantsettings", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating TenantSettingsClient: %+v", err) } + + return &TenantSettingsClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2021-08-01/tenantsettings/method_get.go b/resource-manager/apimanagement/2021-08-01/tenantsettings/method_get.go new file mode 100644 index 00000000000..9f42162d776 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/tenantsettings/method_get.go @@ -0,0 +1,52 @@ +package tenantsettings + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *TenantSettingsContract +} + +// Get ... +func (c TenantSettingsClient) 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: fmt.Sprintf("%s/settings/public", 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/apimanagement/2021-08-01/tenantsettings/method_get_autorest.go b/resource-manager/apimanagement/2021-08-01/tenantsettings/method_get_autorest.go deleted file mode 100644 index 5fe75ae615e..00000000000 --- a/resource-manager/apimanagement/2021-08-01/tenantsettings/method_get_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package tenantsettings - -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 GetOperationResponse struct { - HttpResponse *http.Response - Model *TenantSettingsContract -} - -// Get ... -func (c TenantSettingsClient) Get(ctx context.Context, id ServiceId) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "tenantsettings.TenantSettingsClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "tenantsettings.TenantSettingsClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "tenantsettings.TenantSettingsClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c TenantSettingsClient) 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(fmt.Sprintf("%s/settings/public", 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 TenantSettingsClient) 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/apimanagement/2021-08-01/tenantsettings/method_listbyservice.go b/resource-manager/apimanagement/2021-08-01/tenantsettings/method_listbyservice.go new file mode 100644 index 00000000000..6d94b36d733 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/tenantsettings/method_listbyservice.go @@ -0,0 +1,117 @@ +package tenantsettings + +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 ListByServiceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]TenantSettingsContract +} + +type ListByServiceCompleteResult struct { + Items []TenantSettingsContract +} + +type ListByServiceOperationOptions struct { + Filter *string +} + +func DefaultListByServiceOperationOptions() ListByServiceOperationOptions { + return ListByServiceOperationOptions{} +} + +func (o ListByServiceOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListByServiceOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListByServiceOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + return &out +} + +// ListByService ... +func (c TenantSettingsClient) ListByService(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (result ListByServiceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/settings", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]TenantSettingsContract `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByServiceComplete retrieves all the results into a single object +func (c TenantSettingsClient) ListByServiceComplete(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (ListByServiceCompleteResult, error) { + return c.ListByServiceCompleteMatchingPredicate(ctx, id, options, TenantSettingsContractOperationPredicate{}) +} + +// ListByServiceCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c TenantSettingsClient) ListByServiceCompleteMatchingPredicate(ctx context.Context, id ServiceId, options ListByServiceOperationOptions, predicate TenantSettingsContractOperationPredicate) (result ListByServiceCompleteResult, err error) { + items := make([]TenantSettingsContract, 0) + + resp, err := c.ListByService(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByServiceCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/apimanagement/2021-08-01/tenantsettings/method_listbyservice_autorest.go b/resource-manager/apimanagement/2021-08-01/tenantsettings/method_listbyservice_autorest.go deleted file mode 100644 index 1514f996e50..00000000000 --- a/resource-manager/apimanagement/2021-08-01/tenantsettings/method_listbyservice_autorest.go +++ /dev/null @@ -1,215 +0,0 @@ -package tenantsettings - -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 ListByServiceOperationResponse struct { - HttpResponse *http.Response - Model *[]TenantSettingsContract - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListByServiceOperationResponse, error) -} - -type ListByServiceCompleteResult struct { - Items []TenantSettingsContract -} - -func (r ListByServiceOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListByServiceOperationResponse) LoadMore(ctx context.Context) (resp ListByServiceOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -type ListByServiceOperationOptions struct { - Filter *string -} - -func DefaultListByServiceOperationOptions() ListByServiceOperationOptions { - return ListByServiceOperationOptions{} -} - -func (o ListByServiceOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o ListByServiceOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Filter != nil { - out["$filter"] = *o.Filter - } - - return out -} - -// ListByService ... -func (c TenantSettingsClient) ListByService(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (resp ListByServiceOperationResponse, err error) { - req, err := c.preparerForListByService(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "tenantsettings.TenantSettingsClient", "ListByService", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "tenantsettings.TenantSettingsClient", "ListByService", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListByService(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "tenantsettings.TenantSettingsClient", "ListByService", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListByService prepares the ListByService request. -func (c TenantSettingsClient) preparerForListByService(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/settings", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListByServiceWithNextLink prepares the ListByService request with the given nextLink token. -func (c TenantSettingsClient) preparerForListByServiceWithNextLink(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)) -} - -// responderForListByService handles the response to the ListByService request. The method always -// closes the http.Response Body. -func (c TenantSettingsClient) responderForListByService(resp *http.Response) (result ListByServiceOperationResponse, err error) { - type page struct { - Values []TenantSettingsContract `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 ListByServiceOperationResponse, err error) { - req, err := c.preparerForListByServiceWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "tenantsettings.TenantSettingsClient", "ListByService", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "tenantsettings.TenantSettingsClient", "ListByService", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByService(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "tenantsettings.TenantSettingsClient", "ListByService", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListByServiceComplete retrieves all of the results into a single object -func (c TenantSettingsClient) ListByServiceComplete(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (ListByServiceCompleteResult, error) { - return c.ListByServiceCompleteMatchingPredicate(ctx, id, options, TenantSettingsContractOperationPredicate{}) -} - -// ListByServiceCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c TenantSettingsClient) ListByServiceCompleteMatchingPredicate(ctx context.Context, id ServiceId, options ListByServiceOperationOptions, predicate TenantSettingsContractOperationPredicate) (resp ListByServiceCompleteResult, err error) { - items := make([]TenantSettingsContract, 0) - - page, err := c.ListByService(ctx, id, options) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListByServiceCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/apimanagement/2021-08-01/user/client.go b/resource-manager/apimanagement/2021-08-01/user/client.go index edf5ba84ceb..68cdf855892 100644 --- a/resource-manager/apimanagement/2021-08-01/user/client.go +++ b/resource-manager/apimanagement/2021-08-01/user/client.go @@ -1,18 +1,26 @@ package user -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 UserClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewUserClientWithBaseURI(endpoint string) UserClient { - return UserClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewUserClientWithBaseURI(api environments.Api) (*UserClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "user", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating UserClient: %+v", err) } + + return &UserClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2021-08-01/user/constants.go b/resource-manager/apimanagement/2021-08-01/user/constants.go index e5b9de9b614..83573cf87af 100644 --- a/resource-manager/apimanagement/2021-08-01/user/constants.go +++ b/resource-manager/apimanagement/2021-08-01/user/constants.go @@ -1,6 +1,10 @@ package user -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 PossibleValuesForAppType() []string { } } +func (s *AppType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAppType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseAppType(input string) (*AppType, error) { vals := map[string]AppType{ "developerportal": AppTypeDeveloperPortal, @@ -47,6 +64,19 @@ func PossibleValuesForConfirmation() []string { } } +func (s *Confirmation) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseConfirmation(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseConfirmation(input string) (*Confirmation, error) { vals := map[string]Confirmation{ "invite": ConfirmationInvite, @@ -77,6 +107,19 @@ func PossibleValuesForGroupType() []string { } } +func (s *GroupType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseGroupType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseGroupType(input string) (*GroupType, error) { vals := map[string]GroupType{ "custom": GroupTypeCustom, @@ -110,6 +153,19 @@ func PossibleValuesForUserState() []string { } } +func (s *UserState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseUserState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseUserState(input string) (*UserState, error) { vals := map[string]UserState{ "active": UserStateActive, diff --git a/resource-manager/apimanagement/2021-08-01/user/method_createorupdate.go b/resource-manager/apimanagement/2021-08-01/user/method_createorupdate.go new file mode 100644 index 00000000000..6ff0ddbf251 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/user/method_createorupdate.go @@ -0,0 +1,88 @@ +package user + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *UserContract +} + +type CreateOrUpdateOperationOptions struct { + IfMatch *string + Notify *bool +} + +func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { + return CreateOrUpdateOperationOptions{} +} + +func (o CreateOrUpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o CreateOrUpdateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o CreateOrUpdateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Notify != nil { + out.Append("notify", fmt.Sprintf("%v", *o.Notify)) + } + return &out +} + +// CreateOrUpdate ... +func (c UserClient) CreateOrUpdate(ctx context.Context, id UserId, input UserCreateParameters, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + OptionsObject: options, + } + + 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/apimanagement/2021-08-01/user/method_createorupdate_autorest.go b/resource-manager/apimanagement/2021-08-01/user/method_createorupdate_autorest.go deleted file mode 100644 index 2d354273eac..00000000000 --- a/resource-manager/apimanagement/2021-08-01/user/method_createorupdate_autorest.go +++ /dev/null @@ -1,103 +0,0 @@ -package user - -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 *UserContract -} - -type CreateOrUpdateOperationOptions struct { - IfMatch *string - Notify *bool -} - -func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { - return CreateOrUpdateOperationOptions{} -} - -func (o CreateOrUpdateOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o CreateOrUpdateOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Notify != nil { - out["notify"] = *o.Notify - } - - return out -} - -// CreateOrUpdate ... -func (c UserClient) CreateOrUpdate(ctx context.Context, id UserId, input UserCreateParameters, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdate(ctx, id, input, options) - if err != nil { - err = autorest.NewErrorWithError(err, "user.UserClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "user.UserClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCreateOrUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "user.UserClient", "CreateOrUpdate", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCreateOrUpdate prepares the CreateOrUpdate request. -func (c UserClient) preparerForCreateOrUpdate(ctx context.Context, id UserId, input UserCreateParameters, options CreateOrUpdateOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - 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 UserClient) responderForCreateOrUpdate(resp *http.Response) (result CreateOrUpdateOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2021-08-01/user/method_delete.go b/resource-manager/apimanagement/2021-08-01/user/method_delete.go new file mode 100644 index 00000000000..fd6b3518902 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/user/method_delete.go @@ -0,0 +1,87 @@ +package user + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +type DeleteOperationOptions struct { + AppType *AppType + DeleteSubscriptions *bool + IfMatch *string + Notify *bool +} + +func DefaultDeleteOperationOptions() DeleteOperationOptions { + return DeleteOperationOptions{} +} + +func (o DeleteOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o DeleteOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o DeleteOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.AppType != nil { + out.Append("appType", fmt.Sprintf("%v", *o.AppType)) + } + if o.DeleteSubscriptions != nil { + out.Append("deleteSubscriptions", fmt.Sprintf("%v", *o.DeleteSubscriptions)) + } + if o.Notify != nil { + out.Append("notify", fmt.Sprintf("%v", *o.Notify)) + } + return &out +} + +// Delete ... +func (c UserClient) Delete(ctx context.Context, id UserId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2021-08-01/user/method_delete_autorest.go b/resource-manager/apimanagement/2021-08-01/user/method_delete_autorest.go deleted file mode 100644 index 34b48b3fa26..00000000000 --- a/resource-manager/apimanagement/2021-08-01/user/method_delete_autorest.go +++ /dev/null @@ -1,110 +0,0 @@ -package user - -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 DeleteOperationResponse struct { - HttpResponse *http.Response -} - -type DeleteOperationOptions struct { - AppType *AppType - DeleteSubscriptions *bool - IfMatch *string - Notify *bool -} - -func DefaultDeleteOperationOptions() DeleteOperationOptions { - return DeleteOperationOptions{} -} - -func (o DeleteOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o DeleteOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.AppType != nil { - out["appType"] = *o.AppType - } - - if o.DeleteSubscriptions != nil { - out["deleteSubscriptions"] = *o.DeleteSubscriptions - } - - if o.Notify != nil { - out["notify"] = *o.Notify - } - - return out -} - -// Delete ... -func (c UserClient) Delete(ctx context.Context, id UserId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { - req, err := c.preparerForDelete(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "user.UserClient", "Delete", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "user.UserClient", "Delete", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForDelete(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "user.UserClient", "Delete", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForDelete prepares the Delete request. -func (c UserClient) preparerForDelete(ctx context.Context, id UserId, options DeleteOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForDelete handles the response to the Delete request. The method always -// closes the http.Response Body. -func (c UserClient) responderForDelete(resp *http.Response) (result DeleteOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2021-08-01/user/method_get.go b/resource-manager/apimanagement/2021-08-01/user/method_get.go new file mode 100644 index 00000000000..c70fed38ef8 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/user/method_get.go @@ -0,0 +1,51 @@ +package user + +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 *UserContract +} + +// Get ... +func (c UserClient) Get(ctx context.Context, id UserId) (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/apimanagement/2021-08-01/user/method_get_autorest.go b/resource-manager/apimanagement/2021-08-01/user/method_get_autorest.go deleted file mode 100644 index e3b8b477c77..00000000000 --- a/resource-manager/apimanagement/2021-08-01/user/method_get_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package user - -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 *UserContract -} - -// Get ... -func (c UserClient) Get(ctx context.Context, id UserId) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "user.UserClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "user.UserClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "user.UserClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c UserClient) preparerForGet(ctx context.Context, id UserId) (*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 UserClient) 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/apimanagement/2021-08-01/user/method_getentitytag.go b/resource-manager/apimanagement/2021-08-01/user/method_getentitytag.go new file mode 100644 index 00000000000..bc31a7c3697 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/user/method_getentitytag.go @@ -0,0 +1,46 @@ +package user + +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 GetEntityTagOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// GetEntityTag ... +func (c UserClient) GetEntityTag(ctx context.Context, id UserId) (result GetEntityTagOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodHead, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2021-08-01/user/method_getentitytag_autorest.go b/resource-manager/apimanagement/2021-08-01/user/method_getentitytag_autorest.go deleted file mode 100644 index ec2d361cccd..00000000000 --- a/resource-manager/apimanagement/2021-08-01/user/method_getentitytag_autorest.go +++ /dev/null @@ -1,66 +0,0 @@ -package user - -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 GetEntityTagOperationResponse struct { - HttpResponse *http.Response -} - -// GetEntityTag ... -func (c UserClient) GetEntityTag(ctx context.Context, id UserId) (result GetEntityTagOperationResponse, err error) { - req, err := c.preparerForGetEntityTag(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "user.UserClient", "GetEntityTag", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "user.UserClient", "GetEntityTag", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetEntityTag(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "user.UserClient", "GetEntityTag", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetEntityTag prepares the GetEntityTag request. -func (c UserClient) preparerForGetEntityTag(ctx context.Context, id UserId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsHead(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetEntityTag handles the response to the GetEntityTag request. The method always -// closes the http.Response Body. -func (c UserClient) responderForGetEntityTag(resp *http.Response) (result GetEntityTagOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2021-08-01/user/method_listbyservice.go b/resource-manager/apimanagement/2021-08-01/user/method_listbyservice.go new file mode 100644 index 00000000000..5882829e90c --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/user/method_listbyservice.go @@ -0,0 +1,129 @@ +package user + +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 ListByServiceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]UserContract +} + +type ListByServiceCompleteResult struct { + Items []UserContract +} + +type ListByServiceOperationOptions struct { + ExpandGroups *bool + Filter *string + Skip *int64 + Top *int64 +} + +func DefaultListByServiceOperationOptions() ListByServiceOperationOptions { + return ListByServiceOperationOptions{} +} + +func (o ListByServiceOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListByServiceOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListByServiceOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.ExpandGroups != nil { + out.Append("expandGroups", fmt.Sprintf("%v", *o.ExpandGroups)) + } + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.Skip != nil { + out.Append("$skip", fmt.Sprintf("%v", *o.Skip)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +// ListByService ... +func (c UserClient) ListByService(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (result ListByServiceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/users", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]UserContract `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByServiceComplete retrieves all the results into a single object +func (c UserClient) ListByServiceComplete(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (ListByServiceCompleteResult, error) { + return c.ListByServiceCompleteMatchingPredicate(ctx, id, options, UserContractOperationPredicate{}) +} + +// ListByServiceCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c UserClient) ListByServiceCompleteMatchingPredicate(ctx context.Context, id ServiceId, options ListByServiceOperationOptions, predicate UserContractOperationPredicate) (result ListByServiceCompleteResult, err error) { + items := make([]UserContract, 0) + + resp, err := c.ListByService(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByServiceCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/apimanagement/2021-08-01/user/method_listbyservice_autorest.go b/resource-manager/apimanagement/2021-08-01/user/method_listbyservice_autorest.go deleted file mode 100644 index 8304e22f9e4..00000000000 --- a/resource-manager/apimanagement/2021-08-01/user/method_listbyservice_autorest.go +++ /dev/null @@ -1,230 +0,0 @@ -package user - -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 ListByServiceOperationResponse struct { - HttpResponse *http.Response - Model *[]UserContract - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListByServiceOperationResponse, error) -} - -type ListByServiceCompleteResult struct { - Items []UserContract -} - -func (r ListByServiceOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListByServiceOperationResponse) LoadMore(ctx context.Context) (resp ListByServiceOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -type ListByServiceOperationOptions struct { - ExpandGroups *bool - Filter *string - Skip *int64 - Top *int64 -} - -func DefaultListByServiceOperationOptions() ListByServiceOperationOptions { - return ListByServiceOperationOptions{} -} - -func (o ListByServiceOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o ListByServiceOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.ExpandGroups != nil { - out["expandGroups"] = *o.ExpandGroups - } - - if o.Filter != nil { - out["$filter"] = *o.Filter - } - - if o.Skip != nil { - out["$skip"] = *o.Skip - } - - if o.Top != nil { - out["$top"] = *o.Top - } - - return out -} - -// ListByService ... -func (c UserClient) ListByService(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (resp ListByServiceOperationResponse, err error) { - req, err := c.preparerForListByService(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "user.UserClient", "ListByService", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "user.UserClient", "ListByService", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListByService(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "user.UserClient", "ListByService", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListByService prepares the ListByService request. -func (c UserClient) preparerForListByService(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/users", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListByServiceWithNextLink prepares the ListByService request with the given nextLink token. -func (c UserClient) preparerForListByServiceWithNextLink(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)) -} - -// responderForListByService handles the response to the ListByService request. The method always -// closes the http.Response Body. -func (c UserClient) responderForListByService(resp *http.Response) (result ListByServiceOperationResponse, err error) { - type page struct { - Values []UserContract `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 ListByServiceOperationResponse, err error) { - req, err := c.preparerForListByServiceWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "user.UserClient", "ListByService", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "user.UserClient", "ListByService", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByService(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "user.UserClient", "ListByService", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListByServiceComplete retrieves all of the results into a single object -func (c UserClient) ListByServiceComplete(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (ListByServiceCompleteResult, error) { - return c.ListByServiceCompleteMatchingPredicate(ctx, id, options, UserContractOperationPredicate{}) -} - -// ListByServiceCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c UserClient) ListByServiceCompleteMatchingPredicate(ctx context.Context, id ServiceId, options ListByServiceOperationOptions, predicate UserContractOperationPredicate) (resp ListByServiceCompleteResult, err error) { - items := make([]UserContract, 0) - - page, err := c.ListByService(ctx, id, options) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListByServiceCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/apimanagement/2021-08-01/user/method_update.go b/resource-manager/apimanagement/2021-08-01/user/method_update.go new file mode 100644 index 00000000000..ed43e43248d --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/user/method_update.go @@ -0,0 +1,84 @@ +package user + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *UserContract +} + +type UpdateOperationOptions struct { + IfMatch *string +} + +func DefaultUpdateOperationOptions() UpdateOperationOptions { + return UpdateOperationOptions{} +} + +func (o UpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o UpdateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o UpdateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// Update ... +func (c UserClient) Update(ctx context.Context, id UserId, input UserUpdateParameters, options UpdateOperationOptions) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + OptionsObject: options, + } + + 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/apimanagement/2021-08-01/user/method_update_autorest.go b/resource-manager/apimanagement/2021-08-01/user/method_update_autorest.go deleted file mode 100644 index 38f81f608fd..00000000000 --- a/resource-manager/apimanagement/2021-08-01/user/method_update_autorest.go +++ /dev/null @@ -1,98 +0,0 @@ -package user - -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 *UserContract -} - -type UpdateOperationOptions struct { - IfMatch *string -} - -func DefaultUpdateOperationOptions() UpdateOperationOptions { - return UpdateOperationOptions{} -} - -func (o UpdateOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o UpdateOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// Update ... -func (c UserClient) Update(ctx context.Context, id UserId, input UserUpdateParameters, options UpdateOperationOptions) (result UpdateOperationResponse, err error) { - req, err := c.preparerForUpdate(ctx, id, input, options) - if err != nil { - err = autorest.NewErrorWithError(err, "user.UserClient", "Update", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "user.UserClient", "Update", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "user.UserClient", "Update", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForUpdate prepares the Update request. -func (c UserClient) preparerForUpdate(ctx context.Context, id UserId, input UserUpdateParameters, options UpdateOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPatch(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - 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 UserClient) 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/apimanagement/2021-08-01/userconfirmationpasswordsend/client.go b/resource-manager/apimanagement/2021-08-01/userconfirmationpasswordsend/client.go index 756489454aa..3a81da4d203 100644 --- a/resource-manager/apimanagement/2021-08-01/userconfirmationpasswordsend/client.go +++ b/resource-manager/apimanagement/2021-08-01/userconfirmationpasswordsend/client.go @@ -1,18 +1,26 @@ package userconfirmationpasswordsend -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 UserConfirmationPasswordSendClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewUserConfirmationPasswordSendClientWithBaseURI(endpoint string) UserConfirmationPasswordSendClient { - return UserConfirmationPasswordSendClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewUserConfirmationPasswordSendClientWithBaseURI(api environments.Api) (*UserConfirmationPasswordSendClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "userconfirmationpasswordsend", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating UserConfirmationPasswordSendClient: %+v", err) } + + return &UserConfirmationPasswordSendClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2021-08-01/userconfirmationpasswordsend/constants.go b/resource-manager/apimanagement/2021-08-01/userconfirmationpasswordsend/constants.go index cc153945e69..c532eea3196 100644 --- a/resource-manager/apimanagement/2021-08-01/userconfirmationpasswordsend/constants.go +++ b/resource-manager/apimanagement/2021-08-01/userconfirmationpasswordsend/constants.go @@ -1,6 +1,10 @@ package userconfirmationpasswordsend -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 PossibleValuesForAppType() []string { } } +func (s *AppType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAppType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseAppType(input string) (*AppType, error) { vals := map[string]AppType{ "developerportal": AppTypeDeveloperPortal, diff --git a/resource-manager/apimanagement/2021-08-01/userconfirmationpasswordsend/method_userconfirmationpasswordsend.go b/resource-manager/apimanagement/2021-08-01/userconfirmationpasswordsend/method_userconfirmationpasswordsend.go new file mode 100644 index 00000000000..883292fd0c2 --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/userconfirmationpasswordsend/method_userconfirmationpasswordsend.go @@ -0,0 +1,75 @@ +package userconfirmationpasswordsend + +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 UserConfirmationPasswordSendOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +type UserConfirmationPasswordSendOperationOptions struct { + AppType *AppType +} + +func DefaultUserConfirmationPasswordSendOperationOptions() UserConfirmationPasswordSendOperationOptions { + return UserConfirmationPasswordSendOperationOptions{} +} + +func (o UserConfirmationPasswordSendOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o UserConfirmationPasswordSendOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o UserConfirmationPasswordSendOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.AppType != nil { + out.Append("appType", fmt.Sprintf("%v", *o.AppType)) + } + return &out +} + +// UserConfirmationPasswordSend ... +func (c UserConfirmationPasswordSendClient) UserConfirmationPasswordSend(ctx context.Context, id UserId, options UserConfirmationPasswordSendOperationOptions) (result UserConfirmationPasswordSendOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/confirmations/password/send", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2021-08-01/userconfirmationpasswordsend/method_userconfirmationpasswordsend_autorest.go b/resource-manager/apimanagement/2021-08-01/userconfirmationpasswordsend/method_userconfirmationpasswordsend_autorest.go deleted file mode 100644 index 8a9f0a68633..00000000000 --- a/resource-manager/apimanagement/2021-08-01/userconfirmationpasswordsend/method_userconfirmationpasswordsend_autorest.go +++ /dev/null @@ -1,96 +0,0 @@ -package userconfirmationpasswordsend - -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 UserConfirmationPasswordSendOperationResponse struct { - HttpResponse *http.Response -} - -type UserConfirmationPasswordSendOperationOptions struct { - AppType *AppType -} - -func DefaultUserConfirmationPasswordSendOperationOptions() UserConfirmationPasswordSendOperationOptions { - return UserConfirmationPasswordSendOperationOptions{} -} - -func (o UserConfirmationPasswordSendOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o UserConfirmationPasswordSendOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.AppType != nil { - out["appType"] = *o.AppType - } - - return out -} - -// UserConfirmationPasswordSend ... -func (c UserConfirmationPasswordSendClient) UserConfirmationPasswordSend(ctx context.Context, id UserId, options UserConfirmationPasswordSendOperationOptions) (result UserConfirmationPasswordSendOperationResponse, err error) { - req, err := c.preparerForUserConfirmationPasswordSend(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "userconfirmationpasswordsend.UserConfirmationPasswordSendClient", "UserConfirmationPasswordSend", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "userconfirmationpasswordsend.UserConfirmationPasswordSendClient", "UserConfirmationPasswordSend", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForUserConfirmationPasswordSend(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "userconfirmationpasswordsend.UserConfirmationPasswordSendClient", "UserConfirmationPasswordSend", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForUserConfirmationPasswordSend prepares the UserConfirmationPasswordSend request. -func (c UserConfirmationPasswordSendClient) preparerForUserConfirmationPasswordSend(ctx context.Context, id UserId, options UserConfirmationPasswordSendOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/confirmations/password/send", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForUserConfirmationPasswordSend handles the response to the UserConfirmationPasswordSend request. The method always -// closes the http.Response Body. -func (c UserConfirmationPasswordSendClient) responderForUserConfirmationPasswordSend(resp *http.Response) (result UserConfirmationPasswordSendOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2021-08-01/usergroup/client.go b/resource-manager/apimanagement/2021-08-01/usergroup/client.go index d08c65ca35c..c00726aa8ef 100644 --- a/resource-manager/apimanagement/2021-08-01/usergroup/client.go +++ b/resource-manager/apimanagement/2021-08-01/usergroup/client.go @@ -1,18 +1,26 @@ package usergroup -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 UserGroupClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewUserGroupClientWithBaseURI(endpoint string) UserGroupClient { - return UserGroupClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewUserGroupClientWithBaseURI(api environments.Api) (*UserGroupClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "usergroup", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating UserGroupClient: %+v", err) } + + return &UserGroupClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2021-08-01/usergroup/constants.go b/resource-manager/apimanagement/2021-08-01/usergroup/constants.go index ea114107530..8762d75fc71 100644 --- a/resource-manager/apimanagement/2021-08-01/usergroup/constants.go +++ b/resource-manager/apimanagement/2021-08-01/usergroup/constants.go @@ -1,6 +1,10 @@ package usergroup -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 PossibleValuesForGroupType() []string { } } +func (s *GroupType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseGroupType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseGroupType(input string) (*GroupType, error) { vals := map[string]GroupType{ "custom": GroupTypeCustom, diff --git a/resource-manager/apimanagement/2021-08-01/usergroup/method_list.go b/resource-manager/apimanagement/2021-08-01/usergroup/method_list.go new file mode 100644 index 00000000000..c59680e814a --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/usergroup/method_list.go @@ -0,0 +1,125 @@ +package usergroup + +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 *[]GroupContract +} + +type ListCompleteResult struct { + Items []GroupContract +} + +type ListOperationOptions struct { + Filter *string + Skip *int64 + Top *int64 +} + +func DefaultListOperationOptions() ListOperationOptions { + return ListOperationOptions{} +} + +func (o ListOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.Skip != nil { + out.Append("$skip", fmt.Sprintf("%v", *o.Skip)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +// List ... +func (c UserGroupClient) List(ctx context.Context, id UserId, options ListOperationOptions) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/groups", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]GroupContract `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 UserGroupClient) ListComplete(ctx context.Context, id UserId, options ListOperationOptions) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, options, GroupContractOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c UserGroupClient) ListCompleteMatchingPredicate(ctx context.Context, id UserId, options ListOperationOptions, predicate GroupContractOperationPredicate) (result ListCompleteResult, err error) { + items := make([]GroupContract, 0) + + resp, err := c.List(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/apimanagement/2021-08-01/usergroup/method_list_autorest.go b/resource-manager/apimanagement/2021-08-01/usergroup/method_list_autorest.go deleted file mode 100644 index 61e0bb9e690..00000000000 --- a/resource-manager/apimanagement/2021-08-01/usergroup/method_list_autorest.go +++ /dev/null @@ -1,225 +0,0 @@ -package usergroup - -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 *[]GroupContract - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListOperationResponse, error) -} - -type ListCompleteResult struct { - Items []GroupContract -} - -func (r ListOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListOperationResponse) LoadMore(ctx context.Context) (resp ListOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -type ListOperationOptions struct { - Filter *string - Skip *int64 - Top *int64 -} - -func DefaultListOperationOptions() ListOperationOptions { - return ListOperationOptions{} -} - -func (o ListOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o ListOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Filter != nil { - out["$filter"] = *o.Filter - } - - if o.Skip != nil { - out["$skip"] = *o.Skip - } - - if o.Top != nil { - out["$top"] = *o.Top - } - - return out -} - -// List ... -func (c UserGroupClient) List(ctx context.Context, id UserId, options ListOperationOptions) (resp ListOperationResponse, err error) { - req, err := c.preparerForList(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "usergroup.UserGroupClient", "List", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "usergroup.UserGroupClient", "List", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForList(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "usergroup.UserGroupClient", "List", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForList prepares the List request. -func (c UserGroupClient) preparerForList(ctx context.Context, id UserId, options ListOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/groups", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListWithNextLink prepares the List request with the given nextLink token. -func (c UserGroupClient) 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 UserGroupClient) responderForList(resp *http.Response) (result ListOperationResponse, err error) { - type page struct { - Values []GroupContract `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, "usergroup.UserGroupClient", "List", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "usergroup.UserGroupClient", "List", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForList(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "usergroup.UserGroupClient", "List", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListComplete retrieves all of the results into a single object -func (c UserGroupClient) ListComplete(ctx context.Context, id UserId, options ListOperationOptions) (ListCompleteResult, error) { - return c.ListCompleteMatchingPredicate(ctx, id, options, GroupContractOperationPredicate{}) -} - -// ListCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c UserGroupClient) ListCompleteMatchingPredicate(ctx context.Context, id UserId, options ListOperationOptions, predicate GroupContractOperationPredicate) (resp ListCompleteResult, err error) { - items := make([]GroupContract, 0) - - page, err := c.List(ctx, id, options) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/apimanagement/2021-08-01/useridentity/client.go b/resource-manager/apimanagement/2021-08-01/useridentity/client.go index 4ae90e35324..ba69a70cbf8 100644 --- a/resource-manager/apimanagement/2021-08-01/useridentity/client.go +++ b/resource-manager/apimanagement/2021-08-01/useridentity/client.go @@ -1,18 +1,26 @@ package useridentity -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 UserIdentityClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewUserIdentityClientWithBaseURI(endpoint string) UserIdentityClient { - return UserIdentityClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewUserIdentityClientWithBaseURI(api environments.Api) (*UserIdentityClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "useridentity", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating UserIdentityClient: %+v", err) } + + return &UserIdentityClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2021-08-01/useridentity/method_useridentitieslist.go b/resource-manager/apimanagement/2021-08-01/useridentity/method_useridentitieslist.go new file mode 100644 index 00000000000..74e3593f0ab --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/useridentity/method_useridentitieslist.go @@ -0,0 +1,89 @@ +package useridentity + +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 UserIdentitiesListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]UserIdentityContract +} + +type UserIdentitiesListCompleteResult struct { + Items []UserIdentityContract +} + +// UserIdentitiesList ... +func (c UserIdentityClient) UserIdentitiesList(ctx context.Context, id UserId) (result UserIdentitiesListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/identities", 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 *[]UserIdentityContract `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// UserIdentitiesListComplete retrieves all the results into a single object +func (c UserIdentityClient) UserIdentitiesListComplete(ctx context.Context, id UserId) (UserIdentitiesListCompleteResult, error) { + return c.UserIdentitiesListCompleteMatchingPredicate(ctx, id, UserIdentityContractOperationPredicate{}) +} + +// UserIdentitiesListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c UserIdentityClient) UserIdentitiesListCompleteMatchingPredicate(ctx context.Context, id UserId, predicate UserIdentityContractOperationPredicate) (result UserIdentitiesListCompleteResult, err error) { + items := make([]UserIdentityContract, 0) + + resp, err := c.UserIdentitiesList(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 = UserIdentitiesListCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/apimanagement/2021-08-01/useridentity/method_useridentitieslist_autorest.go b/resource-manager/apimanagement/2021-08-01/useridentity/method_useridentitieslist_autorest.go deleted file mode 100644 index 6374338ce31..00000000000 --- a/resource-manager/apimanagement/2021-08-01/useridentity/method_useridentitieslist_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package useridentity - -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 UserIdentitiesListOperationResponse struct { - HttpResponse *http.Response - Model *[]UserIdentityContract - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (UserIdentitiesListOperationResponse, error) -} - -type UserIdentitiesListCompleteResult struct { - Items []UserIdentityContract -} - -func (r UserIdentitiesListOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r UserIdentitiesListOperationResponse) LoadMore(ctx context.Context) (resp UserIdentitiesListOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// UserIdentitiesList ... -func (c UserIdentityClient) UserIdentitiesList(ctx context.Context, id UserId) (resp UserIdentitiesListOperationResponse, err error) { - req, err := c.preparerForUserIdentitiesList(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "useridentity.UserIdentityClient", "UserIdentitiesList", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "useridentity.UserIdentityClient", "UserIdentitiesList", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForUserIdentitiesList(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "useridentity.UserIdentityClient", "UserIdentitiesList", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForUserIdentitiesList prepares the UserIdentitiesList request. -func (c UserIdentityClient) preparerForUserIdentitiesList(ctx context.Context, id UserId) (*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/identities", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForUserIdentitiesListWithNextLink prepares the UserIdentitiesList request with the given nextLink token. -func (c UserIdentityClient) preparerForUserIdentitiesListWithNextLink(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)) -} - -// responderForUserIdentitiesList handles the response to the UserIdentitiesList request. The method always -// closes the http.Response Body. -func (c UserIdentityClient) responderForUserIdentitiesList(resp *http.Response) (result UserIdentitiesListOperationResponse, err error) { - type page struct { - Values []UserIdentityContract `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 UserIdentitiesListOperationResponse, err error) { - req, err := c.preparerForUserIdentitiesListWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "useridentity.UserIdentityClient", "UserIdentitiesList", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "useridentity.UserIdentityClient", "UserIdentitiesList", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForUserIdentitiesList(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "useridentity.UserIdentityClient", "UserIdentitiesList", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// UserIdentitiesListComplete retrieves all of the results into a single object -func (c UserIdentityClient) UserIdentitiesListComplete(ctx context.Context, id UserId) (UserIdentitiesListCompleteResult, error) { - return c.UserIdentitiesListCompleteMatchingPredicate(ctx, id, UserIdentityContractOperationPredicate{}) -} - -// UserIdentitiesListCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c UserIdentityClient) UserIdentitiesListCompleteMatchingPredicate(ctx context.Context, id UserId, predicate UserIdentityContractOperationPredicate) (resp UserIdentitiesListCompleteResult, err error) { - items := make([]UserIdentityContract, 0) - - page, err := c.UserIdentitiesList(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 := UserIdentitiesListCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/apimanagement/2021-08-01/users/client.go b/resource-manager/apimanagement/2021-08-01/users/client.go index eead37dfa09..b2fbba7618b 100644 --- a/resource-manager/apimanagement/2021-08-01/users/client.go +++ b/resource-manager/apimanagement/2021-08-01/users/client.go @@ -1,18 +1,26 @@ package users -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 UsersClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewUsersClientWithBaseURI(endpoint string) UsersClient { - return UsersClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewUsersClientWithBaseURI(api environments.Api) (*UsersClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "users", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating UsersClient: %+v", err) } + + return &UsersClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2021-08-01/users/method_usergeneratessourl.go b/resource-manager/apimanagement/2021-08-01/users/method_usergeneratessourl.go new file mode 100644 index 00000000000..9cf69e473cf --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/users/method_usergeneratessourl.go @@ -0,0 +1,52 @@ +package users + +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 UserGenerateSsoUrlOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *GenerateSsoUrlResult +} + +// UserGenerateSsoUrl ... +func (c UsersClient) UserGenerateSsoUrl(ctx context.Context, id UserId) (result UserGenerateSsoUrlOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/generateSsoUrl", 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/apimanagement/2021-08-01/users/method_usergeneratessourl_autorest.go b/resource-manager/apimanagement/2021-08-01/users/method_usergeneratessourl_autorest.go deleted file mode 100644 index 90bf6c3ad37..00000000000 --- a/resource-manager/apimanagement/2021-08-01/users/method_usergeneratessourl_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package users - -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 UserGenerateSsoUrlOperationResponse struct { - HttpResponse *http.Response - Model *GenerateSsoUrlResult -} - -// UserGenerateSsoUrl ... -func (c UsersClient) UserGenerateSsoUrl(ctx context.Context, id UserId) (result UserGenerateSsoUrlOperationResponse, err error) { - req, err := c.preparerForUserGenerateSsoUrl(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "users.UsersClient", "UserGenerateSsoUrl", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "users.UsersClient", "UserGenerateSsoUrl", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForUserGenerateSsoUrl(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "users.UsersClient", "UserGenerateSsoUrl", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForUserGenerateSsoUrl prepares the UserGenerateSsoUrl request. -func (c UsersClient) preparerForUserGenerateSsoUrl(ctx context.Context, id UserId) (*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/generateSsoUrl", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForUserGenerateSsoUrl handles the response to the UserGenerateSsoUrl request. The method always -// closes the http.Response Body. -func (c UsersClient) responderForUserGenerateSsoUrl(resp *http.Response) (result UserGenerateSsoUrlOperationResponse, 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/apimanagement/2021-08-01/usersubscription/client.go b/resource-manager/apimanagement/2021-08-01/usersubscription/client.go index d3ba8ac4ce8..2b0a8bfdf91 100644 --- a/resource-manager/apimanagement/2021-08-01/usersubscription/client.go +++ b/resource-manager/apimanagement/2021-08-01/usersubscription/client.go @@ -1,18 +1,26 @@ package usersubscription -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 UserSubscriptionClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewUserSubscriptionClientWithBaseURI(endpoint string) UserSubscriptionClient { - return UserSubscriptionClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewUserSubscriptionClientWithBaseURI(api environments.Api) (*UserSubscriptionClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "usersubscription", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating UserSubscriptionClient: %+v", err) } + + return &UserSubscriptionClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2021-08-01/usersubscription/constants.go b/resource-manager/apimanagement/2021-08-01/usersubscription/constants.go index f7ed9ea1ce6..8999ff3cae7 100644 --- a/resource-manager/apimanagement/2021-08-01/usersubscription/constants.go +++ b/resource-manager/apimanagement/2021-08-01/usersubscription/constants.go @@ -1,6 +1,10 @@ package usersubscription -import "strings" +import ( + "encoding/json" + "fmt" + "strings" +) // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See NOTICE.txt in the project root for license information. @@ -27,6 +31,19 @@ func PossibleValuesForSubscriptionState() []string { } } +func (s *SubscriptionState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSubscriptionState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseSubscriptionState(input string) (*SubscriptionState, error) { vals := map[string]SubscriptionState{ "active": SubscriptionStateActive, diff --git a/resource-manager/apimanagement/2021-08-01/usersubscription/method_list.go b/resource-manager/apimanagement/2021-08-01/usersubscription/method_list.go new file mode 100644 index 00000000000..e66d1f8242d --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/usersubscription/method_list.go @@ -0,0 +1,125 @@ +package usersubscription + +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 *[]SubscriptionContract +} + +type ListCompleteResult struct { + Items []SubscriptionContract +} + +type ListOperationOptions struct { + Filter *string + Skip *int64 + Top *int64 +} + +func DefaultListOperationOptions() ListOperationOptions { + return ListOperationOptions{} +} + +func (o ListOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.Skip != nil { + out.Append("$skip", fmt.Sprintf("%v", *o.Skip)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +// List ... +func (c UserSubscriptionClient) List(ctx context.Context, id UserId, options ListOperationOptions) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/subscriptions", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]SubscriptionContract `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 UserSubscriptionClient) ListComplete(ctx context.Context, id UserId, options ListOperationOptions) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, options, SubscriptionContractOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c UserSubscriptionClient) ListCompleteMatchingPredicate(ctx context.Context, id UserId, options ListOperationOptions, predicate SubscriptionContractOperationPredicate) (result ListCompleteResult, err error) { + items := make([]SubscriptionContract, 0) + + resp, err := c.List(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/apimanagement/2021-08-01/usersubscription/method_list_autorest.go b/resource-manager/apimanagement/2021-08-01/usersubscription/method_list_autorest.go deleted file mode 100644 index e7fd01255cc..00000000000 --- a/resource-manager/apimanagement/2021-08-01/usersubscription/method_list_autorest.go +++ /dev/null @@ -1,225 +0,0 @@ -package usersubscription - -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 *[]SubscriptionContract - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListOperationResponse, error) -} - -type ListCompleteResult struct { - Items []SubscriptionContract -} - -func (r ListOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListOperationResponse) LoadMore(ctx context.Context) (resp ListOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -type ListOperationOptions struct { - Filter *string - Skip *int64 - Top *int64 -} - -func DefaultListOperationOptions() ListOperationOptions { - return ListOperationOptions{} -} - -func (o ListOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o ListOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Filter != nil { - out["$filter"] = *o.Filter - } - - if o.Skip != nil { - out["$skip"] = *o.Skip - } - - if o.Top != nil { - out["$top"] = *o.Top - } - - return out -} - -// List ... -func (c UserSubscriptionClient) List(ctx context.Context, id UserId, options ListOperationOptions) (resp ListOperationResponse, err error) { - req, err := c.preparerForList(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "usersubscription.UserSubscriptionClient", "List", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "usersubscription.UserSubscriptionClient", "List", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForList(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "usersubscription.UserSubscriptionClient", "List", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForList prepares the List request. -func (c UserSubscriptionClient) preparerForList(ctx context.Context, id UserId, options ListOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/subscriptions", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListWithNextLink prepares the List request with the given nextLink token. -func (c UserSubscriptionClient) 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 UserSubscriptionClient) responderForList(resp *http.Response) (result ListOperationResponse, err error) { - type page struct { - Values []SubscriptionContract `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, "usersubscription.UserSubscriptionClient", "List", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "usersubscription.UserSubscriptionClient", "List", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForList(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "usersubscription.UserSubscriptionClient", "List", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListComplete retrieves all of the results into a single object -func (c UserSubscriptionClient) ListComplete(ctx context.Context, id UserId, options ListOperationOptions) (ListCompleteResult, error) { - return c.ListCompleteMatchingPredicate(ctx, id, options, SubscriptionContractOperationPredicate{}) -} - -// ListCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c UserSubscriptionClient) ListCompleteMatchingPredicate(ctx context.Context, id UserId, options ListOperationOptions, predicate SubscriptionContractOperationPredicate) (resp ListCompleteResult, err error) { - items := make([]SubscriptionContract, 0) - - page, err := c.List(ctx, id, options) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/apimanagement/2021-08-01/usertoken/client.go b/resource-manager/apimanagement/2021-08-01/usertoken/client.go index ba17707e000..d1c1e1db7b3 100644 --- a/resource-manager/apimanagement/2021-08-01/usertoken/client.go +++ b/resource-manager/apimanagement/2021-08-01/usertoken/client.go @@ -1,18 +1,26 @@ package usertoken -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 UserTokenClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewUserTokenClientWithBaseURI(endpoint string) UserTokenClient { - return UserTokenClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewUserTokenClientWithBaseURI(api environments.Api) (*UserTokenClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "usertoken", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating UserTokenClient: %+v", err) } + + return &UserTokenClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2021-08-01/usertoken/constants.go b/resource-manager/apimanagement/2021-08-01/usertoken/constants.go index 9a1db97e8df..9c811483fc3 100644 --- a/resource-manager/apimanagement/2021-08-01/usertoken/constants.go +++ b/resource-manager/apimanagement/2021-08-01/usertoken/constants.go @@ -1,6 +1,10 @@ package usertoken -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 PossibleValuesForKeyType() []string { } } +func (s *KeyType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseKeyType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseKeyType(input string) (*KeyType, error) { vals := map[string]KeyType{ "primary": KeyTypePrimary, diff --git a/resource-manager/apimanagement/2021-08-01/usertoken/method_usergetsharedaccesstoken.go b/resource-manager/apimanagement/2021-08-01/usertoken/method_usergetsharedaccesstoken.go new file mode 100644 index 00000000000..c4fe631328a --- /dev/null +++ b/resource-manager/apimanagement/2021-08-01/usertoken/method_usergetsharedaccesstoken.go @@ -0,0 +1,56 @@ +package usertoken + +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 UserGetSharedAccessTokenOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *UserTokenResult +} + +// UserGetSharedAccessToken ... +func (c UserTokenClient) UserGetSharedAccessToken(ctx context.Context, id UserId, input UserTokenParameters) (result UserGetSharedAccessTokenOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/token", 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/apimanagement/2021-08-01/usertoken/method_usergetsharedaccesstoken_autorest.go b/resource-manager/apimanagement/2021-08-01/usertoken/method_usergetsharedaccesstoken_autorest.go deleted file mode 100644 index 75e4e070eb0..00000000000 --- a/resource-manager/apimanagement/2021-08-01/usertoken/method_usergetsharedaccesstoken_autorest.go +++ /dev/null @@ -1,70 +0,0 @@ -package usertoken - -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 UserGetSharedAccessTokenOperationResponse struct { - HttpResponse *http.Response - Model *UserTokenResult -} - -// UserGetSharedAccessToken ... -func (c UserTokenClient) UserGetSharedAccessToken(ctx context.Context, id UserId, input UserTokenParameters) (result UserGetSharedAccessTokenOperationResponse, err error) { - req, err := c.preparerForUserGetSharedAccessToken(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "usertoken.UserTokenClient", "UserGetSharedAccessToken", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "usertoken.UserTokenClient", "UserGetSharedAccessToken", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForUserGetSharedAccessToken(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "usertoken.UserTokenClient", "UserGetSharedAccessToken", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForUserGetSharedAccessToken prepares the UserGetSharedAccessToken request. -func (c UserTokenClient) preparerForUserGetSharedAccessToken(ctx context.Context, id UserId, input UserTokenParameters) (*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/token", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForUserGetSharedAccessToken handles the response to the UserGetSharedAccessToken request. The method always -// closes the http.Response Body. -func (c UserTokenClient) responderForUserGetSharedAccessToken(resp *http.Response) (result UserGetSharedAccessTokenOperationResponse, 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/apimanagement/2022-08-01/api/client.go b/resource-manager/apimanagement/2022-08-01/api/client.go index 6d9c8390b45..577f71cde2a 100644 --- a/resource-manager/apimanagement/2022-08-01/api/client.go +++ b/resource-manager/apimanagement/2022-08-01/api/client.go @@ -1,18 +1,26 @@ package api -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 ApiClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewApiClientWithBaseURI(endpoint string) ApiClient { - return ApiClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewApiClientWithBaseURI(api environments.Api) (*ApiClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "api", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ApiClient: %+v", err) } + + return &ApiClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2022-08-01/api/constants.go b/resource-manager/apimanagement/2022-08-01/api/constants.go index 8448cef6b1a..534cfc958a1 100644 --- a/resource-manager/apimanagement/2022-08-01/api/constants.go +++ b/resource-manager/apimanagement/2022-08-01/api/constants.go @@ -1,6 +1,10 @@ package api -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 PossibleValuesForApiType() []string { } } +func (s *ApiType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseApiType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseApiType(input string) (*ApiType, error) { vals := map[string]ApiType{ "graphql": ApiTypeGraphql, @@ -53,6 +70,19 @@ func PossibleValuesForBearerTokenSendingMethods() []string { } } +func (s *BearerTokenSendingMethods) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseBearerTokenSendingMethods(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseBearerTokenSendingMethods(input string) (*BearerTokenSendingMethods, error) { vals := map[string]BearerTokenSendingMethods{ "authorizationheader": BearerTokenSendingMethodsAuthorizationHeader, @@ -99,6 +129,19 @@ func PossibleValuesForContentFormat() []string { } } +func (s *ContentFormat) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseContentFormat(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseContentFormat(input string) (*ContentFormat, error) { vals := map[string]ContentFormat{ "graphql-link": ContentFormatGraphqlNegativelink, @@ -140,6 +183,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{ "http": ProtocolHTTP, @@ -174,6 +230,19 @@ func PossibleValuesForSoapApiType() []string { } } +func (s *SoapApiType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSoapApiType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseSoapApiType(input string) (*SoapApiType, error) { vals := map[string]SoapApiType{ "graphql": SoapApiTypeGraphql, @@ -204,6 +273,19 @@ func PossibleValuesForTranslateRequiredQueryParametersConduct() []string { } } +func (s *TranslateRequiredQueryParametersConduct) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseTranslateRequiredQueryParametersConduct(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseTranslateRequiredQueryParametersConduct(input string) (*TranslateRequiredQueryParametersConduct, error) { vals := map[string]TranslateRequiredQueryParametersConduct{ "query": TranslateRequiredQueryParametersConductQuery, @@ -234,6 +316,19 @@ func PossibleValuesForVersioningScheme() []string { } } +func (s *VersioningScheme) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseVersioningScheme(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseVersioningScheme(input string) (*VersioningScheme, error) { vals := map[string]VersioningScheme{ "header": VersioningSchemeHeader, diff --git a/resource-manager/apimanagement/2022-08-01/api/method_createorupdate.go b/resource-manager/apimanagement/2022-08-01/api/method_createorupdate.go new file mode 100644 index 00000000000..6906b67a6ba --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/api/method_createorupdate.go @@ -0,0 +1,103 @@ +package api + +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 +} + +type CreateOrUpdateOperationOptions struct { + IfMatch *string +} + +func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { + return CreateOrUpdateOperationOptions{} +} + +func (o CreateOrUpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o CreateOrUpdateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o CreateOrUpdateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// CreateOrUpdate ... +func (c ApiClient) CreateOrUpdate(ctx context.Context, id ApiId, input ApiCreateOrUpdateParameter, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + OptionsObject: options, + } + + 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 ApiClient) CreateOrUpdateThenPoll(ctx context.Context, id ApiId, input ApiCreateOrUpdateParameter, options CreateOrUpdateOperationOptions) error { + result, err := c.CreateOrUpdate(ctx, id, input, options) + 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/apimanagement/2022-08-01/api/method_createorupdate_autorest.go b/resource-manager/apimanagement/2022-08-01/api/method_createorupdate_autorest.go deleted file mode 100644 index cf276d9f58f..00000000000 --- a/resource-manager/apimanagement/2022-08-01/api/method_createorupdate_autorest.go +++ /dev/null @@ -1,108 +0,0 @@ -package api - -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 -} - -type CreateOrUpdateOperationOptions struct { - IfMatch *string -} - -func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { - return CreateOrUpdateOperationOptions{} -} - -func (o CreateOrUpdateOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o CreateOrUpdateOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// CreateOrUpdate ... -func (c ApiClient) CreateOrUpdate(ctx context.Context, id ApiId, input ApiCreateOrUpdateParameter, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdate(ctx, id, input, options) - if err != nil { - err = autorest.NewErrorWithError(err, "api.ApiClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result, err = c.senderForCreateOrUpdate(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "api.ApiClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed -func (c ApiClient) CreateOrUpdateThenPoll(ctx context.Context, id ApiId, input ApiCreateOrUpdateParameter, options CreateOrUpdateOperationOptions) error { - result, err := c.CreateOrUpdate(ctx, id, input, options) - 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 ApiClient) preparerForCreateOrUpdate(ctx context.Context, id ApiId, input ApiCreateOrUpdateParameter, options CreateOrUpdateOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - 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 ApiClient) 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/apimanagement/2022-08-01/api/method_delete.go b/resource-manager/apimanagement/2022-08-01/api/method_delete.go new file mode 100644 index 00000000000..19f24f35d16 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/api/method_delete.go @@ -0,0 +1,79 @@ +package api + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +type DeleteOperationOptions struct { + DeleteRevisions *bool + IfMatch *string +} + +func DefaultDeleteOperationOptions() DeleteOperationOptions { + return DeleteOperationOptions{} +} + +func (o DeleteOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o DeleteOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o DeleteOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.DeleteRevisions != nil { + out.Append("deleteRevisions", fmt.Sprintf("%v", *o.DeleteRevisions)) + } + return &out +} + +// Delete ... +func (c ApiClient) Delete(ctx context.Context, id ApiId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2022-08-01/api/method_delete_autorest.go b/resource-manager/apimanagement/2022-08-01/api/method_delete_autorest.go deleted file mode 100644 index 0971572259e..00000000000 --- a/resource-manager/apimanagement/2022-08-01/api/method_delete_autorest.go +++ /dev/null @@ -1,100 +0,0 @@ -package api - -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 DeleteOperationResponse struct { - HttpResponse *http.Response -} - -type DeleteOperationOptions struct { - DeleteRevisions *bool - IfMatch *string -} - -func DefaultDeleteOperationOptions() DeleteOperationOptions { - return DeleteOperationOptions{} -} - -func (o DeleteOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o DeleteOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.DeleteRevisions != nil { - out["deleteRevisions"] = *o.DeleteRevisions - } - - return out -} - -// Delete ... -func (c ApiClient) Delete(ctx context.Context, id ApiId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { - req, err := c.preparerForDelete(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "api.ApiClient", "Delete", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "api.ApiClient", "Delete", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForDelete(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "api.ApiClient", "Delete", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForDelete prepares the Delete request. -func (c ApiClient) preparerForDelete(ctx context.Context, id ApiId, options DeleteOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForDelete handles the response to the Delete request. The method always -// closes the http.Response Body. -func (c ApiClient) responderForDelete(resp *http.Response) (result DeleteOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2022-08-01/api/method_get.go b/resource-manager/apimanagement/2022-08-01/api/method_get.go new file mode 100644 index 00000000000..f750fb8e0ec --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/api/method_get.go @@ -0,0 +1,51 @@ +package api + +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 *ApiContract +} + +// Get ... +func (c ApiClient) Get(ctx context.Context, id ApiId) (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/apimanagement/2022-08-01/api/method_get_autorest.go b/resource-manager/apimanagement/2022-08-01/api/method_get_autorest.go deleted file mode 100644 index cd4943ce66a..00000000000 --- a/resource-manager/apimanagement/2022-08-01/api/method_get_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package api - -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 *ApiContract -} - -// Get ... -func (c ApiClient) Get(ctx context.Context, id ApiId) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "api.ApiClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "api.ApiClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "api.ApiClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c ApiClient) preparerForGet(ctx context.Context, id ApiId) (*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 ApiClient) 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/apimanagement/2022-08-01/api/method_getentitytag.go b/resource-manager/apimanagement/2022-08-01/api/method_getentitytag.go new file mode 100644 index 00000000000..5d65ab7fc88 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/api/method_getentitytag.go @@ -0,0 +1,46 @@ +package api + +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 GetEntityTagOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// GetEntityTag ... +func (c ApiClient) GetEntityTag(ctx context.Context, id ApiId) (result GetEntityTagOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodHead, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2022-08-01/api/method_getentitytag_autorest.go b/resource-manager/apimanagement/2022-08-01/api/method_getentitytag_autorest.go deleted file mode 100644 index 326d2bb9cdf..00000000000 --- a/resource-manager/apimanagement/2022-08-01/api/method_getentitytag_autorest.go +++ /dev/null @@ -1,66 +0,0 @@ -package api - -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 GetEntityTagOperationResponse struct { - HttpResponse *http.Response -} - -// GetEntityTag ... -func (c ApiClient) GetEntityTag(ctx context.Context, id ApiId) (result GetEntityTagOperationResponse, err error) { - req, err := c.preparerForGetEntityTag(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "api.ApiClient", "GetEntityTag", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "api.ApiClient", "GetEntityTag", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetEntityTag(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "api.ApiClient", "GetEntityTag", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetEntityTag prepares the GetEntityTag request. -func (c ApiClient) preparerForGetEntityTag(ctx context.Context, id ApiId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsHead(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetEntityTag handles the response to the GetEntityTag request. The method always -// closes the http.Response Body. -func (c ApiClient) responderForGetEntityTag(resp *http.Response) (result GetEntityTagOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2022-08-01/api/method_listbyservice.go b/resource-manager/apimanagement/2022-08-01/api/method_listbyservice.go new file mode 100644 index 00000000000..2b6a6ad37f7 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/api/method_listbyservice.go @@ -0,0 +1,133 @@ +package api + +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 ListByServiceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ApiContract +} + +type ListByServiceCompleteResult struct { + Items []ApiContract +} + +type ListByServiceOperationOptions struct { + ExpandApiVersionSet *bool + Filter *string + Skip *int64 + Tags *string + Top *int64 +} + +func DefaultListByServiceOperationOptions() ListByServiceOperationOptions { + return ListByServiceOperationOptions{} +} + +func (o ListByServiceOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListByServiceOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListByServiceOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.ExpandApiVersionSet != nil { + out.Append("expandApiVersionSet", fmt.Sprintf("%v", *o.ExpandApiVersionSet)) + } + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.Skip != nil { + out.Append("$skip", fmt.Sprintf("%v", *o.Skip)) + } + if o.Tags != nil { + out.Append("tags", fmt.Sprintf("%v", *o.Tags)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +// ListByService ... +func (c ApiClient) ListByService(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (result ListByServiceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/apis", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ApiContract `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByServiceComplete retrieves all the results into a single object +func (c ApiClient) ListByServiceComplete(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (ListByServiceCompleteResult, error) { + return c.ListByServiceCompleteMatchingPredicate(ctx, id, options, ApiContractOperationPredicate{}) +} + +// ListByServiceCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ApiClient) ListByServiceCompleteMatchingPredicate(ctx context.Context, id ServiceId, options ListByServiceOperationOptions, predicate ApiContractOperationPredicate) (result ListByServiceCompleteResult, err error) { + items := make([]ApiContract, 0) + + resp, err := c.ListByService(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByServiceCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/apimanagement/2022-08-01/api/method_listbyservice_autorest.go b/resource-manager/apimanagement/2022-08-01/api/method_listbyservice_autorest.go deleted file mode 100644 index 114e7e5afe3..00000000000 --- a/resource-manager/apimanagement/2022-08-01/api/method_listbyservice_autorest.go +++ /dev/null @@ -1,235 +0,0 @@ -package api - -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 ListByServiceOperationResponse struct { - HttpResponse *http.Response - Model *[]ApiContract - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListByServiceOperationResponse, error) -} - -type ListByServiceCompleteResult struct { - Items []ApiContract -} - -func (r ListByServiceOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListByServiceOperationResponse) LoadMore(ctx context.Context) (resp ListByServiceOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -type ListByServiceOperationOptions struct { - ExpandApiVersionSet *bool - Filter *string - Skip *int64 - Tags *string - Top *int64 -} - -func DefaultListByServiceOperationOptions() ListByServiceOperationOptions { - return ListByServiceOperationOptions{} -} - -func (o ListByServiceOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o ListByServiceOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.ExpandApiVersionSet != nil { - out["expandApiVersionSet"] = *o.ExpandApiVersionSet - } - - if o.Filter != nil { - out["$filter"] = *o.Filter - } - - if o.Skip != nil { - out["$skip"] = *o.Skip - } - - if o.Tags != nil { - out["tags"] = *o.Tags - } - - if o.Top != nil { - out["$top"] = *o.Top - } - - return out -} - -// ListByService ... -func (c ApiClient) ListByService(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (resp ListByServiceOperationResponse, err error) { - req, err := c.preparerForListByService(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "api.ApiClient", "ListByService", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "api.ApiClient", "ListByService", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListByService(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "api.ApiClient", "ListByService", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListByService prepares the ListByService request. -func (c ApiClient) preparerForListByService(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/apis", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListByServiceWithNextLink prepares the ListByService request with the given nextLink token. -func (c ApiClient) preparerForListByServiceWithNextLink(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)) -} - -// responderForListByService handles the response to the ListByService request. The method always -// closes the http.Response Body. -func (c ApiClient) responderForListByService(resp *http.Response) (result ListByServiceOperationResponse, err error) { - type page struct { - Values []ApiContract `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 ListByServiceOperationResponse, err error) { - req, err := c.preparerForListByServiceWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "api.ApiClient", "ListByService", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "api.ApiClient", "ListByService", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByService(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "api.ApiClient", "ListByService", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListByServiceComplete retrieves all of the results into a single object -func (c ApiClient) ListByServiceComplete(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (ListByServiceCompleteResult, error) { - return c.ListByServiceCompleteMatchingPredicate(ctx, id, options, ApiContractOperationPredicate{}) -} - -// ListByServiceCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c ApiClient) ListByServiceCompleteMatchingPredicate(ctx context.Context, id ServiceId, options ListByServiceOperationOptions, predicate ApiContractOperationPredicate) (resp ListByServiceCompleteResult, err error) { - items := make([]ApiContract, 0) - - page, err := c.ListByService(ctx, id, options) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListByServiceCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/apimanagement/2022-08-01/api/method_update.go b/resource-manager/apimanagement/2022-08-01/api/method_update.go new file mode 100644 index 00000000000..8b2e6fa4357 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/api/method_update.go @@ -0,0 +1,84 @@ +package api + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ApiContract +} + +type UpdateOperationOptions struct { + IfMatch *string +} + +func DefaultUpdateOperationOptions() UpdateOperationOptions { + return UpdateOperationOptions{} +} + +func (o UpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o UpdateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o UpdateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// Update ... +func (c ApiClient) Update(ctx context.Context, id ApiId, input ApiUpdateContract, options UpdateOperationOptions) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + OptionsObject: options, + } + + 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/apimanagement/2022-08-01/api/method_update_autorest.go b/resource-manager/apimanagement/2022-08-01/api/method_update_autorest.go deleted file mode 100644 index b998809dc0e..00000000000 --- a/resource-manager/apimanagement/2022-08-01/api/method_update_autorest.go +++ /dev/null @@ -1,98 +0,0 @@ -package api - -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 *ApiContract -} - -type UpdateOperationOptions struct { - IfMatch *string -} - -func DefaultUpdateOperationOptions() UpdateOperationOptions { - return UpdateOperationOptions{} -} - -func (o UpdateOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o UpdateOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// Update ... -func (c ApiClient) Update(ctx context.Context, id ApiId, input ApiUpdateContract, options UpdateOperationOptions) (result UpdateOperationResponse, err error) { - req, err := c.preparerForUpdate(ctx, id, input, options) - if err != nil { - err = autorest.NewErrorWithError(err, "api.ApiClient", "Update", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "api.ApiClient", "Update", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "api.ApiClient", "Update", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForUpdate prepares the Update request. -func (c ApiClient) preparerForUpdate(ctx context.Context, id ApiId, input ApiUpdateContract, options UpdateOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPatch(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - 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 ApiClient) 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/apimanagement/2022-08-01/apidiagnostic/client.go b/resource-manager/apimanagement/2022-08-01/apidiagnostic/client.go index 99e83188cc6..beec386c59e 100644 --- a/resource-manager/apimanagement/2022-08-01/apidiagnostic/client.go +++ b/resource-manager/apimanagement/2022-08-01/apidiagnostic/client.go @@ -1,18 +1,26 @@ package apidiagnostic -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 ApiDiagnosticClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewApiDiagnosticClientWithBaseURI(endpoint string) ApiDiagnosticClient { - return ApiDiagnosticClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewApiDiagnosticClientWithBaseURI(api environments.Api) (*ApiDiagnosticClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "apidiagnostic", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ApiDiagnosticClient: %+v", err) } + + return &ApiDiagnosticClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2022-08-01/apidiagnostic/constants.go b/resource-manager/apimanagement/2022-08-01/apidiagnostic/constants.go index 4d80cb551c7..1afde676ffa 100644 --- a/resource-manager/apimanagement/2022-08-01/apidiagnostic/constants.go +++ b/resource-manager/apimanagement/2022-08-01/apidiagnostic/constants.go @@ -1,6 +1,10 @@ package apidiagnostic -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 PossibleValuesForAlwaysLog() []string { } } +func (s *AlwaysLog) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAlwaysLog(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseAlwaysLog(input string) (*AlwaysLog, error) { vals := map[string]AlwaysLog{ "allerrors": AlwaysLogAllErrors, @@ -44,6 +61,19 @@ func PossibleValuesForDataMaskingMode() []string { } } +func (s *DataMaskingMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDataMaskingMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseDataMaskingMode(input string) (*DataMaskingMode, error) { vals := map[string]DataMaskingMode{ "hide": DataMaskingModeHide, @@ -74,6 +104,19 @@ func PossibleValuesForHTTPCorrelationProtocol() []string { } } +func (s *HTTPCorrelationProtocol) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseHTTPCorrelationProtocol(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseHTTPCorrelationProtocol(input string) (*HTTPCorrelationProtocol, error) { vals := map[string]HTTPCorrelationProtocol{ "legacy": HTTPCorrelationProtocolLegacy, @@ -103,6 +146,19 @@ func PossibleValuesForOperationNameFormat() []string { } } +func (s *OperationNameFormat) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseOperationNameFormat(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseOperationNameFormat(input string) (*OperationNameFormat, error) { vals := map[string]OperationNameFormat{ "name": OperationNameFormatName, @@ -129,6 +185,19 @@ func PossibleValuesForSamplingType() []string { } } +func (s *SamplingType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSamplingType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseSamplingType(input string) (*SamplingType, error) { vals := map[string]SamplingType{ "fixed": SamplingTypeFixed, @@ -158,6 +227,19 @@ func PossibleValuesForVerbosity() []string { } } +func (s *Verbosity) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseVerbosity(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseVerbosity(input string) (*Verbosity, error) { vals := map[string]Verbosity{ "error": VerbosityError, diff --git a/resource-manager/apimanagement/2022-08-01/apidiagnostic/method_createorupdate.go b/resource-manager/apimanagement/2022-08-01/apidiagnostic/method_createorupdate.go new file mode 100644 index 00000000000..d50634ca8da --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/apidiagnostic/method_createorupdate.go @@ -0,0 +1,85 @@ +package apidiagnostic + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DiagnosticContract +} + +type CreateOrUpdateOperationOptions struct { + IfMatch *string +} + +func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { + return CreateOrUpdateOperationOptions{} +} + +func (o CreateOrUpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o CreateOrUpdateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o CreateOrUpdateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// CreateOrUpdate ... +func (c ApiDiagnosticClient) CreateOrUpdate(ctx context.Context, id ApiDiagnosticId, input DiagnosticContract, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + OptionsObject: options, + } + + 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/apimanagement/2022-08-01/apidiagnostic/method_createorupdate_autorest.go b/resource-manager/apimanagement/2022-08-01/apidiagnostic/method_createorupdate_autorest.go deleted file mode 100644 index 510d94a82ae..00000000000 --- a/resource-manager/apimanagement/2022-08-01/apidiagnostic/method_createorupdate_autorest.go +++ /dev/null @@ -1,98 +0,0 @@ -package apidiagnostic - -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 *DiagnosticContract -} - -type CreateOrUpdateOperationOptions struct { - IfMatch *string -} - -func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { - return CreateOrUpdateOperationOptions{} -} - -func (o CreateOrUpdateOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o CreateOrUpdateOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// CreateOrUpdate ... -func (c ApiDiagnosticClient) CreateOrUpdate(ctx context.Context, id ApiDiagnosticId, input DiagnosticContract, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdate(ctx, id, input, options) - if err != nil { - err = autorest.NewErrorWithError(err, "apidiagnostic.ApiDiagnosticClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apidiagnostic.ApiDiagnosticClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCreateOrUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apidiagnostic.ApiDiagnosticClient", "CreateOrUpdate", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCreateOrUpdate prepares the CreateOrUpdate request. -func (c ApiDiagnosticClient) preparerForCreateOrUpdate(ctx context.Context, id ApiDiagnosticId, input DiagnosticContract, options CreateOrUpdateOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - 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 ApiDiagnosticClient) responderForCreateOrUpdate(resp *http.Response) (result CreateOrUpdateOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2022-08-01/apidiagnostic/method_delete.go b/resource-manager/apimanagement/2022-08-01/apidiagnostic/method_delete.go new file mode 100644 index 00000000000..0fb3223f00f --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/apidiagnostic/method_delete.go @@ -0,0 +1,76 @@ +package apidiagnostic + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +type DeleteOperationOptions struct { + IfMatch *string +} + +func DefaultDeleteOperationOptions() DeleteOperationOptions { + return DeleteOperationOptions{} +} + +func (o DeleteOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o DeleteOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o DeleteOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// Delete ... +func (c ApiDiagnosticClient) Delete(ctx context.Context, id ApiDiagnosticId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2022-08-01/apidiagnostic/method_delete_autorest.go b/resource-manager/apimanagement/2022-08-01/apidiagnostic/method_delete_autorest.go deleted file mode 100644 index f9098fe95dd..00000000000 --- a/resource-manager/apimanagement/2022-08-01/apidiagnostic/method_delete_autorest.go +++ /dev/null @@ -1,95 +0,0 @@ -package apidiagnostic - -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 DeleteOperationResponse struct { - HttpResponse *http.Response -} - -type DeleteOperationOptions struct { - IfMatch *string -} - -func DefaultDeleteOperationOptions() DeleteOperationOptions { - return DeleteOperationOptions{} -} - -func (o DeleteOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o DeleteOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// Delete ... -func (c ApiDiagnosticClient) Delete(ctx context.Context, id ApiDiagnosticId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { - req, err := c.preparerForDelete(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "apidiagnostic.ApiDiagnosticClient", "Delete", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apidiagnostic.ApiDiagnosticClient", "Delete", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForDelete(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apidiagnostic.ApiDiagnosticClient", "Delete", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForDelete prepares the Delete request. -func (c ApiDiagnosticClient) preparerForDelete(ctx context.Context, id ApiDiagnosticId, options DeleteOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForDelete handles the response to the Delete request. The method always -// closes the http.Response Body. -func (c ApiDiagnosticClient) responderForDelete(resp *http.Response) (result DeleteOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2022-08-01/apidiagnostic/method_get.go b/resource-manager/apimanagement/2022-08-01/apidiagnostic/method_get.go new file mode 100644 index 00000000000..26dffc0cd3e --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/apidiagnostic/method_get.go @@ -0,0 +1,51 @@ +package apidiagnostic + +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 *DiagnosticContract +} + +// Get ... +func (c ApiDiagnosticClient) Get(ctx context.Context, id ApiDiagnosticId) (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/apimanagement/2022-08-01/apidiagnostic/method_get_autorest.go b/resource-manager/apimanagement/2022-08-01/apidiagnostic/method_get_autorest.go deleted file mode 100644 index 5468c122ef0..00000000000 --- a/resource-manager/apimanagement/2022-08-01/apidiagnostic/method_get_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package apidiagnostic - -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 *DiagnosticContract -} - -// Get ... -func (c ApiDiagnosticClient) Get(ctx context.Context, id ApiDiagnosticId) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "apidiagnostic.ApiDiagnosticClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apidiagnostic.ApiDiagnosticClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apidiagnostic.ApiDiagnosticClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c ApiDiagnosticClient) preparerForGet(ctx context.Context, id ApiDiagnosticId) (*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 ApiDiagnosticClient) 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/apimanagement/2022-08-01/apidiagnostic/method_getentitytag.go b/resource-manager/apimanagement/2022-08-01/apidiagnostic/method_getentitytag.go new file mode 100644 index 00000000000..312e0f37414 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/apidiagnostic/method_getentitytag.go @@ -0,0 +1,46 @@ +package apidiagnostic + +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 GetEntityTagOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// GetEntityTag ... +func (c ApiDiagnosticClient) GetEntityTag(ctx context.Context, id ApiDiagnosticId) (result GetEntityTagOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodHead, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2022-08-01/apidiagnostic/method_getentitytag_autorest.go b/resource-manager/apimanagement/2022-08-01/apidiagnostic/method_getentitytag_autorest.go deleted file mode 100644 index 4ad28bdb6d5..00000000000 --- a/resource-manager/apimanagement/2022-08-01/apidiagnostic/method_getentitytag_autorest.go +++ /dev/null @@ -1,66 +0,0 @@ -package apidiagnostic - -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 GetEntityTagOperationResponse struct { - HttpResponse *http.Response -} - -// GetEntityTag ... -func (c ApiDiagnosticClient) GetEntityTag(ctx context.Context, id ApiDiagnosticId) (result GetEntityTagOperationResponse, err error) { - req, err := c.preparerForGetEntityTag(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "apidiagnostic.ApiDiagnosticClient", "GetEntityTag", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apidiagnostic.ApiDiagnosticClient", "GetEntityTag", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetEntityTag(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apidiagnostic.ApiDiagnosticClient", "GetEntityTag", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetEntityTag prepares the GetEntityTag request. -func (c ApiDiagnosticClient) preparerForGetEntityTag(ctx context.Context, id ApiDiagnosticId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsHead(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetEntityTag handles the response to the GetEntityTag request. The method always -// closes the http.Response Body. -func (c ApiDiagnosticClient) responderForGetEntityTag(resp *http.Response) (result GetEntityTagOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2022-08-01/apidiagnostic/method_listbyservice.go b/resource-manager/apimanagement/2022-08-01/apidiagnostic/method_listbyservice.go new file mode 100644 index 00000000000..125ebd65d5f --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/apidiagnostic/method_listbyservice.go @@ -0,0 +1,125 @@ +package apidiagnostic + +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 ListByServiceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]DiagnosticContract +} + +type ListByServiceCompleteResult struct { + Items []DiagnosticContract +} + +type ListByServiceOperationOptions struct { + Filter *string + Skip *int64 + Top *int64 +} + +func DefaultListByServiceOperationOptions() ListByServiceOperationOptions { + return ListByServiceOperationOptions{} +} + +func (o ListByServiceOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListByServiceOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListByServiceOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.Skip != nil { + out.Append("$skip", fmt.Sprintf("%v", *o.Skip)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +// ListByService ... +func (c ApiDiagnosticClient) ListByService(ctx context.Context, id ApiId, options ListByServiceOperationOptions) (result ListByServiceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/diagnostics", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]DiagnosticContract `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByServiceComplete retrieves all the results into a single object +func (c ApiDiagnosticClient) ListByServiceComplete(ctx context.Context, id ApiId, options ListByServiceOperationOptions) (ListByServiceCompleteResult, error) { + return c.ListByServiceCompleteMatchingPredicate(ctx, id, options, DiagnosticContractOperationPredicate{}) +} + +// ListByServiceCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ApiDiagnosticClient) ListByServiceCompleteMatchingPredicate(ctx context.Context, id ApiId, options ListByServiceOperationOptions, predicate DiagnosticContractOperationPredicate) (result ListByServiceCompleteResult, err error) { + items := make([]DiagnosticContract, 0) + + resp, err := c.ListByService(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByServiceCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/apimanagement/2022-08-01/apidiagnostic/method_listbyservice_autorest.go b/resource-manager/apimanagement/2022-08-01/apidiagnostic/method_listbyservice_autorest.go deleted file mode 100644 index c58834cf8bf..00000000000 --- a/resource-manager/apimanagement/2022-08-01/apidiagnostic/method_listbyservice_autorest.go +++ /dev/null @@ -1,225 +0,0 @@ -package apidiagnostic - -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 ListByServiceOperationResponse struct { - HttpResponse *http.Response - Model *[]DiagnosticContract - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListByServiceOperationResponse, error) -} - -type ListByServiceCompleteResult struct { - Items []DiagnosticContract -} - -func (r ListByServiceOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListByServiceOperationResponse) LoadMore(ctx context.Context) (resp ListByServiceOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -type ListByServiceOperationOptions struct { - Filter *string - Skip *int64 - Top *int64 -} - -func DefaultListByServiceOperationOptions() ListByServiceOperationOptions { - return ListByServiceOperationOptions{} -} - -func (o ListByServiceOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o ListByServiceOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Filter != nil { - out["$filter"] = *o.Filter - } - - if o.Skip != nil { - out["$skip"] = *o.Skip - } - - if o.Top != nil { - out["$top"] = *o.Top - } - - return out -} - -// ListByService ... -func (c ApiDiagnosticClient) ListByService(ctx context.Context, id ApiId, options ListByServiceOperationOptions) (resp ListByServiceOperationResponse, err error) { - req, err := c.preparerForListByService(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "apidiagnostic.ApiDiagnosticClient", "ListByService", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apidiagnostic.ApiDiagnosticClient", "ListByService", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListByService(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apidiagnostic.ApiDiagnosticClient", "ListByService", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListByService prepares the ListByService request. -func (c ApiDiagnosticClient) preparerForListByService(ctx context.Context, id ApiId, options ListByServiceOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/diagnostics", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListByServiceWithNextLink prepares the ListByService request with the given nextLink token. -func (c ApiDiagnosticClient) preparerForListByServiceWithNextLink(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)) -} - -// responderForListByService handles the response to the ListByService request. The method always -// closes the http.Response Body. -func (c ApiDiagnosticClient) responderForListByService(resp *http.Response) (result ListByServiceOperationResponse, err error) { - type page struct { - Values []DiagnosticContract `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 ListByServiceOperationResponse, err error) { - req, err := c.preparerForListByServiceWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "apidiagnostic.ApiDiagnosticClient", "ListByService", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apidiagnostic.ApiDiagnosticClient", "ListByService", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByService(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apidiagnostic.ApiDiagnosticClient", "ListByService", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListByServiceComplete retrieves all of the results into a single object -func (c ApiDiagnosticClient) ListByServiceComplete(ctx context.Context, id ApiId, options ListByServiceOperationOptions) (ListByServiceCompleteResult, error) { - return c.ListByServiceCompleteMatchingPredicate(ctx, id, options, DiagnosticContractOperationPredicate{}) -} - -// ListByServiceCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c ApiDiagnosticClient) ListByServiceCompleteMatchingPredicate(ctx context.Context, id ApiId, options ListByServiceOperationOptions, predicate DiagnosticContractOperationPredicate) (resp ListByServiceCompleteResult, err error) { - items := make([]DiagnosticContract, 0) - - page, err := c.ListByService(ctx, id, options) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListByServiceCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/apimanagement/2022-08-01/apidiagnostic/method_update.go b/resource-manager/apimanagement/2022-08-01/apidiagnostic/method_update.go new file mode 100644 index 00000000000..b5341b3da3e --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/apidiagnostic/method_update.go @@ -0,0 +1,84 @@ +package apidiagnostic + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DiagnosticContract +} + +type UpdateOperationOptions struct { + IfMatch *string +} + +func DefaultUpdateOperationOptions() UpdateOperationOptions { + return UpdateOperationOptions{} +} + +func (o UpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o UpdateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o UpdateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// Update ... +func (c ApiDiagnosticClient) Update(ctx context.Context, id ApiDiagnosticId, input DiagnosticContract, options UpdateOperationOptions) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + OptionsObject: options, + } + + 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/apimanagement/2022-08-01/apidiagnostic/method_update_autorest.go b/resource-manager/apimanagement/2022-08-01/apidiagnostic/method_update_autorest.go deleted file mode 100644 index fa90a3f37f8..00000000000 --- a/resource-manager/apimanagement/2022-08-01/apidiagnostic/method_update_autorest.go +++ /dev/null @@ -1,98 +0,0 @@ -package apidiagnostic - -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 *DiagnosticContract -} - -type UpdateOperationOptions struct { - IfMatch *string -} - -func DefaultUpdateOperationOptions() UpdateOperationOptions { - return UpdateOperationOptions{} -} - -func (o UpdateOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o UpdateOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// Update ... -func (c ApiDiagnosticClient) Update(ctx context.Context, id ApiDiagnosticId, input DiagnosticContract, options UpdateOperationOptions) (result UpdateOperationResponse, err error) { - req, err := c.preparerForUpdate(ctx, id, input, options) - if err != nil { - err = autorest.NewErrorWithError(err, "apidiagnostic.ApiDiagnosticClient", "Update", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apidiagnostic.ApiDiagnosticClient", "Update", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apidiagnostic.ApiDiagnosticClient", "Update", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForUpdate prepares the Update request. -func (c ApiDiagnosticClient) preparerForUpdate(ctx context.Context, id ApiDiagnosticId, input DiagnosticContract, options UpdateOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPatch(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - 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 ApiDiagnosticClient) 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/apimanagement/2022-08-01/apiissue/client.go b/resource-manager/apimanagement/2022-08-01/apiissue/client.go index f63c05725de..7402b8d4ab0 100644 --- a/resource-manager/apimanagement/2022-08-01/apiissue/client.go +++ b/resource-manager/apimanagement/2022-08-01/apiissue/client.go @@ -1,18 +1,26 @@ package apiissue -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 ApiIssueClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewApiIssueClientWithBaseURI(endpoint string) ApiIssueClient { - return ApiIssueClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewApiIssueClientWithBaseURI(api environments.Api) (*ApiIssueClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "apiissue", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ApiIssueClient: %+v", err) } + + return &ApiIssueClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2022-08-01/apiissue/constants.go b/resource-manager/apimanagement/2022-08-01/apiissue/constants.go index 63548405b43..16888d5e064 100644 --- a/resource-manager/apimanagement/2022-08-01/apiissue/constants.go +++ b/resource-manager/apimanagement/2022-08-01/apiissue/constants.go @@ -1,6 +1,10 @@ package apiissue -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. @@ -25,6 +29,19 @@ func PossibleValuesForState() []string { } } +func (s *State) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseState(input string) (*State, error) { vals := map[string]State{ "closed": StateClosed, diff --git a/resource-manager/apimanagement/2022-08-01/apiissue/method_createorupdate.go b/resource-manager/apimanagement/2022-08-01/apiissue/method_createorupdate.go new file mode 100644 index 00000000000..10a6a5bca91 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/apiissue/method_createorupdate.go @@ -0,0 +1,85 @@ +package apiissue + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *IssueContract +} + +type CreateOrUpdateOperationOptions struct { + IfMatch *string +} + +func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { + return CreateOrUpdateOperationOptions{} +} + +func (o CreateOrUpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o CreateOrUpdateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o CreateOrUpdateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// CreateOrUpdate ... +func (c ApiIssueClient) CreateOrUpdate(ctx context.Context, id ApiIssueId, input IssueContract, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + OptionsObject: options, + } + + 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/apimanagement/2022-08-01/apiissue/method_createorupdate_autorest.go b/resource-manager/apimanagement/2022-08-01/apiissue/method_createorupdate_autorest.go deleted file mode 100644 index 74810fa4260..00000000000 --- a/resource-manager/apimanagement/2022-08-01/apiissue/method_createorupdate_autorest.go +++ /dev/null @@ -1,98 +0,0 @@ -package apiissue - -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 *IssueContract -} - -type CreateOrUpdateOperationOptions struct { - IfMatch *string -} - -func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { - return CreateOrUpdateOperationOptions{} -} - -func (o CreateOrUpdateOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o CreateOrUpdateOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// CreateOrUpdate ... -func (c ApiIssueClient) CreateOrUpdate(ctx context.Context, id ApiIssueId, input IssueContract, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdate(ctx, id, input, options) - if err != nil { - err = autorest.NewErrorWithError(err, "apiissue.ApiIssueClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apiissue.ApiIssueClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCreateOrUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apiissue.ApiIssueClient", "CreateOrUpdate", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCreateOrUpdate prepares the CreateOrUpdate request. -func (c ApiIssueClient) preparerForCreateOrUpdate(ctx context.Context, id ApiIssueId, input IssueContract, options CreateOrUpdateOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - 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 ApiIssueClient) responderForCreateOrUpdate(resp *http.Response) (result CreateOrUpdateOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2022-08-01/apiissue/method_delete.go b/resource-manager/apimanagement/2022-08-01/apiissue/method_delete.go new file mode 100644 index 00000000000..822eaefefe3 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/apiissue/method_delete.go @@ -0,0 +1,76 @@ +package apiissue + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +type DeleteOperationOptions struct { + IfMatch *string +} + +func DefaultDeleteOperationOptions() DeleteOperationOptions { + return DeleteOperationOptions{} +} + +func (o DeleteOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o DeleteOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o DeleteOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// Delete ... +func (c ApiIssueClient) Delete(ctx context.Context, id ApiIssueId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2022-08-01/apiissue/method_delete_autorest.go b/resource-manager/apimanagement/2022-08-01/apiissue/method_delete_autorest.go deleted file mode 100644 index 77956335e4c..00000000000 --- a/resource-manager/apimanagement/2022-08-01/apiissue/method_delete_autorest.go +++ /dev/null @@ -1,95 +0,0 @@ -package apiissue - -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 DeleteOperationResponse struct { - HttpResponse *http.Response -} - -type DeleteOperationOptions struct { - IfMatch *string -} - -func DefaultDeleteOperationOptions() DeleteOperationOptions { - return DeleteOperationOptions{} -} - -func (o DeleteOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o DeleteOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// Delete ... -func (c ApiIssueClient) Delete(ctx context.Context, id ApiIssueId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { - req, err := c.preparerForDelete(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "apiissue.ApiIssueClient", "Delete", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apiissue.ApiIssueClient", "Delete", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForDelete(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apiissue.ApiIssueClient", "Delete", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForDelete prepares the Delete request. -func (c ApiIssueClient) preparerForDelete(ctx context.Context, id ApiIssueId, options DeleteOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForDelete handles the response to the Delete request. The method always -// closes the http.Response Body. -func (c ApiIssueClient) responderForDelete(resp *http.Response) (result DeleteOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2022-08-01/apiissue/method_get.go b/resource-manager/apimanagement/2022-08-01/apiissue/method_get.go new file mode 100644 index 00000000000..437b0420930 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/apiissue/method_get.go @@ -0,0 +1,80 @@ +package apiissue + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *IssueContract +} + +type GetOperationOptions struct { + ExpandCommentsAttachments *bool +} + +func DefaultGetOperationOptions() GetOperationOptions { + return GetOperationOptions{} +} + +func (o GetOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o GetOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o GetOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.ExpandCommentsAttachments != nil { + out.Append("expandCommentsAttachments", fmt.Sprintf("%v", *o.ExpandCommentsAttachments)) + } + return &out +} + +// Get ... +func (c ApiIssueClient) Get(ctx context.Context, id ApiIssueId, options GetOperationOptions) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + OptionsObject: options, + } + + 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/apimanagement/2022-08-01/apiissue/method_get_autorest.go b/resource-manager/apimanagement/2022-08-01/apiissue/method_get_autorest.go deleted file mode 100644 index 0821e733063..00000000000 --- a/resource-manager/apimanagement/2022-08-01/apiissue/method_get_autorest.go +++ /dev/null @@ -1,97 +0,0 @@ -package apiissue - -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 *IssueContract -} - -type GetOperationOptions struct { - ExpandCommentsAttachments *bool -} - -func DefaultGetOperationOptions() GetOperationOptions { - return GetOperationOptions{} -} - -func (o GetOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o GetOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.ExpandCommentsAttachments != nil { - out["expandCommentsAttachments"] = *o.ExpandCommentsAttachments - } - - return out -} - -// Get ... -func (c ApiIssueClient) Get(ctx context.Context, id ApiIssueId, options GetOperationOptions) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "apiissue.ApiIssueClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apiissue.ApiIssueClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apiissue.ApiIssueClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c ApiIssueClient) preparerForGet(ctx context.Context, id ApiIssueId, options GetOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(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 ApiIssueClient) 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/apimanagement/2022-08-01/apiissue/method_getentitytag.go b/resource-manager/apimanagement/2022-08-01/apiissue/method_getentitytag.go new file mode 100644 index 00000000000..fa22e539b24 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/apiissue/method_getentitytag.go @@ -0,0 +1,46 @@ +package apiissue + +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 GetEntityTagOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// GetEntityTag ... +func (c ApiIssueClient) GetEntityTag(ctx context.Context, id ApiIssueId) (result GetEntityTagOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodHead, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2022-08-01/apiissue/method_getentitytag_autorest.go b/resource-manager/apimanagement/2022-08-01/apiissue/method_getentitytag_autorest.go deleted file mode 100644 index 589dff977e0..00000000000 --- a/resource-manager/apimanagement/2022-08-01/apiissue/method_getentitytag_autorest.go +++ /dev/null @@ -1,66 +0,0 @@ -package apiissue - -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 GetEntityTagOperationResponse struct { - HttpResponse *http.Response -} - -// GetEntityTag ... -func (c ApiIssueClient) GetEntityTag(ctx context.Context, id ApiIssueId) (result GetEntityTagOperationResponse, err error) { - req, err := c.preparerForGetEntityTag(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "apiissue.ApiIssueClient", "GetEntityTag", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apiissue.ApiIssueClient", "GetEntityTag", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetEntityTag(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apiissue.ApiIssueClient", "GetEntityTag", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetEntityTag prepares the GetEntityTag request. -func (c ApiIssueClient) preparerForGetEntityTag(ctx context.Context, id ApiIssueId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsHead(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetEntityTag handles the response to the GetEntityTag request. The method always -// closes the http.Response Body. -func (c ApiIssueClient) responderForGetEntityTag(resp *http.Response) (result GetEntityTagOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2022-08-01/apiissue/method_listbyservice.go b/resource-manager/apimanagement/2022-08-01/apiissue/method_listbyservice.go new file mode 100644 index 00000000000..faa0de569c6 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/apiissue/method_listbyservice.go @@ -0,0 +1,129 @@ +package apiissue + +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 ListByServiceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]IssueContract +} + +type ListByServiceCompleteResult struct { + Items []IssueContract +} + +type ListByServiceOperationOptions struct { + ExpandCommentsAttachments *bool + Filter *string + Skip *int64 + Top *int64 +} + +func DefaultListByServiceOperationOptions() ListByServiceOperationOptions { + return ListByServiceOperationOptions{} +} + +func (o ListByServiceOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListByServiceOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListByServiceOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.ExpandCommentsAttachments != nil { + out.Append("expandCommentsAttachments", fmt.Sprintf("%v", *o.ExpandCommentsAttachments)) + } + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.Skip != nil { + out.Append("$skip", fmt.Sprintf("%v", *o.Skip)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +// ListByService ... +func (c ApiIssueClient) ListByService(ctx context.Context, id ApiId, options ListByServiceOperationOptions) (result ListByServiceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/issues", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]IssueContract `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByServiceComplete retrieves all the results into a single object +func (c ApiIssueClient) ListByServiceComplete(ctx context.Context, id ApiId, options ListByServiceOperationOptions) (ListByServiceCompleteResult, error) { + return c.ListByServiceCompleteMatchingPredicate(ctx, id, options, IssueContractOperationPredicate{}) +} + +// ListByServiceCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ApiIssueClient) ListByServiceCompleteMatchingPredicate(ctx context.Context, id ApiId, options ListByServiceOperationOptions, predicate IssueContractOperationPredicate) (result ListByServiceCompleteResult, err error) { + items := make([]IssueContract, 0) + + resp, err := c.ListByService(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByServiceCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/apimanagement/2022-08-01/apiissue/method_listbyservice_autorest.go b/resource-manager/apimanagement/2022-08-01/apiissue/method_listbyservice_autorest.go deleted file mode 100644 index 48b3a2c6d18..00000000000 --- a/resource-manager/apimanagement/2022-08-01/apiissue/method_listbyservice_autorest.go +++ /dev/null @@ -1,230 +0,0 @@ -package apiissue - -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 ListByServiceOperationResponse struct { - HttpResponse *http.Response - Model *[]IssueContract - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListByServiceOperationResponse, error) -} - -type ListByServiceCompleteResult struct { - Items []IssueContract -} - -func (r ListByServiceOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListByServiceOperationResponse) LoadMore(ctx context.Context) (resp ListByServiceOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -type ListByServiceOperationOptions struct { - ExpandCommentsAttachments *bool - Filter *string - Skip *int64 - Top *int64 -} - -func DefaultListByServiceOperationOptions() ListByServiceOperationOptions { - return ListByServiceOperationOptions{} -} - -func (o ListByServiceOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o ListByServiceOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.ExpandCommentsAttachments != nil { - out["expandCommentsAttachments"] = *o.ExpandCommentsAttachments - } - - if o.Filter != nil { - out["$filter"] = *o.Filter - } - - if o.Skip != nil { - out["$skip"] = *o.Skip - } - - if o.Top != nil { - out["$top"] = *o.Top - } - - return out -} - -// ListByService ... -func (c ApiIssueClient) ListByService(ctx context.Context, id ApiId, options ListByServiceOperationOptions) (resp ListByServiceOperationResponse, err error) { - req, err := c.preparerForListByService(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "apiissue.ApiIssueClient", "ListByService", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apiissue.ApiIssueClient", "ListByService", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListByService(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apiissue.ApiIssueClient", "ListByService", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListByService prepares the ListByService request. -func (c ApiIssueClient) preparerForListByService(ctx context.Context, id ApiId, options ListByServiceOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/issues", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListByServiceWithNextLink prepares the ListByService request with the given nextLink token. -func (c ApiIssueClient) preparerForListByServiceWithNextLink(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)) -} - -// responderForListByService handles the response to the ListByService request. The method always -// closes the http.Response Body. -func (c ApiIssueClient) responderForListByService(resp *http.Response) (result ListByServiceOperationResponse, err error) { - type page struct { - Values []IssueContract `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 ListByServiceOperationResponse, err error) { - req, err := c.preparerForListByServiceWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "apiissue.ApiIssueClient", "ListByService", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apiissue.ApiIssueClient", "ListByService", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByService(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apiissue.ApiIssueClient", "ListByService", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListByServiceComplete retrieves all of the results into a single object -func (c ApiIssueClient) ListByServiceComplete(ctx context.Context, id ApiId, options ListByServiceOperationOptions) (ListByServiceCompleteResult, error) { - return c.ListByServiceCompleteMatchingPredicate(ctx, id, options, IssueContractOperationPredicate{}) -} - -// ListByServiceCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c ApiIssueClient) ListByServiceCompleteMatchingPredicate(ctx context.Context, id ApiId, options ListByServiceOperationOptions, predicate IssueContractOperationPredicate) (resp ListByServiceCompleteResult, err error) { - items := make([]IssueContract, 0) - - page, err := c.ListByService(ctx, id, options) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListByServiceCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/apimanagement/2022-08-01/apiissue/method_update.go b/resource-manager/apimanagement/2022-08-01/apiissue/method_update.go new file mode 100644 index 00000000000..584e3d7d164 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/apiissue/method_update.go @@ -0,0 +1,84 @@ +package apiissue + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *IssueContract +} + +type UpdateOperationOptions struct { + IfMatch *string +} + +func DefaultUpdateOperationOptions() UpdateOperationOptions { + return UpdateOperationOptions{} +} + +func (o UpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o UpdateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o UpdateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// Update ... +func (c ApiIssueClient) Update(ctx context.Context, id ApiIssueId, input IssueUpdateContract, options UpdateOperationOptions) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + OptionsObject: options, + } + + 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/apimanagement/2022-08-01/apiissue/method_update_autorest.go b/resource-manager/apimanagement/2022-08-01/apiissue/method_update_autorest.go deleted file mode 100644 index f2e65e33867..00000000000 --- a/resource-manager/apimanagement/2022-08-01/apiissue/method_update_autorest.go +++ /dev/null @@ -1,98 +0,0 @@ -package apiissue - -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 *IssueContract -} - -type UpdateOperationOptions struct { - IfMatch *string -} - -func DefaultUpdateOperationOptions() UpdateOperationOptions { - return UpdateOperationOptions{} -} - -func (o UpdateOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o UpdateOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// Update ... -func (c ApiIssueClient) Update(ctx context.Context, id ApiIssueId, input IssueUpdateContract, options UpdateOperationOptions) (result UpdateOperationResponse, err error) { - req, err := c.preparerForUpdate(ctx, id, input, options) - if err != nil { - err = autorest.NewErrorWithError(err, "apiissue.ApiIssueClient", "Update", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apiissue.ApiIssueClient", "Update", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apiissue.ApiIssueClient", "Update", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForUpdate prepares the Update request. -func (c ApiIssueClient) preparerForUpdate(ctx context.Context, id ApiIssueId, input IssueUpdateContract, options UpdateOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPatch(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - 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 ApiIssueClient) 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/apimanagement/2022-08-01/apiissueattachment/client.go b/resource-manager/apimanagement/2022-08-01/apiissueattachment/client.go index 603bab63d7c..8defa3dd09b 100644 --- a/resource-manager/apimanagement/2022-08-01/apiissueattachment/client.go +++ b/resource-manager/apimanagement/2022-08-01/apiissueattachment/client.go @@ -1,18 +1,26 @@ package apiissueattachment -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 ApiIssueAttachmentClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewApiIssueAttachmentClientWithBaseURI(endpoint string) ApiIssueAttachmentClient { - return ApiIssueAttachmentClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewApiIssueAttachmentClientWithBaseURI(api environments.Api) (*ApiIssueAttachmentClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "apiissueattachment", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ApiIssueAttachmentClient: %+v", err) } + + return &ApiIssueAttachmentClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2022-08-01/apiissueattachment/method_createorupdate.go b/resource-manager/apimanagement/2022-08-01/apiissueattachment/method_createorupdate.go new file mode 100644 index 00000000000..9b38974fd6c --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/apiissueattachment/method_createorupdate.go @@ -0,0 +1,85 @@ +package apiissueattachment + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *IssueAttachmentContract +} + +type CreateOrUpdateOperationOptions struct { + IfMatch *string +} + +func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { + return CreateOrUpdateOperationOptions{} +} + +func (o CreateOrUpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o CreateOrUpdateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o CreateOrUpdateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// CreateOrUpdate ... +func (c ApiIssueAttachmentClient) CreateOrUpdate(ctx context.Context, id AttachmentId, input IssueAttachmentContract, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + OptionsObject: options, + } + + 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/apimanagement/2022-08-01/apiissueattachment/method_createorupdate_autorest.go b/resource-manager/apimanagement/2022-08-01/apiissueattachment/method_createorupdate_autorest.go deleted file mode 100644 index 0d3c8faed1f..00000000000 --- a/resource-manager/apimanagement/2022-08-01/apiissueattachment/method_createorupdate_autorest.go +++ /dev/null @@ -1,98 +0,0 @@ -package apiissueattachment - -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 *IssueAttachmentContract -} - -type CreateOrUpdateOperationOptions struct { - IfMatch *string -} - -func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { - return CreateOrUpdateOperationOptions{} -} - -func (o CreateOrUpdateOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o CreateOrUpdateOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// CreateOrUpdate ... -func (c ApiIssueAttachmentClient) CreateOrUpdate(ctx context.Context, id AttachmentId, input IssueAttachmentContract, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdate(ctx, id, input, options) - if err != nil { - err = autorest.NewErrorWithError(err, "apiissueattachment.ApiIssueAttachmentClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apiissueattachment.ApiIssueAttachmentClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCreateOrUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apiissueattachment.ApiIssueAttachmentClient", "CreateOrUpdate", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCreateOrUpdate prepares the CreateOrUpdate request. -func (c ApiIssueAttachmentClient) preparerForCreateOrUpdate(ctx context.Context, id AttachmentId, input IssueAttachmentContract, options CreateOrUpdateOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - 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 ApiIssueAttachmentClient) responderForCreateOrUpdate(resp *http.Response) (result CreateOrUpdateOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2022-08-01/apiissueattachment/method_delete.go b/resource-manager/apimanagement/2022-08-01/apiissueattachment/method_delete.go new file mode 100644 index 00000000000..e2c80a156a2 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/apiissueattachment/method_delete.go @@ -0,0 +1,76 @@ +package apiissueattachment + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +type DeleteOperationOptions struct { + IfMatch *string +} + +func DefaultDeleteOperationOptions() DeleteOperationOptions { + return DeleteOperationOptions{} +} + +func (o DeleteOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o DeleteOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o DeleteOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// Delete ... +func (c ApiIssueAttachmentClient) Delete(ctx context.Context, id AttachmentId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2022-08-01/apiissueattachment/method_delete_autorest.go b/resource-manager/apimanagement/2022-08-01/apiissueattachment/method_delete_autorest.go deleted file mode 100644 index 0c1c547304e..00000000000 --- a/resource-manager/apimanagement/2022-08-01/apiissueattachment/method_delete_autorest.go +++ /dev/null @@ -1,95 +0,0 @@ -package apiissueattachment - -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 DeleteOperationResponse struct { - HttpResponse *http.Response -} - -type DeleteOperationOptions struct { - IfMatch *string -} - -func DefaultDeleteOperationOptions() DeleteOperationOptions { - return DeleteOperationOptions{} -} - -func (o DeleteOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o DeleteOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// Delete ... -func (c ApiIssueAttachmentClient) Delete(ctx context.Context, id AttachmentId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { - req, err := c.preparerForDelete(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "apiissueattachment.ApiIssueAttachmentClient", "Delete", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apiissueattachment.ApiIssueAttachmentClient", "Delete", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForDelete(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apiissueattachment.ApiIssueAttachmentClient", "Delete", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForDelete prepares the Delete request. -func (c ApiIssueAttachmentClient) preparerForDelete(ctx context.Context, id AttachmentId, options DeleteOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForDelete handles the response to the Delete request. The method always -// closes the http.Response Body. -func (c ApiIssueAttachmentClient) responderForDelete(resp *http.Response) (result DeleteOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2022-08-01/apiissueattachment/method_get.go b/resource-manager/apimanagement/2022-08-01/apiissueattachment/method_get.go new file mode 100644 index 00000000000..3e35f0e3c03 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/apiissueattachment/method_get.go @@ -0,0 +1,51 @@ +package apiissueattachment + +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 *IssueAttachmentContract +} + +// Get ... +func (c ApiIssueAttachmentClient) Get(ctx context.Context, id AttachmentId) (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/apimanagement/2022-08-01/apiissueattachment/method_get_autorest.go b/resource-manager/apimanagement/2022-08-01/apiissueattachment/method_get_autorest.go deleted file mode 100644 index cf5a5442e8f..00000000000 --- a/resource-manager/apimanagement/2022-08-01/apiissueattachment/method_get_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package apiissueattachment - -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 *IssueAttachmentContract -} - -// Get ... -func (c ApiIssueAttachmentClient) Get(ctx context.Context, id AttachmentId) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "apiissueattachment.ApiIssueAttachmentClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apiissueattachment.ApiIssueAttachmentClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apiissueattachment.ApiIssueAttachmentClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c ApiIssueAttachmentClient) preparerForGet(ctx context.Context, id AttachmentId) (*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 ApiIssueAttachmentClient) 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/apimanagement/2022-08-01/apiissueattachment/method_getentitytag.go b/resource-manager/apimanagement/2022-08-01/apiissueattachment/method_getentitytag.go new file mode 100644 index 00000000000..417b3e0b9bd --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/apiissueattachment/method_getentitytag.go @@ -0,0 +1,46 @@ +package apiissueattachment + +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 GetEntityTagOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// GetEntityTag ... +func (c ApiIssueAttachmentClient) GetEntityTag(ctx context.Context, id AttachmentId) (result GetEntityTagOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodHead, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2022-08-01/apiissueattachment/method_getentitytag_autorest.go b/resource-manager/apimanagement/2022-08-01/apiissueattachment/method_getentitytag_autorest.go deleted file mode 100644 index 24756f5be27..00000000000 --- a/resource-manager/apimanagement/2022-08-01/apiissueattachment/method_getentitytag_autorest.go +++ /dev/null @@ -1,66 +0,0 @@ -package apiissueattachment - -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 GetEntityTagOperationResponse struct { - HttpResponse *http.Response -} - -// GetEntityTag ... -func (c ApiIssueAttachmentClient) GetEntityTag(ctx context.Context, id AttachmentId) (result GetEntityTagOperationResponse, err error) { - req, err := c.preparerForGetEntityTag(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "apiissueattachment.ApiIssueAttachmentClient", "GetEntityTag", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apiissueattachment.ApiIssueAttachmentClient", "GetEntityTag", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetEntityTag(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apiissueattachment.ApiIssueAttachmentClient", "GetEntityTag", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetEntityTag prepares the GetEntityTag request. -func (c ApiIssueAttachmentClient) preparerForGetEntityTag(ctx context.Context, id AttachmentId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsHead(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetEntityTag handles the response to the GetEntityTag request. The method always -// closes the http.Response Body. -func (c ApiIssueAttachmentClient) responderForGetEntityTag(resp *http.Response) (result GetEntityTagOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2022-08-01/apiissueattachment/method_listbyservice.go b/resource-manager/apimanagement/2022-08-01/apiissueattachment/method_listbyservice.go new file mode 100644 index 00000000000..bda7001b3ab --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/apiissueattachment/method_listbyservice.go @@ -0,0 +1,125 @@ +package apiissueattachment + +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 ListByServiceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]IssueAttachmentContract +} + +type ListByServiceCompleteResult struct { + Items []IssueAttachmentContract +} + +type ListByServiceOperationOptions struct { + Filter *string + Skip *int64 + Top *int64 +} + +func DefaultListByServiceOperationOptions() ListByServiceOperationOptions { + return ListByServiceOperationOptions{} +} + +func (o ListByServiceOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListByServiceOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListByServiceOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.Skip != nil { + out.Append("$skip", fmt.Sprintf("%v", *o.Skip)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +// ListByService ... +func (c ApiIssueAttachmentClient) ListByService(ctx context.Context, id ApiIssueId, options ListByServiceOperationOptions) (result ListByServiceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/attachments", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]IssueAttachmentContract `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByServiceComplete retrieves all the results into a single object +func (c ApiIssueAttachmentClient) ListByServiceComplete(ctx context.Context, id ApiIssueId, options ListByServiceOperationOptions) (ListByServiceCompleteResult, error) { + return c.ListByServiceCompleteMatchingPredicate(ctx, id, options, IssueAttachmentContractOperationPredicate{}) +} + +// ListByServiceCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ApiIssueAttachmentClient) ListByServiceCompleteMatchingPredicate(ctx context.Context, id ApiIssueId, options ListByServiceOperationOptions, predicate IssueAttachmentContractOperationPredicate) (result ListByServiceCompleteResult, err error) { + items := make([]IssueAttachmentContract, 0) + + resp, err := c.ListByService(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByServiceCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/apimanagement/2022-08-01/apiissueattachment/method_listbyservice_autorest.go b/resource-manager/apimanagement/2022-08-01/apiissueattachment/method_listbyservice_autorest.go deleted file mode 100644 index 8decbc696ea..00000000000 --- a/resource-manager/apimanagement/2022-08-01/apiissueattachment/method_listbyservice_autorest.go +++ /dev/null @@ -1,225 +0,0 @@ -package apiissueattachment - -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 ListByServiceOperationResponse struct { - HttpResponse *http.Response - Model *[]IssueAttachmentContract - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListByServiceOperationResponse, error) -} - -type ListByServiceCompleteResult struct { - Items []IssueAttachmentContract -} - -func (r ListByServiceOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListByServiceOperationResponse) LoadMore(ctx context.Context) (resp ListByServiceOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -type ListByServiceOperationOptions struct { - Filter *string - Skip *int64 - Top *int64 -} - -func DefaultListByServiceOperationOptions() ListByServiceOperationOptions { - return ListByServiceOperationOptions{} -} - -func (o ListByServiceOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o ListByServiceOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Filter != nil { - out["$filter"] = *o.Filter - } - - if o.Skip != nil { - out["$skip"] = *o.Skip - } - - if o.Top != nil { - out["$top"] = *o.Top - } - - return out -} - -// ListByService ... -func (c ApiIssueAttachmentClient) ListByService(ctx context.Context, id ApiIssueId, options ListByServiceOperationOptions) (resp ListByServiceOperationResponse, err error) { - req, err := c.preparerForListByService(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "apiissueattachment.ApiIssueAttachmentClient", "ListByService", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apiissueattachment.ApiIssueAttachmentClient", "ListByService", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListByService(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apiissueattachment.ApiIssueAttachmentClient", "ListByService", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListByService prepares the ListByService request. -func (c ApiIssueAttachmentClient) preparerForListByService(ctx context.Context, id ApiIssueId, options ListByServiceOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/attachments", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListByServiceWithNextLink prepares the ListByService request with the given nextLink token. -func (c ApiIssueAttachmentClient) preparerForListByServiceWithNextLink(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)) -} - -// responderForListByService handles the response to the ListByService request. The method always -// closes the http.Response Body. -func (c ApiIssueAttachmentClient) responderForListByService(resp *http.Response) (result ListByServiceOperationResponse, err error) { - type page struct { - Values []IssueAttachmentContract `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 ListByServiceOperationResponse, err error) { - req, err := c.preparerForListByServiceWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "apiissueattachment.ApiIssueAttachmentClient", "ListByService", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apiissueattachment.ApiIssueAttachmentClient", "ListByService", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByService(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apiissueattachment.ApiIssueAttachmentClient", "ListByService", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListByServiceComplete retrieves all of the results into a single object -func (c ApiIssueAttachmentClient) ListByServiceComplete(ctx context.Context, id ApiIssueId, options ListByServiceOperationOptions) (ListByServiceCompleteResult, error) { - return c.ListByServiceCompleteMatchingPredicate(ctx, id, options, IssueAttachmentContractOperationPredicate{}) -} - -// ListByServiceCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c ApiIssueAttachmentClient) ListByServiceCompleteMatchingPredicate(ctx context.Context, id ApiIssueId, options ListByServiceOperationOptions, predicate IssueAttachmentContractOperationPredicate) (resp ListByServiceCompleteResult, err error) { - items := make([]IssueAttachmentContract, 0) - - page, err := c.ListByService(ctx, id, options) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListByServiceCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/apimanagement/2022-08-01/apiissuecomment/client.go b/resource-manager/apimanagement/2022-08-01/apiissuecomment/client.go index c2d875d616a..0628382d8fb 100644 --- a/resource-manager/apimanagement/2022-08-01/apiissuecomment/client.go +++ b/resource-manager/apimanagement/2022-08-01/apiissuecomment/client.go @@ -1,18 +1,26 @@ package apiissuecomment -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 ApiIssueCommentClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewApiIssueCommentClientWithBaseURI(endpoint string) ApiIssueCommentClient { - return ApiIssueCommentClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewApiIssueCommentClientWithBaseURI(api environments.Api) (*ApiIssueCommentClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "apiissuecomment", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ApiIssueCommentClient: %+v", err) } + + return &ApiIssueCommentClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2022-08-01/apiissuecomment/method_createorupdate.go b/resource-manager/apimanagement/2022-08-01/apiissuecomment/method_createorupdate.go new file mode 100644 index 00000000000..4151626f6b6 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/apiissuecomment/method_createorupdate.go @@ -0,0 +1,85 @@ +package apiissuecomment + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *IssueCommentContract +} + +type CreateOrUpdateOperationOptions struct { + IfMatch *string +} + +func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { + return CreateOrUpdateOperationOptions{} +} + +func (o CreateOrUpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o CreateOrUpdateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o CreateOrUpdateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// CreateOrUpdate ... +func (c ApiIssueCommentClient) CreateOrUpdate(ctx context.Context, id CommentId, input IssueCommentContract, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + OptionsObject: options, + } + + 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/apimanagement/2022-08-01/apiissuecomment/method_createorupdate_autorest.go b/resource-manager/apimanagement/2022-08-01/apiissuecomment/method_createorupdate_autorest.go deleted file mode 100644 index 4b1b3d4e955..00000000000 --- a/resource-manager/apimanagement/2022-08-01/apiissuecomment/method_createorupdate_autorest.go +++ /dev/null @@ -1,98 +0,0 @@ -package apiissuecomment - -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 *IssueCommentContract -} - -type CreateOrUpdateOperationOptions struct { - IfMatch *string -} - -func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { - return CreateOrUpdateOperationOptions{} -} - -func (o CreateOrUpdateOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o CreateOrUpdateOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// CreateOrUpdate ... -func (c ApiIssueCommentClient) CreateOrUpdate(ctx context.Context, id CommentId, input IssueCommentContract, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdate(ctx, id, input, options) - if err != nil { - err = autorest.NewErrorWithError(err, "apiissuecomment.ApiIssueCommentClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apiissuecomment.ApiIssueCommentClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCreateOrUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apiissuecomment.ApiIssueCommentClient", "CreateOrUpdate", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCreateOrUpdate prepares the CreateOrUpdate request. -func (c ApiIssueCommentClient) preparerForCreateOrUpdate(ctx context.Context, id CommentId, input IssueCommentContract, options CreateOrUpdateOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - 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 ApiIssueCommentClient) responderForCreateOrUpdate(resp *http.Response) (result CreateOrUpdateOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2022-08-01/apiissuecomment/method_delete.go b/resource-manager/apimanagement/2022-08-01/apiissuecomment/method_delete.go new file mode 100644 index 00000000000..b6cb1c7f69b --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/apiissuecomment/method_delete.go @@ -0,0 +1,76 @@ +package apiissuecomment + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +type DeleteOperationOptions struct { + IfMatch *string +} + +func DefaultDeleteOperationOptions() DeleteOperationOptions { + return DeleteOperationOptions{} +} + +func (o DeleteOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o DeleteOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o DeleteOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// Delete ... +func (c ApiIssueCommentClient) Delete(ctx context.Context, id CommentId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2022-08-01/apiissuecomment/method_delete_autorest.go b/resource-manager/apimanagement/2022-08-01/apiissuecomment/method_delete_autorest.go deleted file mode 100644 index ae7d6a12be4..00000000000 --- a/resource-manager/apimanagement/2022-08-01/apiissuecomment/method_delete_autorest.go +++ /dev/null @@ -1,95 +0,0 @@ -package apiissuecomment - -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 DeleteOperationResponse struct { - HttpResponse *http.Response -} - -type DeleteOperationOptions struct { - IfMatch *string -} - -func DefaultDeleteOperationOptions() DeleteOperationOptions { - return DeleteOperationOptions{} -} - -func (o DeleteOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o DeleteOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// Delete ... -func (c ApiIssueCommentClient) Delete(ctx context.Context, id CommentId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { - req, err := c.preparerForDelete(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "apiissuecomment.ApiIssueCommentClient", "Delete", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apiissuecomment.ApiIssueCommentClient", "Delete", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForDelete(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apiissuecomment.ApiIssueCommentClient", "Delete", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForDelete prepares the Delete request. -func (c ApiIssueCommentClient) preparerForDelete(ctx context.Context, id CommentId, options DeleteOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForDelete handles the response to the Delete request. The method always -// closes the http.Response Body. -func (c ApiIssueCommentClient) responderForDelete(resp *http.Response) (result DeleteOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2022-08-01/apiissuecomment/method_get.go b/resource-manager/apimanagement/2022-08-01/apiissuecomment/method_get.go new file mode 100644 index 00000000000..df6ff41fb18 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/apiissuecomment/method_get.go @@ -0,0 +1,51 @@ +package apiissuecomment + +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 *IssueCommentContract +} + +// Get ... +func (c ApiIssueCommentClient) Get(ctx context.Context, id CommentId) (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/apimanagement/2022-08-01/apiissuecomment/method_get_autorest.go b/resource-manager/apimanagement/2022-08-01/apiissuecomment/method_get_autorest.go deleted file mode 100644 index 97cae9d1ac1..00000000000 --- a/resource-manager/apimanagement/2022-08-01/apiissuecomment/method_get_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package apiissuecomment - -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 *IssueCommentContract -} - -// Get ... -func (c ApiIssueCommentClient) Get(ctx context.Context, id CommentId) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "apiissuecomment.ApiIssueCommentClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apiissuecomment.ApiIssueCommentClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apiissuecomment.ApiIssueCommentClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c ApiIssueCommentClient) preparerForGet(ctx context.Context, id CommentId) (*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 ApiIssueCommentClient) 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/apimanagement/2022-08-01/apiissuecomment/method_getentitytag.go b/resource-manager/apimanagement/2022-08-01/apiissuecomment/method_getentitytag.go new file mode 100644 index 00000000000..a5ce802f723 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/apiissuecomment/method_getentitytag.go @@ -0,0 +1,46 @@ +package apiissuecomment + +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 GetEntityTagOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// GetEntityTag ... +func (c ApiIssueCommentClient) GetEntityTag(ctx context.Context, id CommentId) (result GetEntityTagOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodHead, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2022-08-01/apiissuecomment/method_getentitytag_autorest.go b/resource-manager/apimanagement/2022-08-01/apiissuecomment/method_getentitytag_autorest.go deleted file mode 100644 index 7793e44727b..00000000000 --- a/resource-manager/apimanagement/2022-08-01/apiissuecomment/method_getentitytag_autorest.go +++ /dev/null @@ -1,66 +0,0 @@ -package apiissuecomment - -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 GetEntityTagOperationResponse struct { - HttpResponse *http.Response -} - -// GetEntityTag ... -func (c ApiIssueCommentClient) GetEntityTag(ctx context.Context, id CommentId) (result GetEntityTagOperationResponse, err error) { - req, err := c.preparerForGetEntityTag(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "apiissuecomment.ApiIssueCommentClient", "GetEntityTag", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apiissuecomment.ApiIssueCommentClient", "GetEntityTag", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetEntityTag(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apiissuecomment.ApiIssueCommentClient", "GetEntityTag", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetEntityTag prepares the GetEntityTag request. -func (c ApiIssueCommentClient) preparerForGetEntityTag(ctx context.Context, id CommentId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsHead(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetEntityTag handles the response to the GetEntityTag request. The method always -// closes the http.Response Body. -func (c ApiIssueCommentClient) responderForGetEntityTag(resp *http.Response) (result GetEntityTagOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2022-08-01/apiissuecomment/method_listbyservice.go b/resource-manager/apimanagement/2022-08-01/apiissuecomment/method_listbyservice.go new file mode 100644 index 00000000000..3240d518d9c --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/apiissuecomment/method_listbyservice.go @@ -0,0 +1,125 @@ +package apiissuecomment + +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 ListByServiceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]IssueCommentContract +} + +type ListByServiceCompleteResult struct { + Items []IssueCommentContract +} + +type ListByServiceOperationOptions struct { + Filter *string + Skip *int64 + Top *int64 +} + +func DefaultListByServiceOperationOptions() ListByServiceOperationOptions { + return ListByServiceOperationOptions{} +} + +func (o ListByServiceOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListByServiceOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListByServiceOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.Skip != nil { + out.Append("$skip", fmt.Sprintf("%v", *o.Skip)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +// ListByService ... +func (c ApiIssueCommentClient) ListByService(ctx context.Context, id ApiIssueId, options ListByServiceOperationOptions) (result ListByServiceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/comments", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]IssueCommentContract `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByServiceComplete retrieves all the results into a single object +func (c ApiIssueCommentClient) ListByServiceComplete(ctx context.Context, id ApiIssueId, options ListByServiceOperationOptions) (ListByServiceCompleteResult, error) { + return c.ListByServiceCompleteMatchingPredicate(ctx, id, options, IssueCommentContractOperationPredicate{}) +} + +// ListByServiceCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ApiIssueCommentClient) ListByServiceCompleteMatchingPredicate(ctx context.Context, id ApiIssueId, options ListByServiceOperationOptions, predicate IssueCommentContractOperationPredicate) (result ListByServiceCompleteResult, err error) { + items := make([]IssueCommentContract, 0) + + resp, err := c.ListByService(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByServiceCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/apimanagement/2022-08-01/apiissuecomment/method_listbyservice_autorest.go b/resource-manager/apimanagement/2022-08-01/apiissuecomment/method_listbyservice_autorest.go deleted file mode 100644 index 3057cba0d58..00000000000 --- a/resource-manager/apimanagement/2022-08-01/apiissuecomment/method_listbyservice_autorest.go +++ /dev/null @@ -1,225 +0,0 @@ -package apiissuecomment - -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 ListByServiceOperationResponse struct { - HttpResponse *http.Response - Model *[]IssueCommentContract - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListByServiceOperationResponse, error) -} - -type ListByServiceCompleteResult struct { - Items []IssueCommentContract -} - -func (r ListByServiceOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListByServiceOperationResponse) LoadMore(ctx context.Context) (resp ListByServiceOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -type ListByServiceOperationOptions struct { - Filter *string - Skip *int64 - Top *int64 -} - -func DefaultListByServiceOperationOptions() ListByServiceOperationOptions { - return ListByServiceOperationOptions{} -} - -func (o ListByServiceOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o ListByServiceOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Filter != nil { - out["$filter"] = *o.Filter - } - - if o.Skip != nil { - out["$skip"] = *o.Skip - } - - if o.Top != nil { - out["$top"] = *o.Top - } - - return out -} - -// ListByService ... -func (c ApiIssueCommentClient) ListByService(ctx context.Context, id ApiIssueId, options ListByServiceOperationOptions) (resp ListByServiceOperationResponse, err error) { - req, err := c.preparerForListByService(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "apiissuecomment.ApiIssueCommentClient", "ListByService", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apiissuecomment.ApiIssueCommentClient", "ListByService", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListByService(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apiissuecomment.ApiIssueCommentClient", "ListByService", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListByService prepares the ListByService request. -func (c ApiIssueCommentClient) preparerForListByService(ctx context.Context, id ApiIssueId, options ListByServiceOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/comments", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListByServiceWithNextLink prepares the ListByService request with the given nextLink token. -func (c ApiIssueCommentClient) preparerForListByServiceWithNextLink(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)) -} - -// responderForListByService handles the response to the ListByService request. The method always -// closes the http.Response Body. -func (c ApiIssueCommentClient) responderForListByService(resp *http.Response) (result ListByServiceOperationResponse, err error) { - type page struct { - Values []IssueCommentContract `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 ListByServiceOperationResponse, err error) { - req, err := c.preparerForListByServiceWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "apiissuecomment.ApiIssueCommentClient", "ListByService", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apiissuecomment.ApiIssueCommentClient", "ListByService", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByService(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apiissuecomment.ApiIssueCommentClient", "ListByService", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListByServiceComplete retrieves all of the results into a single object -func (c ApiIssueCommentClient) ListByServiceComplete(ctx context.Context, id ApiIssueId, options ListByServiceOperationOptions) (ListByServiceCompleteResult, error) { - return c.ListByServiceCompleteMatchingPredicate(ctx, id, options, IssueCommentContractOperationPredicate{}) -} - -// ListByServiceCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c ApiIssueCommentClient) ListByServiceCompleteMatchingPredicate(ctx context.Context, id ApiIssueId, options ListByServiceOperationOptions, predicate IssueCommentContractOperationPredicate) (resp ListByServiceCompleteResult, err error) { - items := make([]IssueCommentContract, 0) - - page, err := c.ListByService(ctx, id, options) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListByServiceCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/apimanagement/2022-08-01/apimanagementservice/client.go b/resource-manager/apimanagement/2022-08-01/apimanagementservice/client.go index b6859cfd757..b7a7fbab358 100644 --- a/resource-manager/apimanagement/2022-08-01/apimanagementservice/client.go +++ b/resource-manager/apimanagement/2022-08-01/apimanagementservice/client.go @@ -1,18 +1,26 @@ package apimanagementservice -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 ApiManagementServiceClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewApiManagementServiceClientWithBaseURI(endpoint string) ApiManagementServiceClient { - return ApiManagementServiceClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewApiManagementServiceClientWithBaseURI(api environments.Api) (*ApiManagementServiceClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "apimanagementservice", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ApiManagementServiceClient: %+v", err) } + + return &ApiManagementServiceClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2022-08-01/apimanagementservice/constants.go b/resource-manager/apimanagement/2022-08-01/apimanagementservice/constants.go index 5eb7eeb6ae4..d9fbce72ae6 100644 --- a/resource-manager/apimanagement/2022-08-01/apimanagementservice/constants.go +++ b/resource-manager/apimanagement/2022-08-01/apimanagementservice/constants.go @@ -1,6 +1,10 @@ package apimanagementservice -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 PossibleValuesForAccessType() []string { } } +func (s *AccessType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAccessType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseAccessType(input string) (*AccessType, error) { vals := map[string]AccessType{ "accesskey": AccessTypeAccessKey, @@ -54,6 +71,19 @@ func PossibleValuesForCertificateSource() []string { } } +func (s *CertificateSource) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCertificateSource(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseCertificateSource(input string) (*CertificateSource, error) { vals := map[string]CertificateSource{ "builtin": CertificateSourceBuiltIn, @@ -86,6 +116,19 @@ func PossibleValuesForCertificateStatus() []string { } } +func (s *CertificateStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCertificateStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseCertificateStatus(input string) (*CertificateStatus, error) { vals := map[string]CertificateStatus{ "completed": CertificateStatusCompleted, @@ -121,6 +164,19 @@ func PossibleValuesForHostnameType() []string { } } +func (s *HostnameType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseHostnameType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseHostnameType(input string) (*HostnameType, error) { vals := map[string]HostnameType{ "developerportal": HostnameTypeDeveloperPortal, @@ -154,6 +210,19 @@ func PossibleValuesForNameAvailabilityReason() []string { } } +func (s *NameAvailabilityReason) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNameAvailabilityReason(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseNameAvailabilityReason(input string) (*NameAvailabilityReason, error) { vals := map[string]NameAvailabilityReason{ "alreadyexists": NameAvailabilityReasonAlreadyExists, @@ -183,6 +252,19 @@ func PossibleValuesForNatGatewayState() []string { } } +func (s *NatGatewayState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNatGatewayState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseNatGatewayState(input string) (*NatGatewayState, error) { vals := map[string]NatGatewayState{ "disabled": NatGatewayStateDisabled, @@ -215,6 +297,19 @@ func PossibleValuesForPlatformVersion() []string { } } +func (s *PlatformVersion) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePlatformVersion(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parsePlatformVersion(input string) (*PlatformVersion, error) { vals := map[string]PlatformVersion{ "mtv1": PlatformVersionMtvOne, @@ -247,6 +342,19 @@ func PossibleValuesForPrivateEndpointServiceConnectionStatus() []string { } } +func (s *PrivateEndpointServiceConnectionStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePrivateEndpointServiceConnectionStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parsePrivateEndpointServiceConnectionStatus(input string) (*PrivateEndpointServiceConnectionStatus, error) { vals := map[string]PrivateEndpointServiceConnectionStatus{ "approved": PrivateEndpointServiceConnectionStatusApproved, @@ -276,6 +384,19 @@ func PossibleValuesForPublicNetworkAccess() []string { } } +func (s *PublicNetworkAccess) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePublicNetworkAccess(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parsePublicNetworkAccess(input string) (*PublicNetworkAccess, error) { vals := map[string]PublicNetworkAccess{ "disabled": PublicNetworkAccessDisabled, @@ -312,6 +433,19 @@ func PossibleValuesForSkuType() []string { } } +func (s *SkuType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSkuType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseSkuType(input string) (*SkuType, error) { vals := map[string]SkuType{ "basic": SkuTypeBasic, @@ -344,6 +478,19 @@ func PossibleValuesForStoreName() []string { } } +func (s *StoreName) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseStoreName(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseStoreName(input string) (*StoreName, error) { vals := map[string]StoreName{ "certificateauthority": StoreNameCertificateAuthority, @@ -374,6 +521,19 @@ func PossibleValuesForVirtualNetworkType() []string { } } +func (s *VirtualNetworkType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseVirtualNetworkType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseVirtualNetworkType(input string) (*VirtualNetworkType, error) { vals := map[string]VirtualNetworkType{ "external": VirtualNetworkTypeExternal, diff --git a/resource-manager/apimanagement/2022-08-01/apimanagementservice/method_applynetworkconfigurationupdates.go b/resource-manager/apimanagement/2022-08-01/apimanagementservice/method_applynetworkconfigurationupdates.go new file mode 100644 index 00000000000..47666690d41 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/apimanagementservice/method_applynetworkconfigurationupdates.go @@ -0,0 +1,74 @@ +package apimanagementservice + +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 ApplyNetworkConfigurationUpdatesOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// ApplyNetworkConfigurationUpdates ... +func (c ApiManagementServiceClient) ApplyNetworkConfigurationUpdates(ctx context.Context, id ServiceId, input ApiManagementServiceApplyNetworkConfigurationParameters) (result ApplyNetworkConfigurationUpdatesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/applynetworkconfigurationupdates", 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 +} + +// ApplyNetworkConfigurationUpdatesThenPoll performs ApplyNetworkConfigurationUpdates then polls until it's completed +func (c ApiManagementServiceClient) ApplyNetworkConfigurationUpdatesThenPoll(ctx context.Context, id ServiceId, input ApiManagementServiceApplyNetworkConfigurationParameters) error { + result, err := c.ApplyNetworkConfigurationUpdates(ctx, id, input) + if err != nil { + return fmt.Errorf("performing ApplyNetworkConfigurationUpdates: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after ApplyNetworkConfigurationUpdates: %+v", err) + } + + return nil +} diff --git a/resource-manager/apimanagement/2022-08-01/apimanagementservice/method_applynetworkconfigurationupdates_autorest.go b/resource-manager/apimanagement/2022-08-01/apimanagementservice/method_applynetworkconfigurationupdates_autorest.go deleted file mode 100644 index 7a1a5edef4d..00000000000 --- a/resource-manager/apimanagement/2022-08-01/apimanagementservice/method_applynetworkconfigurationupdates_autorest.go +++ /dev/null @@ -1,79 +0,0 @@ -package apimanagementservice - -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 ApplyNetworkConfigurationUpdatesOperationResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// ApplyNetworkConfigurationUpdates ... -func (c ApiManagementServiceClient) ApplyNetworkConfigurationUpdates(ctx context.Context, id ServiceId, input ApiManagementServiceApplyNetworkConfigurationParameters) (result ApplyNetworkConfigurationUpdatesOperationResponse, err error) { - req, err := c.preparerForApplyNetworkConfigurationUpdates(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "apimanagementservice.ApiManagementServiceClient", "ApplyNetworkConfigurationUpdates", nil, "Failure preparing request") - return - } - - result, err = c.senderForApplyNetworkConfigurationUpdates(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "apimanagementservice.ApiManagementServiceClient", "ApplyNetworkConfigurationUpdates", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// ApplyNetworkConfigurationUpdatesThenPoll performs ApplyNetworkConfigurationUpdates then polls until it's completed -func (c ApiManagementServiceClient) ApplyNetworkConfigurationUpdatesThenPoll(ctx context.Context, id ServiceId, input ApiManagementServiceApplyNetworkConfigurationParameters) error { - result, err := c.ApplyNetworkConfigurationUpdates(ctx, id, input) - if err != nil { - return fmt.Errorf("performing ApplyNetworkConfigurationUpdates: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after ApplyNetworkConfigurationUpdates: %+v", err) - } - - return nil -} - -// preparerForApplyNetworkConfigurationUpdates prepares the ApplyNetworkConfigurationUpdates request. -func (c ApiManagementServiceClient) preparerForApplyNetworkConfigurationUpdates(ctx context.Context, id ServiceId, input ApiManagementServiceApplyNetworkConfigurationParameters) (*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/applynetworkconfigurationupdates", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForApplyNetworkConfigurationUpdates sends the ApplyNetworkConfigurationUpdates request. The method will close the -// http.Response Body if it receives an error. -func (c ApiManagementServiceClient) senderForApplyNetworkConfigurationUpdates(ctx context.Context, req *http.Request) (future ApplyNetworkConfigurationUpdatesOperationResponse, 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/apimanagement/2022-08-01/apimanagementservice/method_backup.go b/resource-manager/apimanagement/2022-08-01/apimanagementservice/method_backup.go new file mode 100644 index 00000000000..2d68d0ef05f --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/apimanagementservice/method_backup.go @@ -0,0 +1,74 @@ +package apimanagementservice + +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 BackupOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Backup ... +func (c ApiManagementServiceClient) Backup(ctx context.Context, id ServiceId, input ApiManagementServiceBackupRestoreParameters) (result BackupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/backup", 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 +} + +// BackupThenPoll performs Backup then polls until it's completed +func (c ApiManagementServiceClient) BackupThenPoll(ctx context.Context, id ServiceId, input ApiManagementServiceBackupRestoreParameters) error { + result, err := c.Backup(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Backup: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Backup: %+v", err) + } + + return nil +} diff --git a/resource-manager/apimanagement/2022-08-01/apimanagementservice/method_backup_autorest.go b/resource-manager/apimanagement/2022-08-01/apimanagementservice/method_backup_autorest.go deleted file mode 100644 index 425460d47a1..00000000000 --- a/resource-manager/apimanagement/2022-08-01/apimanagementservice/method_backup_autorest.go +++ /dev/null @@ -1,79 +0,0 @@ -package apimanagementservice - -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 BackupOperationResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// Backup ... -func (c ApiManagementServiceClient) Backup(ctx context.Context, id ServiceId, input ApiManagementServiceBackupRestoreParameters) (result BackupOperationResponse, err error) { - req, err := c.preparerForBackup(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "apimanagementservice.ApiManagementServiceClient", "Backup", nil, "Failure preparing request") - return - } - - result, err = c.senderForBackup(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "apimanagementservice.ApiManagementServiceClient", "Backup", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// BackupThenPoll performs Backup then polls until it's completed -func (c ApiManagementServiceClient) BackupThenPoll(ctx context.Context, id ServiceId, input ApiManagementServiceBackupRestoreParameters) error { - result, err := c.Backup(ctx, id, input) - if err != nil { - return fmt.Errorf("performing Backup: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after Backup: %+v", err) - } - - return nil -} - -// preparerForBackup prepares the Backup request. -func (c ApiManagementServiceClient) preparerForBackup(ctx context.Context, id ServiceId, input ApiManagementServiceBackupRestoreParameters) (*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/backup", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForBackup sends the Backup request. The method will close the -// http.Response Body if it receives an error. -func (c ApiManagementServiceClient) senderForBackup(ctx context.Context, req *http.Request) (future BackupOperationResponse, 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/apimanagement/2022-08-01/apimanagementservice/method_checknameavailability.go b/resource-manager/apimanagement/2022-08-01/apimanagementservice/method_checknameavailability.go new file mode 100644 index 00000000000..69c30c85560 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/apimanagementservice/method_checknameavailability.go @@ -0,0 +1,57 @@ +package apimanagementservice + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CheckNameAvailabilityOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ApiManagementServiceNameAvailabilityResult +} + +// CheckNameAvailability ... +func (c ApiManagementServiceClient) CheckNameAvailability(ctx context.Context, id commonids.SubscriptionId, input ApiManagementServiceCheckNameAvailabilityParameters) (result CheckNameAvailabilityOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/providers/Microsoft.ApiManagement/checkNameAvailability", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + if err = resp.Unmarshal(&result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2022-08-01/apimanagementservice/method_checknameavailability_autorest.go b/resource-manager/apimanagement/2022-08-01/apimanagementservice/method_checknameavailability_autorest.go deleted file mode 100644 index cd62edeb4a2..00000000000 --- a/resource-manager/apimanagement/2022-08-01/apimanagementservice/method_checknameavailability_autorest.go +++ /dev/null @@ -1,71 +0,0 @@ -package apimanagementservice - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type CheckNameAvailabilityOperationResponse struct { - HttpResponse *http.Response - Model *ApiManagementServiceNameAvailabilityResult -} - -// CheckNameAvailability ... -func (c ApiManagementServiceClient) CheckNameAvailability(ctx context.Context, id commonids.SubscriptionId, input ApiManagementServiceCheckNameAvailabilityParameters) (result CheckNameAvailabilityOperationResponse, err error) { - req, err := c.preparerForCheckNameAvailability(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "apimanagementservice.ApiManagementServiceClient", "CheckNameAvailability", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apimanagementservice.ApiManagementServiceClient", "CheckNameAvailability", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCheckNameAvailability(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apimanagementservice.ApiManagementServiceClient", "CheckNameAvailability", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCheckNameAvailability prepares the CheckNameAvailability request. -func (c ApiManagementServiceClient) preparerForCheckNameAvailability(ctx context.Context, id commonids.SubscriptionId, input ApiManagementServiceCheckNameAvailabilityParameters) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/providers/Microsoft.ApiManagement/checkNameAvailability", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForCheckNameAvailability handles the response to the CheckNameAvailability request. The method always -// closes the http.Response Body. -func (c ApiManagementServiceClient) responderForCheckNameAvailability(resp *http.Response) (result CheckNameAvailabilityOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2022-08-01/apimanagementservice/method_createorupdate.go b/resource-manager/apimanagement/2022-08-01/apimanagementservice/method_createorupdate.go new file mode 100644 index 00000000000..6ad0b1f3c65 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/apimanagementservice/method_createorupdate.go @@ -0,0 +1,74 @@ +package apimanagementservice + +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 +} + +// CreateOrUpdate ... +func (c ApiManagementServiceClient) CreateOrUpdate(ctx context.Context, id ServiceId, input ApiManagementServiceResource) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed +func (c ApiManagementServiceClient) CreateOrUpdateThenPoll(ctx context.Context, id ServiceId, input ApiManagementServiceResource) 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/apimanagement/2022-08-01/apimanagementservice/method_createorupdate_autorest.go b/resource-manager/apimanagement/2022-08-01/apimanagementservice/method_createorupdate_autorest.go deleted file mode 100644 index b374287e28f..00000000000 --- a/resource-manager/apimanagement/2022-08-01/apimanagementservice/method_createorupdate_autorest.go +++ /dev/null @@ -1,79 +0,0 @@ -package apimanagementservice - -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 -} - -// CreateOrUpdate ... -func (c ApiManagementServiceClient) CreateOrUpdate(ctx context.Context, id ServiceId, input ApiManagementServiceResource) (result CreateOrUpdateOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "apimanagementservice.ApiManagementServiceClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result, err = c.senderForCreateOrUpdate(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "apimanagementservice.ApiManagementServiceClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed -func (c ApiManagementServiceClient) CreateOrUpdateThenPoll(ctx context.Context, id ServiceId, input ApiManagementServiceResource) 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 ApiManagementServiceClient) preparerForCreateOrUpdate(ctx context.Context, id ServiceId, input ApiManagementServiceResource) (*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 ApiManagementServiceClient) 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/apimanagement/2022-08-01/apimanagementservice/method_delete.go b/resource-manager/apimanagement/2022-08-01/apimanagementservice/method_delete.go new file mode 100644 index 00000000000..e40cd93940a --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/apimanagementservice/method_delete.go @@ -0,0 +1,71 @@ +package apimanagementservice + +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 ApiManagementServiceClient) 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 ApiManagementServiceClient) 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/apimanagement/2022-08-01/apimanagementservice/method_delete_autorest.go b/resource-manager/apimanagement/2022-08-01/apimanagementservice/method_delete_autorest.go deleted file mode 100644 index c8aa7ccb600..00000000000 --- a/resource-manager/apimanagement/2022-08-01/apimanagementservice/method_delete_autorest.go +++ /dev/null @@ -1,78 +0,0 @@ -package apimanagementservice - -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 ApiManagementServiceClient) Delete(ctx context.Context, id ServiceId) (result DeleteOperationResponse, err error) { - req, err := c.preparerForDelete(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "apimanagementservice.ApiManagementServiceClient", "Delete", nil, "Failure preparing request") - return - } - - result, err = c.senderForDelete(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "apimanagementservice.ApiManagementServiceClient", "Delete", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// DeleteThenPoll performs Delete then polls until it's completed -func (c ApiManagementServiceClient) 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 ApiManagementServiceClient) 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 ApiManagementServiceClient) 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/apimanagement/2022-08-01/apimanagementservice/method_get.go b/resource-manager/apimanagement/2022-08-01/apimanagementservice/method_get.go new file mode 100644 index 00000000000..a12ef17aed4 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/apimanagementservice/method_get.go @@ -0,0 +1,51 @@ +package apimanagementservice + +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 *ApiManagementServiceResource +} + +// Get ... +func (c ApiManagementServiceClient) 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/apimanagement/2022-08-01/apimanagementservice/method_get_autorest.go b/resource-manager/apimanagement/2022-08-01/apimanagementservice/method_get_autorest.go deleted file mode 100644 index 83af95cf755..00000000000 --- a/resource-manager/apimanagement/2022-08-01/apimanagementservice/method_get_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package apimanagementservice - -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 *ApiManagementServiceResource -} - -// Get ... -func (c ApiManagementServiceClient) Get(ctx context.Context, id ServiceId) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "apimanagementservice.ApiManagementServiceClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apimanagementservice.ApiManagementServiceClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apimanagementservice.ApiManagementServiceClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c ApiManagementServiceClient) 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 ApiManagementServiceClient) 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/apimanagement/2022-08-01/apimanagementservice/method_getdomainownershipidentifier.go b/resource-manager/apimanagement/2022-08-01/apimanagementservice/method_getdomainownershipidentifier.go new file mode 100644 index 00000000000..de103cd5209 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/apimanagementservice/method_getdomainownershipidentifier.go @@ -0,0 +1,53 @@ +package apimanagementservice + +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 GetDomainOwnershipIdentifierOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ApiManagementServiceGetDomainOwnershipIdentifierResult +} + +// GetDomainOwnershipIdentifier ... +func (c ApiManagementServiceClient) GetDomainOwnershipIdentifier(ctx context.Context, id commonids.SubscriptionId) (result GetDomainOwnershipIdentifierOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/providers/Microsoft.ApiManagement/getDomainOwnershipIdentifier", 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/apimanagement/2022-08-01/apimanagementservice/method_getdomainownershipidentifier_autorest.go b/resource-manager/apimanagement/2022-08-01/apimanagementservice/method_getdomainownershipidentifier_autorest.go deleted file mode 100644 index 3ee44e20f2e..00000000000 --- a/resource-manager/apimanagement/2022-08-01/apimanagementservice/method_getdomainownershipidentifier_autorest.go +++ /dev/null @@ -1,70 +0,0 @@ -package apimanagementservice - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetDomainOwnershipIdentifierOperationResponse struct { - HttpResponse *http.Response - Model *ApiManagementServiceGetDomainOwnershipIdentifierResult -} - -// GetDomainOwnershipIdentifier ... -func (c ApiManagementServiceClient) GetDomainOwnershipIdentifier(ctx context.Context, id commonids.SubscriptionId) (result GetDomainOwnershipIdentifierOperationResponse, err error) { - req, err := c.preparerForGetDomainOwnershipIdentifier(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "apimanagementservice.ApiManagementServiceClient", "GetDomainOwnershipIdentifier", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apimanagementservice.ApiManagementServiceClient", "GetDomainOwnershipIdentifier", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetDomainOwnershipIdentifier(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apimanagementservice.ApiManagementServiceClient", "GetDomainOwnershipIdentifier", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetDomainOwnershipIdentifier prepares the GetDomainOwnershipIdentifier request. -func (c ApiManagementServiceClient) preparerForGetDomainOwnershipIdentifier(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.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/providers/Microsoft.ApiManagement/getDomainOwnershipIdentifier", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetDomainOwnershipIdentifier handles the response to the GetDomainOwnershipIdentifier request. The method always -// closes the http.Response Body. -func (c ApiManagementServiceClient) responderForGetDomainOwnershipIdentifier(resp *http.Response) (result GetDomainOwnershipIdentifierOperationResponse, 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/apimanagement/2022-08-01/apimanagementservice/method_getssotoken.go b/resource-manager/apimanagement/2022-08-01/apimanagementservice/method_getssotoken.go new file mode 100644 index 00000000000..2831bca105b --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/apimanagementservice/method_getssotoken.go @@ -0,0 +1,52 @@ +package apimanagementservice + +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 GetSsoTokenOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ApiManagementServiceGetSsoTokenResult +} + +// GetSsoToken ... +func (c ApiManagementServiceClient) GetSsoToken(ctx context.Context, id ServiceId) (result GetSsoTokenOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/getssotoken", 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/apimanagement/2022-08-01/apimanagementservice/method_getssotoken_autorest.go b/resource-manager/apimanagement/2022-08-01/apimanagementservice/method_getssotoken_autorest.go deleted file mode 100644 index e66d5a4b465..00000000000 --- a/resource-manager/apimanagement/2022-08-01/apimanagementservice/method_getssotoken_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package apimanagementservice - -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 GetSsoTokenOperationResponse struct { - HttpResponse *http.Response - Model *ApiManagementServiceGetSsoTokenResult -} - -// GetSsoToken ... -func (c ApiManagementServiceClient) GetSsoToken(ctx context.Context, id ServiceId) (result GetSsoTokenOperationResponse, err error) { - req, err := c.preparerForGetSsoToken(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "apimanagementservice.ApiManagementServiceClient", "GetSsoToken", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apimanagementservice.ApiManagementServiceClient", "GetSsoToken", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetSsoToken(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apimanagementservice.ApiManagementServiceClient", "GetSsoToken", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetSsoToken prepares the GetSsoToken request. -func (c ApiManagementServiceClient) preparerForGetSsoToken(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.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/getssotoken", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetSsoToken handles the response to the GetSsoToken request. The method always -// closes the http.Response Body. -func (c ApiManagementServiceClient) responderForGetSsoToken(resp *http.Response) (result GetSsoTokenOperationResponse, 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/apimanagement/2022-08-01/apimanagementservice/method_list.go b/resource-manager/apimanagement/2022-08-01/apimanagementservice/method_list.go new file mode 100644 index 00000000000..2f75508ba8a --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/apimanagementservice/method_list.go @@ -0,0 +1,90 @@ +package apimanagementservice + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ApiManagementServiceResource +} + +type ListCompleteResult struct { + Items []ApiManagementServiceResource +} + +// List ... +func (c ApiManagementServiceClient) List(ctx context.Context, id commonids.SubscriptionId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.ApiManagement/service", 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 *[]ApiManagementServiceResource `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 ApiManagementServiceClient) ListComplete(ctx context.Context, id commonids.SubscriptionId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, ApiManagementServiceResourceOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ApiManagementServiceClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate ApiManagementServiceResourceOperationPredicate) (result ListCompleteResult, err error) { + items := make([]ApiManagementServiceResource, 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{ + Items: items, + } + return +} diff --git a/resource-manager/apimanagement/2022-08-01/apimanagementservice/method_list_autorest.go b/resource-manager/apimanagement/2022-08-01/apimanagementservice/method_list_autorest.go deleted file mode 100644 index bc98fce7338..00000000000 --- a/resource-manager/apimanagement/2022-08-01/apimanagementservice/method_list_autorest.go +++ /dev/null @@ -1,187 +0,0 @@ -package apimanagementservice - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListOperationResponse struct { - HttpResponse *http.Response - Model *[]ApiManagementServiceResource - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListOperationResponse, error) -} - -type ListCompleteResult struct { - Items []ApiManagementServiceResource -} - -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 ApiManagementServiceClient) List(ctx context.Context, id commonids.SubscriptionId) (resp ListOperationResponse, err error) { - req, err := c.preparerForList(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "apimanagementservice.ApiManagementServiceClient", "List", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apimanagementservice.ApiManagementServiceClient", "List", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForList(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apimanagementservice.ApiManagementServiceClient", "List", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForList prepares the List request. -func (c ApiManagementServiceClient) preparerForList(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.ApiManagement/service", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListWithNextLink prepares the List request with the given nextLink token. -func (c ApiManagementServiceClient) 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 ApiManagementServiceClient) responderForList(resp *http.Response) (result ListOperationResponse, err error) { - type page struct { - Values []ApiManagementServiceResource `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, "apimanagementservice.ApiManagementServiceClient", "List", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apimanagementservice.ApiManagementServiceClient", "List", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForList(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apimanagementservice.ApiManagementServiceClient", "List", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListComplete retrieves all of the results into a single object -func (c ApiManagementServiceClient) ListComplete(ctx context.Context, id commonids.SubscriptionId) (ListCompleteResult, error) { - return c.ListCompleteMatchingPredicate(ctx, id, ApiManagementServiceResourceOperationPredicate{}) -} - -// ListCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c ApiManagementServiceClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate ApiManagementServiceResourceOperationPredicate) (resp ListCompleteResult, err error) { - items := make([]ApiManagementServiceResource, 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/apimanagement/2022-08-01/apimanagementservice/method_listbyresourcegroup.go b/resource-manager/apimanagement/2022-08-01/apimanagementservice/method_listbyresourcegroup.go new file mode 100644 index 00000000000..46aadae6bda --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/apimanagementservice/method_listbyresourcegroup.go @@ -0,0 +1,90 @@ +package apimanagementservice + +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 *[]ApiManagementServiceResource +} + +type ListByResourceGroupCompleteResult struct { + Items []ApiManagementServiceResource +} + +// ListByResourceGroup ... +func (c ApiManagementServiceClient) 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.ApiManagement/service", 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 *[]ApiManagementServiceResource `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 ApiManagementServiceClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (ListByResourceGroupCompleteResult, error) { + return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, ApiManagementServiceResourceOperationPredicate{}) +} + +// ListByResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ApiManagementServiceClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate ApiManagementServiceResourceOperationPredicate) (result ListByResourceGroupCompleteResult, err error) { + items := make([]ApiManagementServiceResource, 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{ + Items: items, + } + return +} diff --git a/resource-manager/apimanagement/2022-08-01/apimanagementservice/method_listbyresourcegroup_autorest.go b/resource-manager/apimanagement/2022-08-01/apimanagementservice/method_listbyresourcegroup_autorest.go deleted file mode 100644 index f7776316529..00000000000 --- a/resource-manager/apimanagement/2022-08-01/apimanagementservice/method_listbyresourcegroup_autorest.go +++ /dev/null @@ -1,187 +0,0 @@ -package apimanagementservice - -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 *[]ApiManagementServiceResource - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListByResourceGroupOperationResponse, error) -} - -type ListByResourceGroupCompleteResult struct { - Items []ApiManagementServiceResource -} - -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 ApiManagementServiceClient) ListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (resp ListByResourceGroupOperationResponse, err error) { - req, err := c.preparerForListByResourceGroup(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "apimanagementservice.ApiManagementServiceClient", "ListByResourceGroup", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apimanagementservice.ApiManagementServiceClient", "ListByResourceGroup", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListByResourceGroup(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apimanagementservice.ApiManagementServiceClient", "ListByResourceGroup", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListByResourceGroup prepares the ListByResourceGroup request. -func (c ApiManagementServiceClient) 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.ApiManagement/service", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListByResourceGroupWithNextLink prepares the ListByResourceGroup request with the given nextLink token. -func (c ApiManagementServiceClient) 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 ApiManagementServiceClient) responderForListByResourceGroup(resp *http.Response) (result ListByResourceGroupOperationResponse, err error) { - type page struct { - Values []ApiManagementServiceResource `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, "apimanagementservice.ApiManagementServiceClient", "ListByResourceGroup", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apimanagementservice.ApiManagementServiceClient", "ListByResourceGroup", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByResourceGroup(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apimanagementservice.ApiManagementServiceClient", "ListByResourceGroup", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListByResourceGroupComplete retrieves all of the results into a single object -func (c ApiManagementServiceClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (ListByResourceGroupCompleteResult, error) { - return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, ApiManagementServiceResourceOperationPredicate{}) -} - -// ListByResourceGroupCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c ApiManagementServiceClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate ApiManagementServiceResourceOperationPredicate) (resp ListByResourceGroupCompleteResult, err error) { - items := make([]ApiManagementServiceResource, 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/apimanagement/2022-08-01/apimanagementservice/method_migratetostv2.go b/resource-manager/apimanagement/2022-08-01/apimanagementservice/method_migratetostv2.go new file mode 100644 index 00000000000..97feacb5423 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/apimanagementservice/method_migratetostv2.go @@ -0,0 +1,70 @@ +package apimanagementservice + +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 MigrateToStv2OperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// MigrateToStv2 ... +func (c ApiManagementServiceClient) MigrateToStv2(ctx context.Context, id ServiceId) (result MigrateToStv2OperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/migrateToStv2", 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 +} + +// MigrateToStv2ThenPoll performs MigrateToStv2 then polls until it's completed +func (c ApiManagementServiceClient) MigrateToStv2ThenPoll(ctx context.Context, id ServiceId) error { + result, err := c.MigrateToStv2(ctx, id) + if err != nil { + return fmt.Errorf("performing MigrateToStv2: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after MigrateToStv2: %+v", err) + } + + return nil +} diff --git a/resource-manager/apimanagement/2022-08-01/apimanagementservice/method_migratetostv2_autorest.go b/resource-manager/apimanagement/2022-08-01/apimanagementservice/method_migratetostv2_autorest.go deleted file mode 100644 index cd18295a0b2..00000000000 --- a/resource-manager/apimanagement/2022-08-01/apimanagementservice/method_migratetostv2_autorest.go +++ /dev/null @@ -1,78 +0,0 @@ -package apimanagementservice - -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 MigrateToStv2OperationResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// MigrateToStv2 ... -func (c ApiManagementServiceClient) MigrateToStv2(ctx context.Context, id ServiceId) (result MigrateToStv2OperationResponse, err error) { - req, err := c.preparerForMigrateToStv2(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "apimanagementservice.ApiManagementServiceClient", "MigrateToStv2", nil, "Failure preparing request") - return - } - - result, err = c.senderForMigrateToStv2(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "apimanagementservice.ApiManagementServiceClient", "MigrateToStv2", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// MigrateToStv2ThenPoll performs MigrateToStv2 then polls until it's completed -func (c ApiManagementServiceClient) MigrateToStv2ThenPoll(ctx context.Context, id ServiceId) error { - result, err := c.MigrateToStv2(ctx, id) - if err != nil { - return fmt.Errorf("performing MigrateToStv2: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after MigrateToStv2: %+v", err) - } - - return nil -} - -// preparerForMigrateToStv2 prepares the MigrateToStv2 request. -func (c ApiManagementServiceClient) preparerForMigrateToStv2(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.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/migrateToStv2", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForMigrateToStv2 sends the MigrateToStv2 request. The method will close the -// http.Response Body if it receives an error. -func (c ApiManagementServiceClient) senderForMigrateToStv2(ctx context.Context, req *http.Request) (future MigrateToStv2OperationResponse, 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/apimanagement/2022-08-01/apimanagementservice/method_restore.go b/resource-manager/apimanagement/2022-08-01/apimanagementservice/method_restore.go new file mode 100644 index 00000000000..5ea017b5905 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/apimanagementservice/method_restore.go @@ -0,0 +1,74 @@ +package apimanagementservice + +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 RestoreOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Restore ... +func (c ApiManagementServiceClient) Restore(ctx context.Context, id ServiceId, input ApiManagementServiceBackupRestoreParameters) (result RestoreOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/restore", 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 +} + +// RestoreThenPoll performs Restore then polls until it's completed +func (c ApiManagementServiceClient) RestoreThenPoll(ctx context.Context, id ServiceId, input ApiManagementServiceBackupRestoreParameters) error { + result, err := c.Restore(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Restore: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Restore: %+v", err) + } + + return nil +} diff --git a/resource-manager/apimanagement/2022-08-01/apimanagementservice/method_restore_autorest.go b/resource-manager/apimanagement/2022-08-01/apimanagementservice/method_restore_autorest.go deleted file mode 100644 index bb762b61349..00000000000 --- a/resource-manager/apimanagement/2022-08-01/apimanagementservice/method_restore_autorest.go +++ /dev/null @@ -1,79 +0,0 @@ -package apimanagementservice - -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 RestoreOperationResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// Restore ... -func (c ApiManagementServiceClient) Restore(ctx context.Context, id ServiceId, input ApiManagementServiceBackupRestoreParameters) (result RestoreOperationResponse, err error) { - req, err := c.preparerForRestore(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "apimanagementservice.ApiManagementServiceClient", "Restore", nil, "Failure preparing request") - return - } - - result, err = c.senderForRestore(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "apimanagementservice.ApiManagementServiceClient", "Restore", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// RestoreThenPoll performs Restore then polls until it's completed -func (c ApiManagementServiceClient) RestoreThenPoll(ctx context.Context, id ServiceId, input ApiManagementServiceBackupRestoreParameters) error { - result, err := c.Restore(ctx, id, input) - if err != nil { - return fmt.Errorf("performing Restore: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after Restore: %+v", err) - } - - return nil -} - -// preparerForRestore prepares the Restore request. -func (c ApiManagementServiceClient) preparerForRestore(ctx context.Context, id ServiceId, input ApiManagementServiceBackupRestoreParameters) (*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/restore", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForRestore sends the Restore request. The method will close the -// http.Response Body if it receives an error. -func (c ApiManagementServiceClient) senderForRestore(ctx context.Context, req *http.Request) (future RestoreOperationResponse, 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/apimanagement/2022-08-01/apimanagementservice/method_update.go b/resource-manager/apimanagement/2022-08-01/apimanagementservice/method_update.go new file mode 100644 index 00000000000..9a2e8907c9b --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/apimanagementservice/method_update.go @@ -0,0 +1,74 @@ +package apimanagementservice + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Update ... +func (c ApiManagementServiceClient) Update(ctx context.Context, id ServiceId, input ApiManagementServiceUpdateParameters) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// UpdateThenPoll performs Update then polls until it's completed +func (c ApiManagementServiceClient) UpdateThenPoll(ctx context.Context, id ServiceId, input ApiManagementServiceUpdateParameters) error { + result, err := c.Update(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Update: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Update: %+v", err) + } + + return nil +} diff --git a/resource-manager/apimanagement/2022-08-01/apimanagementservice/method_update_autorest.go b/resource-manager/apimanagement/2022-08-01/apimanagementservice/method_update_autorest.go deleted file mode 100644 index c4047579231..00000000000 --- a/resource-manager/apimanagement/2022-08-01/apimanagementservice/method_update_autorest.go +++ /dev/null @@ -1,79 +0,0 @@ -package apimanagementservice - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type UpdateOperationResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// Update ... -func (c ApiManagementServiceClient) Update(ctx context.Context, id ServiceId, input ApiManagementServiceUpdateParameters) (result UpdateOperationResponse, err error) { - req, err := c.preparerForUpdate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "apimanagementservice.ApiManagementServiceClient", "Update", nil, "Failure preparing request") - return - } - - result, err = c.senderForUpdate(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "apimanagementservice.ApiManagementServiceClient", "Update", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// UpdateThenPoll performs Update then polls until it's completed -func (c ApiManagementServiceClient) UpdateThenPoll(ctx context.Context, id ServiceId, input ApiManagementServiceUpdateParameters) error { - result, err := c.Update(ctx, id, input) - if err != nil { - return fmt.Errorf("performing Update: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after Update: %+v", err) - } - - return nil -} - -// preparerForUpdate prepares the Update request. -func (c ApiManagementServiceClient) preparerForUpdate(ctx context.Context, id ServiceId, input ApiManagementServiceUpdateParameters) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPatch(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForUpdate sends the Update request. The method will close the -// http.Response Body if it receives an error. -func (c ApiManagementServiceClient) senderForUpdate(ctx context.Context, req *http.Request) (future UpdateOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/apimanagement/2022-08-01/apimanagementserviceskus/client.go b/resource-manager/apimanagement/2022-08-01/apimanagementserviceskus/client.go index eb6747c1e12..1ce06d88a72 100644 --- a/resource-manager/apimanagement/2022-08-01/apimanagementserviceskus/client.go +++ b/resource-manager/apimanagement/2022-08-01/apimanagementserviceskus/client.go @@ -1,18 +1,26 @@ package apimanagementserviceskus -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 ApiManagementServiceSkusClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewApiManagementServiceSkusClientWithBaseURI(endpoint string) ApiManagementServiceSkusClient { - return ApiManagementServiceSkusClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewApiManagementServiceSkusClientWithBaseURI(api environments.Api) (*ApiManagementServiceSkusClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "apimanagementserviceskus", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ApiManagementServiceSkusClient: %+v", err) } + + return &ApiManagementServiceSkusClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2022-08-01/apimanagementserviceskus/constants.go b/resource-manager/apimanagement/2022-08-01/apimanagementserviceskus/constants.go index d5d2b9ea3eb..d9e2bd19e1c 100644 --- a/resource-manager/apimanagement/2022-08-01/apimanagementserviceskus/constants.go +++ b/resource-manager/apimanagement/2022-08-01/apimanagementserviceskus/constants.go @@ -1,6 +1,10 @@ package apimanagementserviceskus -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 PossibleValuesForResourceSkuCapacityScaleType() []string { } } +func (s *ResourceSkuCapacityScaleType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseResourceSkuCapacityScaleType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseResourceSkuCapacityScaleType(input string) (*ResourceSkuCapacityScaleType, error) { vals := map[string]ResourceSkuCapacityScaleType{ "automatic": ResourceSkuCapacityScaleTypeAutomatic, @@ -58,6 +75,19 @@ func PossibleValuesForSkuType() []string { } } +func (s *SkuType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSkuType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseSkuType(input string) (*SkuType, error) { vals := map[string]SkuType{ "basic": SkuTypeBasic, diff --git a/resource-manager/apimanagement/2022-08-01/apimanagementserviceskus/method_listavailableserviceskus.go b/resource-manager/apimanagement/2022-08-01/apimanagementserviceskus/method_listavailableserviceskus.go new file mode 100644 index 00000000000..afe8ea5af07 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/apimanagementserviceskus/method_listavailableserviceskus.go @@ -0,0 +1,89 @@ +package apimanagementserviceskus + +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 ListAvailableServiceSkusOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ResourceSkuResult +} + +type ListAvailableServiceSkusCompleteResult struct { + Items []ResourceSkuResult +} + +// ListAvailableServiceSkus ... +func (c ApiManagementServiceSkusClient) ListAvailableServiceSkus(ctx context.Context, id ServiceId) (result ListAvailableServiceSkusOperationResponse, 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 *[]ResourceSkuResult `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListAvailableServiceSkusComplete retrieves all the results into a single object +func (c ApiManagementServiceSkusClient) ListAvailableServiceSkusComplete(ctx context.Context, id ServiceId) (ListAvailableServiceSkusCompleteResult, error) { + return c.ListAvailableServiceSkusCompleteMatchingPredicate(ctx, id, ResourceSkuResultOperationPredicate{}) +} + +// ListAvailableServiceSkusCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ApiManagementServiceSkusClient) ListAvailableServiceSkusCompleteMatchingPredicate(ctx context.Context, id ServiceId, predicate ResourceSkuResultOperationPredicate) (result ListAvailableServiceSkusCompleteResult, err error) { + items := make([]ResourceSkuResult, 0) + + resp, err := c.ListAvailableServiceSkus(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 = ListAvailableServiceSkusCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/apimanagement/2022-08-01/apimanagementserviceskus/method_listavailableserviceskus_autorest.go b/resource-manager/apimanagement/2022-08-01/apimanagementserviceskus/method_listavailableserviceskus_autorest.go deleted file mode 100644 index f5aa634c623..00000000000 --- a/resource-manager/apimanagement/2022-08-01/apimanagementserviceskus/method_listavailableserviceskus_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package apimanagementserviceskus - -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 ListAvailableServiceSkusOperationResponse struct { - HttpResponse *http.Response - Model *[]ResourceSkuResult - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListAvailableServiceSkusOperationResponse, error) -} - -type ListAvailableServiceSkusCompleteResult struct { - Items []ResourceSkuResult -} - -func (r ListAvailableServiceSkusOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListAvailableServiceSkusOperationResponse) LoadMore(ctx context.Context) (resp ListAvailableServiceSkusOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListAvailableServiceSkus ... -func (c ApiManagementServiceSkusClient) ListAvailableServiceSkus(ctx context.Context, id ServiceId) (resp ListAvailableServiceSkusOperationResponse, err error) { - req, err := c.preparerForListAvailableServiceSkus(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "apimanagementserviceskus.ApiManagementServiceSkusClient", "ListAvailableServiceSkus", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apimanagementserviceskus.ApiManagementServiceSkusClient", "ListAvailableServiceSkus", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListAvailableServiceSkus(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apimanagementserviceskus.ApiManagementServiceSkusClient", "ListAvailableServiceSkus", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListAvailableServiceSkus prepares the ListAvailableServiceSkus request. -func (c ApiManagementServiceSkusClient) preparerForListAvailableServiceSkus(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(fmt.Sprintf("%s/skus", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListAvailableServiceSkusWithNextLink prepares the ListAvailableServiceSkus request with the given nextLink token. -func (c ApiManagementServiceSkusClient) preparerForListAvailableServiceSkusWithNextLink(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)) -} - -// responderForListAvailableServiceSkus handles the response to the ListAvailableServiceSkus request. The method always -// closes the http.Response Body. -func (c ApiManagementServiceSkusClient) responderForListAvailableServiceSkus(resp *http.Response) (result ListAvailableServiceSkusOperationResponse, err error) { - type page struct { - Values []ResourceSkuResult `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 ListAvailableServiceSkusOperationResponse, err error) { - req, err := c.preparerForListAvailableServiceSkusWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "apimanagementserviceskus.ApiManagementServiceSkusClient", "ListAvailableServiceSkus", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apimanagementserviceskus.ApiManagementServiceSkusClient", "ListAvailableServiceSkus", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListAvailableServiceSkus(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apimanagementserviceskus.ApiManagementServiceSkusClient", "ListAvailableServiceSkus", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListAvailableServiceSkusComplete retrieves all of the results into a single object -func (c ApiManagementServiceSkusClient) ListAvailableServiceSkusComplete(ctx context.Context, id ServiceId) (ListAvailableServiceSkusCompleteResult, error) { - return c.ListAvailableServiceSkusCompleteMatchingPredicate(ctx, id, ResourceSkuResultOperationPredicate{}) -} - -// ListAvailableServiceSkusCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c ApiManagementServiceSkusClient) ListAvailableServiceSkusCompleteMatchingPredicate(ctx context.Context, id ServiceId, predicate ResourceSkuResultOperationPredicate) (resp ListAvailableServiceSkusCompleteResult, err error) { - items := make([]ResourceSkuResult, 0) - - page, err := c.ListAvailableServiceSkus(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 := ListAvailableServiceSkusCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/apimanagement/2022-08-01/apioperation/client.go b/resource-manager/apimanagement/2022-08-01/apioperation/client.go index f4e640e1356..3385359b614 100644 --- a/resource-manager/apimanagement/2022-08-01/apioperation/client.go +++ b/resource-manager/apimanagement/2022-08-01/apioperation/client.go @@ -1,18 +1,26 @@ package apioperation -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 ApiOperationClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewApiOperationClientWithBaseURI(endpoint string) ApiOperationClient { - return ApiOperationClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewApiOperationClientWithBaseURI(api environments.Api) (*ApiOperationClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "apioperation", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ApiOperationClient: %+v", err) } + + return &ApiOperationClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2022-08-01/apioperation/method_createorupdate.go b/resource-manager/apimanagement/2022-08-01/apioperation/method_createorupdate.go new file mode 100644 index 00000000000..6dc046e355f --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/apioperation/method_createorupdate.go @@ -0,0 +1,85 @@ +package apioperation + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *OperationContract +} + +type CreateOrUpdateOperationOptions struct { + IfMatch *string +} + +func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { + return CreateOrUpdateOperationOptions{} +} + +func (o CreateOrUpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o CreateOrUpdateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o CreateOrUpdateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// CreateOrUpdate ... +func (c ApiOperationClient) CreateOrUpdate(ctx context.Context, id OperationId, input OperationContract, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + OptionsObject: options, + } + + 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/apimanagement/2022-08-01/apioperation/method_createorupdate_autorest.go b/resource-manager/apimanagement/2022-08-01/apioperation/method_createorupdate_autorest.go deleted file mode 100644 index 248feffbbb9..00000000000 --- a/resource-manager/apimanagement/2022-08-01/apioperation/method_createorupdate_autorest.go +++ /dev/null @@ -1,98 +0,0 @@ -package apioperation - -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 *OperationContract -} - -type CreateOrUpdateOperationOptions struct { - IfMatch *string -} - -func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { - return CreateOrUpdateOperationOptions{} -} - -func (o CreateOrUpdateOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o CreateOrUpdateOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// CreateOrUpdate ... -func (c ApiOperationClient) CreateOrUpdate(ctx context.Context, id OperationId, input OperationContract, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdate(ctx, id, input, options) - if err != nil { - err = autorest.NewErrorWithError(err, "apioperation.ApiOperationClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apioperation.ApiOperationClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCreateOrUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apioperation.ApiOperationClient", "CreateOrUpdate", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCreateOrUpdate prepares the CreateOrUpdate request. -func (c ApiOperationClient) preparerForCreateOrUpdate(ctx context.Context, id OperationId, input OperationContract, options CreateOrUpdateOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - 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 ApiOperationClient) responderForCreateOrUpdate(resp *http.Response) (result CreateOrUpdateOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2022-08-01/apioperation/method_delete.go b/resource-manager/apimanagement/2022-08-01/apioperation/method_delete.go new file mode 100644 index 00000000000..0693a0a284f --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/apioperation/method_delete.go @@ -0,0 +1,76 @@ +package apioperation + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +type DeleteOperationOptions struct { + IfMatch *string +} + +func DefaultDeleteOperationOptions() DeleteOperationOptions { + return DeleteOperationOptions{} +} + +func (o DeleteOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o DeleteOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o DeleteOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// Delete ... +func (c ApiOperationClient) Delete(ctx context.Context, id OperationId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2022-08-01/apioperation/method_delete_autorest.go b/resource-manager/apimanagement/2022-08-01/apioperation/method_delete_autorest.go deleted file mode 100644 index 6a968ca42c0..00000000000 --- a/resource-manager/apimanagement/2022-08-01/apioperation/method_delete_autorest.go +++ /dev/null @@ -1,95 +0,0 @@ -package apioperation - -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 DeleteOperationResponse struct { - HttpResponse *http.Response -} - -type DeleteOperationOptions struct { - IfMatch *string -} - -func DefaultDeleteOperationOptions() DeleteOperationOptions { - return DeleteOperationOptions{} -} - -func (o DeleteOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o DeleteOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// Delete ... -func (c ApiOperationClient) Delete(ctx context.Context, id OperationId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { - req, err := c.preparerForDelete(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "apioperation.ApiOperationClient", "Delete", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apioperation.ApiOperationClient", "Delete", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForDelete(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apioperation.ApiOperationClient", "Delete", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForDelete prepares the Delete request. -func (c ApiOperationClient) preparerForDelete(ctx context.Context, id OperationId, options DeleteOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForDelete handles the response to the Delete request. The method always -// closes the http.Response Body. -func (c ApiOperationClient) responderForDelete(resp *http.Response) (result DeleteOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2022-08-01/apioperation/method_get.go b/resource-manager/apimanagement/2022-08-01/apioperation/method_get.go new file mode 100644 index 00000000000..d5786d5ae91 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/apioperation/method_get.go @@ -0,0 +1,51 @@ +package apioperation + +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 *OperationContract +} + +// Get ... +func (c ApiOperationClient) Get(ctx context.Context, id OperationId) (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/apimanagement/2022-08-01/apioperation/method_get_autorest.go b/resource-manager/apimanagement/2022-08-01/apioperation/method_get_autorest.go deleted file mode 100644 index 71209f67ea1..00000000000 --- a/resource-manager/apimanagement/2022-08-01/apioperation/method_get_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package apioperation - -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 *OperationContract -} - -// Get ... -func (c ApiOperationClient) Get(ctx context.Context, id OperationId) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "apioperation.ApiOperationClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apioperation.ApiOperationClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apioperation.ApiOperationClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c ApiOperationClient) preparerForGet(ctx context.Context, id OperationId) (*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 ApiOperationClient) 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/apimanagement/2022-08-01/apioperation/method_getentitytag.go b/resource-manager/apimanagement/2022-08-01/apioperation/method_getentitytag.go new file mode 100644 index 00000000000..520a7b92e36 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/apioperation/method_getentitytag.go @@ -0,0 +1,46 @@ +package apioperation + +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 GetEntityTagOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// GetEntityTag ... +func (c ApiOperationClient) GetEntityTag(ctx context.Context, id OperationId) (result GetEntityTagOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodHead, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2022-08-01/apioperation/method_getentitytag_autorest.go b/resource-manager/apimanagement/2022-08-01/apioperation/method_getentitytag_autorest.go deleted file mode 100644 index fbf38551a9a..00000000000 --- a/resource-manager/apimanagement/2022-08-01/apioperation/method_getentitytag_autorest.go +++ /dev/null @@ -1,66 +0,0 @@ -package apioperation - -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 GetEntityTagOperationResponse struct { - HttpResponse *http.Response -} - -// GetEntityTag ... -func (c ApiOperationClient) GetEntityTag(ctx context.Context, id OperationId) (result GetEntityTagOperationResponse, err error) { - req, err := c.preparerForGetEntityTag(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "apioperation.ApiOperationClient", "GetEntityTag", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apioperation.ApiOperationClient", "GetEntityTag", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetEntityTag(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apioperation.ApiOperationClient", "GetEntityTag", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetEntityTag prepares the GetEntityTag request. -func (c ApiOperationClient) preparerForGetEntityTag(ctx context.Context, id OperationId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsHead(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetEntityTag handles the response to the GetEntityTag request. The method always -// closes the http.Response Body. -func (c ApiOperationClient) responderForGetEntityTag(resp *http.Response) (result GetEntityTagOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2022-08-01/apioperation/method_listbyapi.go b/resource-manager/apimanagement/2022-08-01/apioperation/method_listbyapi.go new file mode 100644 index 00000000000..5620f8b7c3e --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/apioperation/method_listbyapi.go @@ -0,0 +1,129 @@ +package apioperation + +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 ListByApiOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]OperationContract +} + +type ListByApiCompleteResult struct { + Items []OperationContract +} + +type ListByApiOperationOptions struct { + Filter *string + Skip *int64 + Tags *string + Top *int64 +} + +func DefaultListByApiOperationOptions() ListByApiOperationOptions { + return ListByApiOperationOptions{} +} + +func (o ListByApiOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListByApiOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListByApiOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.Skip != nil { + out.Append("$skip", fmt.Sprintf("%v", *o.Skip)) + } + if o.Tags != nil { + out.Append("tags", fmt.Sprintf("%v", *o.Tags)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +// ListByApi ... +func (c ApiOperationClient) ListByApi(ctx context.Context, id ApiId, options ListByApiOperationOptions) (result ListByApiOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/operations", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]OperationContract `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByApiComplete retrieves all the results into a single object +func (c ApiOperationClient) ListByApiComplete(ctx context.Context, id ApiId, options ListByApiOperationOptions) (ListByApiCompleteResult, error) { + return c.ListByApiCompleteMatchingPredicate(ctx, id, options, OperationContractOperationPredicate{}) +} + +// ListByApiCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ApiOperationClient) ListByApiCompleteMatchingPredicate(ctx context.Context, id ApiId, options ListByApiOperationOptions, predicate OperationContractOperationPredicate) (result ListByApiCompleteResult, err error) { + items := make([]OperationContract, 0) + + resp, err := c.ListByApi(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByApiCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/apimanagement/2022-08-01/apioperation/method_listbyapi_autorest.go b/resource-manager/apimanagement/2022-08-01/apioperation/method_listbyapi_autorest.go deleted file mode 100644 index 081748611d8..00000000000 --- a/resource-manager/apimanagement/2022-08-01/apioperation/method_listbyapi_autorest.go +++ /dev/null @@ -1,230 +0,0 @@ -package apioperation - -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 ListByApiOperationResponse struct { - HttpResponse *http.Response - Model *[]OperationContract - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListByApiOperationResponse, error) -} - -type ListByApiCompleteResult struct { - Items []OperationContract -} - -func (r ListByApiOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListByApiOperationResponse) LoadMore(ctx context.Context) (resp ListByApiOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -type ListByApiOperationOptions struct { - Filter *string - Skip *int64 - Tags *string - Top *int64 -} - -func DefaultListByApiOperationOptions() ListByApiOperationOptions { - return ListByApiOperationOptions{} -} - -func (o ListByApiOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o ListByApiOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Filter != nil { - out["$filter"] = *o.Filter - } - - if o.Skip != nil { - out["$skip"] = *o.Skip - } - - if o.Tags != nil { - out["tags"] = *o.Tags - } - - if o.Top != nil { - out["$top"] = *o.Top - } - - return out -} - -// ListByApi ... -func (c ApiOperationClient) ListByApi(ctx context.Context, id ApiId, options ListByApiOperationOptions) (resp ListByApiOperationResponse, err error) { - req, err := c.preparerForListByApi(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "apioperation.ApiOperationClient", "ListByApi", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apioperation.ApiOperationClient", "ListByApi", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListByApi(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apioperation.ApiOperationClient", "ListByApi", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListByApi prepares the ListByApi request. -func (c ApiOperationClient) preparerForListByApi(ctx context.Context, id ApiId, options ListByApiOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/operations", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListByApiWithNextLink prepares the ListByApi request with the given nextLink token. -func (c ApiOperationClient) preparerForListByApiWithNextLink(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)) -} - -// responderForListByApi handles the response to the ListByApi request. The method always -// closes the http.Response Body. -func (c ApiOperationClient) responderForListByApi(resp *http.Response) (result ListByApiOperationResponse, err error) { - type page struct { - Values []OperationContract `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 ListByApiOperationResponse, err error) { - req, err := c.preparerForListByApiWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "apioperation.ApiOperationClient", "ListByApi", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apioperation.ApiOperationClient", "ListByApi", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByApi(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apioperation.ApiOperationClient", "ListByApi", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListByApiComplete retrieves all of the results into a single object -func (c ApiOperationClient) ListByApiComplete(ctx context.Context, id ApiId, options ListByApiOperationOptions) (ListByApiCompleteResult, error) { - return c.ListByApiCompleteMatchingPredicate(ctx, id, options, OperationContractOperationPredicate{}) -} - -// ListByApiCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c ApiOperationClient) ListByApiCompleteMatchingPredicate(ctx context.Context, id ApiId, options ListByApiOperationOptions, predicate OperationContractOperationPredicate) (resp ListByApiCompleteResult, err error) { - items := make([]OperationContract, 0) - - page, err := c.ListByApi(ctx, id, options) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListByApiCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/apimanagement/2022-08-01/apioperation/method_update.go b/resource-manager/apimanagement/2022-08-01/apioperation/method_update.go new file mode 100644 index 00000000000..9b215cf692d --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/apioperation/method_update.go @@ -0,0 +1,84 @@ +package apioperation + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *OperationContract +} + +type UpdateOperationOptions struct { + IfMatch *string +} + +func DefaultUpdateOperationOptions() UpdateOperationOptions { + return UpdateOperationOptions{} +} + +func (o UpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o UpdateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o UpdateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// Update ... +func (c ApiOperationClient) Update(ctx context.Context, id OperationId, input OperationUpdateContract, options UpdateOperationOptions) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + OptionsObject: options, + } + + 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/apimanagement/2022-08-01/apioperation/method_update_autorest.go b/resource-manager/apimanagement/2022-08-01/apioperation/method_update_autorest.go deleted file mode 100644 index 753e7e9c090..00000000000 --- a/resource-manager/apimanagement/2022-08-01/apioperation/method_update_autorest.go +++ /dev/null @@ -1,98 +0,0 @@ -package apioperation - -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 *OperationContract -} - -type UpdateOperationOptions struct { - IfMatch *string -} - -func DefaultUpdateOperationOptions() UpdateOperationOptions { - return UpdateOperationOptions{} -} - -func (o UpdateOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o UpdateOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// Update ... -func (c ApiOperationClient) Update(ctx context.Context, id OperationId, input OperationUpdateContract, options UpdateOperationOptions) (result UpdateOperationResponse, err error) { - req, err := c.preparerForUpdate(ctx, id, input, options) - if err != nil { - err = autorest.NewErrorWithError(err, "apioperation.ApiOperationClient", "Update", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apioperation.ApiOperationClient", "Update", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apioperation.ApiOperationClient", "Update", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForUpdate prepares the Update request. -func (c ApiOperationClient) preparerForUpdate(ctx context.Context, id OperationId, input OperationUpdateContract, options UpdateOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPatch(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - 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 ApiOperationClient) 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/apimanagement/2022-08-01/apioperationpolicy/client.go b/resource-manager/apimanagement/2022-08-01/apioperationpolicy/client.go index 263cb368c90..4c6534acec8 100644 --- a/resource-manager/apimanagement/2022-08-01/apioperationpolicy/client.go +++ b/resource-manager/apimanagement/2022-08-01/apioperationpolicy/client.go @@ -1,18 +1,26 @@ package apioperationpolicy -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 ApiOperationPolicyClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewApiOperationPolicyClientWithBaseURI(endpoint string) ApiOperationPolicyClient { - return ApiOperationPolicyClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewApiOperationPolicyClientWithBaseURI(api environments.Api) (*ApiOperationPolicyClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "apioperationpolicy", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ApiOperationPolicyClient: %+v", err) } + + return &ApiOperationPolicyClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2022-08-01/apioperationpolicy/constants.go b/resource-manager/apimanagement/2022-08-01/apioperationpolicy/constants.go index c8bec979994..5a4b902d0cf 100644 --- a/resource-manager/apimanagement/2022-08-01/apioperationpolicy/constants.go +++ b/resource-manager/apimanagement/2022-08-01/apioperationpolicy/constants.go @@ -1,6 +1,10 @@ package apioperationpolicy -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 PossibleValuesForPolicyContentFormat() []string { } } +func (s *PolicyContentFormat) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePolicyContentFormat(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parsePolicyContentFormat(input string) (*PolicyContentFormat, error) { vals := map[string]PolicyContentFormat{ "rawxml": PolicyContentFormatRawxml, @@ -53,6 +70,19 @@ func PossibleValuesForPolicyExportFormat() []string { } } +func (s *PolicyExportFormat) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePolicyExportFormat(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parsePolicyExportFormat(input string) (*PolicyExportFormat, error) { vals := map[string]PolicyExportFormat{ "rawxml": PolicyExportFormatRawxml, diff --git a/resource-manager/apimanagement/2022-08-01/apioperationpolicy/method_createorupdate.go b/resource-manager/apimanagement/2022-08-01/apioperationpolicy/method_createorupdate.go new file mode 100644 index 00000000000..a25fdb2042e --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/apioperationpolicy/method_createorupdate.go @@ -0,0 +1,85 @@ +package apioperationpolicy + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PolicyContract +} + +type CreateOrUpdateOperationOptions struct { + IfMatch *string +} + +func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { + return CreateOrUpdateOperationOptions{} +} + +func (o CreateOrUpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o CreateOrUpdateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o CreateOrUpdateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// CreateOrUpdate ... +func (c ApiOperationPolicyClient) CreateOrUpdate(ctx context.Context, id OperationId, input PolicyContract, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/policies/policy", id.ID()), + OptionsObject: options, + } + + 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/apimanagement/2022-08-01/apioperationpolicy/method_createorupdate_autorest.go b/resource-manager/apimanagement/2022-08-01/apioperationpolicy/method_createorupdate_autorest.go deleted file mode 100644 index ab93439da2b..00000000000 --- a/resource-manager/apimanagement/2022-08-01/apioperationpolicy/method_createorupdate_autorest.go +++ /dev/null @@ -1,99 +0,0 @@ -package apioperationpolicy - -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 CreateOrUpdateOperationResponse struct { - HttpResponse *http.Response - Model *PolicyContract -} - -type CreateOrUpdateOperationOptions struct { - IfMatch *string -} - -func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { - return CreateOrUpdateOperationOptions{} -} - -func (o CreateOrUpdateOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o CreateOrUpdateOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// CreateOrUpdate ... -func (c ApiOperationPolicyClient) CreateOrUpdate(ctx context.Context, id OperationId, input PolicyContract, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdate(ctx, id, input, options) - if err != nil { - err = autorest.NewErrorWithError(err, "apioperationpolicy.ApiOperationPolicyClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apioperationpolicy.ApiOperationPolicyClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCreateOrUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apioperationpolicy.ApiOperationPolicyClient", "CreateOrUpdate", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCreateOrUpdate prepares the CreateOrUpdate request. -func (c ApiOperationPolicyClient) preparerForCreateOrUpdate(ctx context.Context, id OperationId, input PolicyContract, options CreateOrUpdateOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/policies/policy", 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 ApiOperationPolicyClient) responderForCreateOrUpdate(resp *http.Response) (result CreateOrUpdateOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2022-08-01/apioperationpolicy/method_delete.go b/resource-manager/apimanagement/2022-08-01/apioperationpolicy/method_delete.go new file mode 100644 index 00000000000..f30d7d3e932 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/apioperationpolicy/method_delete.go @@ -0,0 +1,76 @@ +package apioperationpolicy + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +type DeleteOperationOptions struct { + IfMatch *string +} + +func DefaultDeleteOperationOptions() DeleteOperationOptions { + return DeleteOperationOptions{} +} + +func (o DeleteOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o DeleteOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o DeleteOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// Delete ... +func (c ApiOperationPolicyClient) Delete(ctx context.Context, id OperationId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: fmt.Sprintf("%s/policies/policy", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2022-08-01/apioperationpolicy/method_delete_autorest.go b/resource-manager/apimanagement/2022-08-01/apioperationpolicy/method_delete_autorest.go deleted file mode 100644 index cb4dd35c12f..00000000000 --- a/resource-manager/apimanagement/2022-08-01/apioperationpolicy/method_delete_autorest.go +++ /dev/null @@ -1,96 +0,0 @@ -package apioperationpolicy - -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 DeleteOperationResponse struct { - HttpResponse *http.Response -} - -type DeleteOperationOptions struct { - IfMatch *string -} - -func DefaultDeleteOperationOptions() DeleteOperationOptions { - return DeleteOperationOptions{} -} - -func (o DeleteOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o DeleteOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// Delete ... -func (c ApiOperationPolicyClient) Delete(ctx context.Context, id OperationId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { - req, err := c.preparerForDelete(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "apioperationpolicy.ApiOperationPolicyClient", "Delete", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apioperationpolicy.ApiOperationPolicyClient", "Delete", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForDelete(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apioperationpolicy.ApiOperationPolicyClient", "Delete", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForDelete prepares the Delete request. -func (c ApiOperationPolicyClient) preparerForDelete(ctx context.Context, id OperationId, options DeleteOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/policies/policy", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForDelete handles the response to the Delete request. The method always -// closes the http.Response Body. -func (c ApiOperationPolicyClient) responderForDelete(resp *http.Response) (result DeleteOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2022-08-01/apioperationpolicy/method_get.go b/resource-manager/apimanagement/2022-08-01/apioperationpolicy/method_get.go new file mode 100644 index 00000000000..62c2e626268 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/apioperationpolicy/method_get.go @@ -0,0 +1,80 @@ +package apioperationpolicy + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PolicyContract +} + +type GetOperationOptions struct { + Format *PolicyExportFormat +} + +func DefaultGetOperationOptions() GetOperationOptions { + return GetOperationOptions{} +} + +func (o GetOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o GetOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o GetOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Format != nil { + out.Append("format", fmt.Sprintf("%v", *o.Format)) + } + return &out +} + +// Get ... +func (c ApiOperationPolicyClient) Get(ctx context.Context, id OperationId, options GetOperationOptions) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/policies/policy", id.ID()), + OptionsObject: options, + } + + 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/apimanagement/2022-08-01/apioperationpolicy/method_get_autorest.go b/resource-manager/apimanagement/2022-08-01/apioperationpolicy/method_get_autorest.go deleted file mode 100644 index 8016e93dbbe..00000000000 --- a/resource-manager/apimanagement/2022-08-01/apioperationpolicy/method_get_autorest.go +++ /dev/null @@ -1,98 +0,0 @@ -package apioperationpolicy - -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 GetOperationResponse struct { - HttpResponse *http.Response - Model *PolicyContract -} - -type GetOperationOptions struct { - Format *PolicyExportFormat -} - -func DefaultGetOperationOptions() GetOperationOptions { - return GetOperationOptions{} -} - -func (o GetOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o GetOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Format != nil { - out["format"] = *o.Format - } - - return out -} - -// Get ... -func (c ApiOperationPolicyClient) Get(ctx context.Context, id OperationId, options GetOperationOptions) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "apioperationpolicy.ApiOperationPolicyClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apioperationpolicy.ApiOperationPolicyClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apioperationpolicy.ApiOperationPolicyClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c ApiOperationPolicyClient) preparerForGet(ctx context.Context, id OperationId, options GetOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/policies/policy", 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 ApiOperationPolicyClient) 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/apimanagement/2022-08-01/apioperationpolicy/method_getentitytag.go b/resource-manager/apimanagement/2022-08-01/apioperationpolicy/method_getentitytag.go new file mode 100644 index 00000000000..88da95a1537 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/apioperationpolicy/method_getentitytag.go @@ -0,0 +1,47 @@ +package apioperationpolicy + +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 GetEntityTagOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// GetEntityTag ... +func (c ApiOperationPolicyClient) GetEntityTag(ctx context.Context, id OperationId) (result GetEntityTagOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodHead, + Path: fmt.Sprintf("%s/policies/policy", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2022-08-01/apioperationpolicy/method_getentitytag_autorest.go b/resource-manager/apimanagement/2022-08-01/apioperationpolicy/method_getentitytag_autorest.go deleted file mode 100644 index 694655ef4b7..00000000000 --- a/resource-manager/apimanagement/2022-08-01/apioperationpolicy/method_getentitytag_autorest.go +++ /dev/null @@ -1,67 +0,0 @@ -package apioperationpolicy - -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 GetEntityTagOperationResponse struct { - HttpResponse *http.Response -} - -// GetEntityTag ... -func (c ApiOperationPolicyClient) GetEntityTag(ctx context.Context, id OperationId) (result GetEntityTagOperationResponse, err error) { - req, err := c.preparerForGetEntityTag(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "apioperationpolicy.ApiOperationPolicyClient", "GetEntityTag", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apioperationpolicy.ApiOperationPolicyClient", "GetEntityTag", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetEntityTag(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apioperationpolicy.ApiOperationPolicyClient", "GetEntityTag", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetEntityTag prepares the GetEntityTag request. -func (c ApiOperationPolicyClient) preparerForGetEntityTag(ctx context.Context, id OperationId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsHead(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/policies/policy", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetEntityTag handles the response to the GetEntityTag request. The method always -// closes the http.Response Body. -func (c ApiOperationPolicyClient) responderForGetEntityTag(resp *http.Response) (result GetEntityTagOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2022-08-01/apioperationpolicy/method_listbyoperation.go b/resource-manager/apimanagement/2022-08-01/apioperationpolicy/method_listbyoperation.go new file mode 100644 index 00000000000..0f79c48d5fe --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/apioperationpolicy/method_listbyoperation.go @@ -0,0 +1,52 @@ +package apioperationpolicy + +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 ListByOperationOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PolicyCollection +} + +// ListByOperation ... +func (c ApiOperationPolicyClient) ListByOperation(ctx context.Context, id OperationId) (result ListByOperationOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/policies", 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/apimanagement/2022-08-01/apioperationpolicy/method_listbyoperation_autorest.go b/resource-manager/apimanagement/2022-08-01/apioperationpolicy/method_listbyoperation_autorest.go deleted file mode 100644 index 65975e5077b..00000000000 --- a/resource-manager/apimanagement/2022-08-01/apioperationpolicy/method_listbyoperation_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package apioperationpolicy - -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 ListByOperationOperationResponse struct { - HttpResponse *http.Response - Model *PolicyCollection -} - -// ListByOperation ... -func (c ApiOperationPolicyClient) ListByOperation(ctx context.Context, id OperationId) (result ListByOperationOperationResponse, err error) { - req, err := c.preparerForListByOperation(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "apioperationpolicy.ApiOperationPolicyClient", "ListByOperation", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apioperationpolicy.ApiOperationPolicyClient", "ListByOperation", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByOperation(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apioperationpolicy.ApiOperationPolicyClient", "ListByOperation", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForListByOperation prepares the ListByOperation request. -func (c ApiOperationPolicyClient) preparerForListByOperation(ctx context.Context, id OperationId) (*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/policies", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListByOperation handles the response to the ListByOperation request. The method always -// closes the http.Response Body. -func (c ApiOperationPolicyClient) responderForListByOperation(resp *http.Response) (result ListByOperationOperationResponse, 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/apimanagement/2022-08-01/apioperationsbytag/client.go b/resource-manager/apimanagement/2022-08-01/apioperationsbytag/client.go index 48716e67800..2cae8f256da 100644 --- a/resource-manager/apimanagement/2022-08-01/apioperationsbytag/client.go +++ b/resource-manager/apimanagement/2022-08-01/apioperationsbytag/client.go @@ -1,18 +1,26 @@ package apioperationsbytag -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 ApiOperationsByTagClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewApiOperationsByTagClientWithBaseURI(endpoint string) ApiOperationsByTagClient { - return ApiOperationsByTagClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewApiOperationsByTagClientWithBaseURI(api environments.Api) (*ApiOperationsByTagClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "apioperationsbytag", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ApiOperationsByTagClient: %+v", err) } + + return &ApiOperationsByTagClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2022-08-01/apioperationsbytag/constants.go b/resource-manager/apimanagement/2022-08-01/apioperationsbytag/constants.go index 7a4b9772ad9..c0f30b87134 100644 --- a/resource-manager/apimanagement/2022-08-01/apioperationsbytag/constants.go +++ b/resource-manager/apimanagement/2022-08-01/apioperationsbytag/constants.go @@ -1,6 +1,10 @@ package apioperationsbytag -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 PossibleValuesForApiType() []string { } } +func (s *ApiType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseApiType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseApiType(input string) (*ApiType, error) { vals := map[string]ApiType{ "graphql": ApiTypeGraphql, @@ -53,6 +70,19 @@ func PossibleValuesForBearerTokenSendingMethods() []string { } } +func (s *BearerTokenSendingMethods) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseBearerTokenSendingMethods(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseBearerTokenSendingMethods(input string) (*BearerTokenSendingMethods, error) { vals := map[string]BearerTokenSendingMethods{ "authorizationheader": BearerTokenSendingMethodsAuthorizationHeader, @@ -81,6 +111,19 @@ func PossibleValuesForProductState() []string { } } +func (s *ProductState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProductState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseProductState(input string) (*ProductState, error) { vals := map[string]ProductState{ "notpublished": ProductStateNotPublished, @@ -113,6 +156,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{ "http": ProtocolHTTP, diff --git a/resource-manager/apimanagement/2022-08-01/apioperationsbytag/method_operationlistbytags.go b/resource-manager/apimanagement/2022-08-01/apioperationsbytag/method_operationlistbytags.go new file mode 100644 index 00000000000..2e348997053 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/apioperationsbytag/method_operationlistbytags.go @@ -0,0 +1,129 @@ +package apioperationsbytag + +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 OperationListByTagsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]TagResourceContract +} + +type OperationListByTagsCompleteResult struct { + Items []TagResourceContract +} + +type OperationListByTagsOperationOptions struct { + Filter *string + IncludeNotTaggedOperations *bool + Skip *int64 + Top *int64 +} + +func DefaultOperationListByTagsOperationOptions() OperationListByTagsOperationOptions { + return OperationListByTagsOperationOptions{} +} + +func (o OperationListByTagsOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o OperationListByTagsOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o OperationListByTagsOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.IncludeNotTaggedOperations != nil { + out.Append("includeNotTaggedOperations", fmt.Sprintf("%v", *o.IncludeNotTaggedOperations)) + } + if o.Skip != nil { + out.Append("$skip", fmt.Sprintf("%v", *o.Skip)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +// OperationListByTags ... +func (c ApiOperationsByTagClient) OperationListByTags(ctx context.Context, id ApiId, options OperationListByTagsOperationOptions) (result OperationListByTagsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/operationsByTags", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]TagResourceContract `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// OperationListByTagsComplete retrieves all the results into a single object +func (c ApiOperationsByTagClient) OperationListByTagsComplete(ctx context.Context, id ApiId, options OperationListByTagsOperationOptions) (OperationListByTagsCompleteResult, error) { + return c.OperationListByTagsCompleteMatchingPredicate(ctx, id, options, TagResourceContractOperationPredicate{}) +} + +// OperationListByTagsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ApiOperationsByTagClient) OperationListByTagsCompleteMatchingPredicate(ctx context.Context, id ApiId, options OperationListByTagsOperationOptions, predicate TagResourceContractOperationPredicate) (result OperationListByTagsCompleteResult, err error) { + items := make([]TagResourceContract, 0) + + resp, err := c.OperationListByTags(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = OperationListByTagsCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/apimanagement/2022-08-01/apioperationsbytag/method_operationlistbytags_autorest.go b/resource-manager/apimanagement/2022-08-01/apioperationsbytag/method_operationlistbytags_autorest.go deleted file mode 100644 index 0c8ab093faf..00000000000 --- a/resource-manager/apimanagement/2022-08-01/apioperationsbytag/method_operationlistbytags_autorest.go +++ /dev/null @@ -1,230 +0,0 @@ -package apioperationsbytag - -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 OperationListByTagsOperationResponse struct { - HttpResponse *http.Response - Model *[]TagResourceContract - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (OperationListByTagsOperationResponse, error) -} - -type OperationListByTagsCompleteResult struct { - Items []TagResourceContract -} - -func (r OperationListByTagsOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r OperationListByTagsOperationResponse) LoadMore(ctx context.Context) (resp OperationListByTagsOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -type OperationListByTagsOperationOptions struct { - Filter *string - IncludeNotTaggedOperations *bool - Skip *int64 - Top *int64 -} - -func DefaultOperationListByTagsOperationOptions() OperationListByTagsOperationOptions { - return OperationListByTagsOperationOptions{} -} - -func (o OperationListByTagsOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o OperationListByTagsOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Filter != nil { - out["$filter"] = *o.Filter - } - - if o.IncludeNotTaggedOperations != nil { - out["includeNotTaggedOperations"] = *o.IncludeNotTaggedOperations - } - - if o.Skip != nil { - out["$skip"] = *o.Skip - } - - if o.Top != nil { - out["$top"] = *o.Top - } - - return out -} - -// OperationListByTags ... -func (c ApiOperationsByTagClient) OperationListByTags(ctx context.Context, id ApiId, options OperationListByTagsOperationOptions) (resp OperationListByTagsOperationResponse, err error) { - req, err := c.preparerForOperationListByTags(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "apioperationsbytag.ApiOperationsByTagClient", "OperationListByTags", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apioperationsbytag.ApiOperationsByTagClient", "OperationListByTags", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForOperationListByTags(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apioperationsbytag.ApiOperationsByTagClient", "OperationListByTags", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForOperationListByTags prepares the OperationListByTags request. -func (c ApiOperationsByTagClient) preparerForOperationListByTags(ctx context.Context, id ApiId, options OperationListByTagsOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/operationsByTags", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForOperationListByTagsWithNextLink prepares the OperationListByTags request with the given nextLink token. -func (c ApiOperationsByTagClient) preparerForOperationListByTagsWithNextLink(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)) -} - -// responderForOperationListByTags handles the response to the OperationListByTags request. The method always -// closes the http.Response Body. -func (c ApiOperationsByTagClient) responderForOperationListByTags(resp *http.Response) (result OperationListByTagsOperationResponse, err error) { - type page struct { - Values []TagResourceContract `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 OperationListByTagsOperationResponse, err error) { - req, err := c.preparerForOperationListByTagsWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "apioperationsbytag.ApiOperationsByTagClient", "OperationListByTags", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apioperationsbytag.ApiOperationsByTagClient", "OperationListByTags", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForOperationListByTags(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apioperationsbytag.ApiOperationsByTagClient", "OperationListByTags", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// OperationListByTagsComplete retrieves all of the results into a single object -func (c ApiOperationsByTagClient) OperationListByTagsComplete(ctx context.Context, id ApiId, options OperationListByTagsOperationOptions) (OperationListByTagsCompleteResult, error) { - return c.OperationListByTagsCompleteMatchingPredicate(ctx, id, options, TagResourceContractOperationPredicate{}) -} - -// OperationListByTagsCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c ApiOperationsByTagClient) OperationListByTagsCompleteMatchingPredicate(ctx context.Context, id ApiId, options OperationListByTagsOperationOptions, predicate TagResourceContractOperationPredicate) (resp OperationListByTagsCompleteResult, err error) { - items := make([]TagResourceContract, 0) - - page, err := c.OperationListByTags(ctx, id, options) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := OperationListByTagsCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/apimanagement/2022-08-01/apioperationtag/client.go b/resource-manager/apimanagement/2022-08-01/apioperationtag/client.go index 3bfc477ea28..5ddac6abce5 100644 --- a/resource-manager/apimanagement/2022-08-01/apioperationtag/client.go +++ b/resource-manager/apimanagement/2022-08-01/apioperationtag/client.go @@ -1,18 +1,26 @@ package apioperationtag -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 ApiOperationTagClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewApiOperationTagClientWithBaseURI(endpoint string) ApiOperationTagClient { - return ApiOperationTagClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewApiOperationTagClientWithBaseURI(api environments.Api) (*ApiOperationTagClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "apioperationtag", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ApiOperationTagClient: %+v", err) } + + return &ApiOperationTagClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2022-08-01/apioperationtag/method_tagassigntooperation.go b/resource-manager/apimanagement/2022-08-01/apioperationtag/method_tagassigntooperation.go new file mode 100644 index 00000000000..2c431fe03fa --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/apioperationtag/method_tagassigntooperation.go @@ -0,0 +1,52 @@ +package apioperationtag + +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 TagAssignToOperationOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *TagContract +} + +// TagAssignToOperation ... +func (c ApiOperationTagClient) TagAssignToOperation(ctx context.Context, id OperationTagId) (result TagAssignToOperationOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + 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/apimanagement/2022-08-01/apioperationtag/method_tagassigntooperation_autorest.go b/resource-manager/apimanagement/2022-08-01/apioperationtag/method_tagassigntooperation_autorest.go deleted file mode 100644 index 9d8aa0afd9a..00000000000 --- a/resource-manager/apimanagement/2022-08-01/apioperationtag/method_tagassigntooperation_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package apioperationtag - -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 TagAssignToOperationOperationResponse struct { - HttpResponse *http.Response - Model *TagContract -} - -// TagAssignToOperation ... -func (c ApiOperationTagClient) TagAssignToOperation(ctx context.Context, id OperationTagId) (result TagAssignToOperationOperationResponse, err error) { - req, err := c.preparerForTagAssignToOperation(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "apioperationtag.ApiOperationTagClient", "TagAssignToOperation", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apioperationtag.ApiOperationTagClient", "TagAssignToOperation", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForTagAssignToOperation(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apioperationtag.ApiOperationTagClient", "TagAssignToOperation", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForTagAssignToOperation prepares the TagAssignToOperation request. -func (c ApiOperationTagClient) preparerForTagAssignToOperation(ctx context.Context, id OperationTagId) (*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.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForTagAssignToOperation handles the response to the TagAssignToOperation request. The method always -// closes the http.Response Body. -func (c ApiOperationTagClient) responderForTagAssignToOperation(resp *http.Response) (result TagAssignToOperationOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2022-08-01/apioperationtag/method_tagdetachfromoperation.go b/resource-manager/apimanagement/2022-08-01/apioperationtag/method_tagdetachfromoperation.go new file mode 100644 index 00000000000..b49f13cabd9 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/apioperationtag/method_tagdetachfromoperation.go @@ -0,0 +1,47 @@ +package apioperationtag + +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 TagDetachFromOperationOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// TagDetachFromOperation ... +func (c ApiOperationTagClient) TagDetachFromOperation(ctx context.Context, id OperationTagId) (result TagDetachFromOperationOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2022-08-01/apioperationtag/method_tagdetachfromoperation_autorest.go b/resource-manager/apimanagement/2022-08-01/apioperationtag/method_tagdetachfromoperation_autorest.go deleted file mode 100644 index b7845a36364..00000000000 --- a/resource-manager/apimanagement/2022-08-01/apioperationtag/method_tagdetachfromoperation_autorest.go +++ /dev/null @@ -1,66 +0,0 @@ -package apioperationtag - -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 TagDetachFromOperationOperationResponse struct { - HttpResponse *http.Response -} - -// TagDetachFromOperation ... -func (c ApiOperationTagClient) TagDetachFromOperation(ctx context.Context, id OperationTagId) (result TagDetachFromOperationOperationResponse, err error) { - req, err := c.preparerForTagDetachFromOperation(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "apioperationtag.ApiOperationTagClient", "TagDetachFromOperation", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apioperationtag.ApiOperationTagClient", "TagDetachFromOperation", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForTagDetachFromOperation(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apioperationtag.ApiOperationTagClient", "TagDetachFromOperation", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForTagDetachFromOperation prepares the TagDetachFromOperation request. -func (c ApiOperationTagClient) preparerForTagDetachFromOperation(ctx context.Context, id OperationTagId) (*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)) -} - -// responderForTagDetachFromOperation handles the response to the TagDetachFromOperation request. The method always -// closes the http.Response Body. -func (c ApiOperationTagClient) responderForTagDetachFromOperation(resp *http.Response) (result TagDetachFromOperationOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2022-08-01/apioperationtag/method_taggetbyoperation.go b/resource-manager/apimanagement/2022-08-01/apioperationtag/method_taggetbyoperation.go new file mode 100644 index 00000000000..a56dc05b28f --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/apioperationtag/method_taggetbyoperation.go @@ -0,0 +1,51 @@ +package apioperationtag + +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 TagGetByOperationOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *TagContract +} + +// TagGetByOperation ... +func (c ApiOperationTagClient) TagGetByOperation(ctx context.Context, id OperationTagId) (result TagGetByOperationOperationResponse, 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/apimanagement/2022-08-01/apioperationtag/method_taggetbyoperation_autorest.go b/resource-manager/apimanagement/2022-08-01/apioperationtag/method_taggetbyoperation_autorest.go deleted file mode 100644 index 8e6507984f5..00000000000 --- a/resource-manager/apimanagement/2022-08-01/apioperationtag/method_taggetbyoperation_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package apioperationtag - -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 TagGetByOperationOperationResponse struct { - HttpResponse *http.Response - Model *TagContract -} - -// TagGetByOperation ... -func (c ApiOperationTagClient) TagGetByOperation(ctx context.Context, id OperationTagId) (result TagGetByOperationOperationResponse, err error) { - req, err := c.preparerForTagGetByOperation(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "apioperationtag.ApiOperationTagClient", "TagGetByOperation", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apioperationtag.ApiOperationTagClient", "TagGetByOperation", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForTagGetByOperation(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apioperationtag.ApiOperationTagClient", "TagGetByOperation", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForTagGetByOperation prepares the TagGetByOperation request. -func (c ApiOperationTagClient) preparerForTagGetByOperation(ctx context.Context, id OperationTagId) (*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)) -} - -// responderForTagGetByOperation handles the response to the TagGetByOperation request. The method always -// closes the http.Response Body. -func (c ApiOperationTagClient) responderForTagGetByOperation(resp *http.Response) (result TagGetByOperationOperationResponse, 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/apimanagement/2022-08-01/apioperationtag/method_taggetentitystatebyoperation.go b/resource-manager/apimanagement/2022-08-01/apioperationtag/method_taggetentitystatebyoperation.go new file mode 100644 index 00000000000..066af82b190 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/apioperationtag/method_taggetentitystatebyoperation.go @@ -0,0 +1,46 @@ +package apioperationtag + +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 TagGetEntityStateByOperationOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// TagGetEntityStateByOperation ... +func (c ApiOperationTagClient) TagGetEntityStateByOperation(ctx context.Context, id OperationTagId) (result TagGetEntityStateByOperationOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodHead, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2022-08-01/apioperationtag/method_taggetentitystatebyoperation_autorest.go b/resource-manager/apimanagement/2022-08-01/apioperationtag/method_taggetentitystatebyoperation_autorest.go deleted file mode 100644 index beaef9dc15a..00000000000 --- a/resource-manager/apimanagement/2022-08-01/apioperationtag/method_taggetentitystatebyoperation_autorest.go +++ /dev/null @@ -1,66 +0,0 @@ -package apioperationtag - -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 TagGetEntityStateByOperationOperationResponse struct { - HttpResponse *http.Response -} - -// TagGetEntityStateByOperation ... -func (c ApiOperationTagClient) TagGetEntityStateByOperation(ctx context.Context, id OperationTagId) (result TagGetEntityStateByOperationOperationResponse, err error) { - req, err := c.preparerForTagGetEntityStateByOperation(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "apioperationtag.ApiOperationTagClient", "TagGetEntityStateByOperation", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apioperationtag.ApiOperationTagClient", "TagGetEntityStateByOperation", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForTagGetEntityStateByOperation(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apioperationtag.ApiOperationTagClient", "TagGetEntityStateByOperation", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForTagGetEntityStateByOperation prepares the TagGetEntityStateByOperation request. -func (c ApiOperationTagClient) preparerForTagGetEntityStateByOperation(ctx context.Context, id OperationTagId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsHead(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForTagGetEntityStateByOperation handles the response to the TagGetEntityStateByOperation request. The method always -// closes the http.Response Body. -func (c ApiOperationTagClient) responderForTagGetEntityStateByOperation(resp *http.Response) (result TagGetEntityStateByOperationOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2022-08-01/apioperationtag/method_taglistbyoperation.go b/resource-manager/apimanagement/2022-08-01/apioperationtag/method_taglistbyoperation.go new file mode 100644 index 00000000000..b857e4ac190 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/apioperationtag/method_taglistbyoperation.go @@ -0,0 +1,125 @@ +package apioperationtag + +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 TagListByOperationOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]TagContract +} + +type TagListByOperationCompleteResult struct { + Items []TagContract +} + +type TagListByOperationOperationOptions struct { + Filter *string + Skip *int64 + Top *int64 +} + +func DefaultTagListByOperationOperationOptions() TagListByOperationOperationOptions { + return TagListByOperationOperationOptions{} +} + +func (o TagListByOperationOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o TagListByOperationOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o TagListByOperationOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.Skip != nil { + out.Append("$skip", fmt.Sprintf("%v", *o.Skip)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +// TagListByOperation ... +func (c ApiOperationTagClient) TagListByOperation(ctx context.Context, id OperationId, options TagListByOperationOperationOptions) (result TagListByOperationOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/tags", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]TagContract `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// TagListByOperationComplete retrieves all the results into a single object +func (c ApiOperationTagClient) TagListByOperationComplete(ctx context.Context, id OperationId, options TagListByOperationOperationOptions) (TagListByOperationCompleteResult, error) { + return c.TagListByOperationCompleteMatchingPredicate(ctx, id, options, TagContractOperationPredicate{}) +} + +// TagListByOperationCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ApiOperationTagClient) TagListByOperationCompleteMatchingPredicate(ctx context.Context, id OperationId, options TagListByOperationOperationOptions, predicate TagContractOperationPredicate) (result TagListByOperationCompleteResult, err error) { + items := make([]TagContract, 0) + + resp, err := c.TagListByOperation(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = TagListByOperationCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/apimanagement/2022-08-01/apioperationtag/method_taglistbyoperation_autorest.go b/resource-manager/apimanagement/2022-08-01/apioperationtag/method_taglistbyoperation_autorest.go deleted file mode 100644 index 5bc7a969362..00000000000 --- a/resource-manager/apimanagement/2022-08-01/apioperationtag/method_taglistbyoperation_autorest.go +++ /dev/null @@ -1,225 +0,0 @@ -package apioperationtag - -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 TagListByOperationOperationResponse struct { - HttpResponse *http.Response - Model *[]TagContract - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (TagListByOperationOperationResponse, error) -} - -type TagListByOperationCompleteResult struct { - Items []TagContract -} - -func (r TagListByOperationOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r TagListByOperationOperationResponse) LoadMore(ctx context.Context) (resp TagListByOperationOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -type TagListByOperationOperationOptions struct { - Filter *string - Skip *int64 - Top *int64 -} - -func DefaultTagListByOperationOperationOptions() TagListByOperationOperationOptions { - return TagListByOperationOperationOptions{} -} - -func (o TagListByOperationOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o TagListByOperationOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Filter != nil { - out["$filter"] = *o.Filter - } - - if o.Skip != nil { - out["$skip"] = *o.Skip - } - - if o.Top != nil { - out["$top"] = *o.Top - } - - return out -} - -// TagListByOperation ... -func (c ApiOperationTagClient) TagListByOperation(ctx context.Context, id OperationId, options TagListByOperationOperationOptions) (resp TagListByOperationOperationResponse, err error) { - req, err := c.preparerForTagListByOperation(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "apioperationtag.ApiOperationTagClient", "TagListByOperation", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apioperationtag.ApiOperationTagClient", "TagListByOperation", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForTagListByOperation(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apioperationtag.ApiOperationTagClient", "TagListByOperation", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForTagListByOperation prepares the TagListByOperation request. -func (c ApiOperationTagClient) preparerForTagListByOperation(ctx context.Context, id OperationId, options TagListByOperationOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/tags", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForTagListByOperationWithNextLink prepares the TagListByOperation request with the given nextLink token. -func (c ApiOperationTagClient) preparerForTagListByOperationWithNextLink(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)) -} - -// responderForTagListByOperation handles the response to the TagListByOperation request. The method always -// closes the http.Response Body. -func (c ApiOperationTagClient) responderForTagListByOperation(resp *http.Response) (result TagListByOperationOperationResponse, err error) { - type page struct { - Values []TagContract `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 TagListByOperationOperationResponse, err error) { - req, err := c.preparerForTagListByOperationWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "apioperationtag.ApiOperationTagClient", "TagListByOperation", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apioperationtag.ApiOperationTagClient", "TagListByOperation", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForTagListByOperation(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apioperationtag.ApiOperationTagClient", "TagListByOperation", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// TagListByOperationComplete retrieves all of the results into a single object -func (c ApiOperationTagClient) TagListByOperationComplete(ctx context.Context, id OperationId, options TagListByOperationOperationOptions) (TagListByOperationCompleteResult, error) { - return c.TagListByOperationCompleteMatchingPredicate(ctx, id, options, TagContractOperationPredicate{}) -} - -// TagListByOperationCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c ApiOperationTagClient) TagListByOperationCompleteMatchingPredicate(ctx context.Context, id OperationId, options TagListByOperationOperationOptions, predicate TagContractOperationPredicate) (resp TagListByOperationCompleteResult, err error) { - items := make([]TagContract, 0) - - page, err := c.TagListByOperation(ctx, id, options) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := TagListByOperationCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/apimanagement/2022-08-01/apipolicy/client.go b/resource-manager/apimanagement/2022-08-01/apipolicy/client.go index 849c529fef4..036eadf1bfd 100644 --- a/resource-manager/apimanagement/2022-08-01/apipolicy/client.go +++ b/resource-manager/apimanagement/2022-08-01/apipolicy/client.go @@ -1,18 +1,26 @@ package apipolicy -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 ApiPolicyClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewApiPolicyClientWithBaseURI(endpoint string) ApiPolicyClient { - return ApiPolicyClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewApiPolicyClientWithBaseURI(api environments.Api) (*ApiPolicyClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "apipolicy", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ApiPolicyClient: %+v", err) } + + return &ApiPolicyClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2022-08-01/apipolicy/constants.go b/resource-manager/apimanagement/2022-08-01/apipolicy/constants.go index 0622a9d8ec5..3a402942dd8 100644 --- a/resource-manager/apimanagement/2022-08-01/apipolicy/constants.go +++ b/resource-manager/apimanagement/2022-08-01/apipolicy/constants.go @@ -1,6 +1,10 @@ package apipolicy -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 PossibleValuesForPolicyContentFormat() []string { } } +func (s *PolicyContentFormat) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePolicyContentFormat(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parsePolicyContentFormat(input string) (*PolicyContentFormat, error) { vals := map[string]PolicyContentFormat{ "rawxml": PolicyContentFormatRawxml, @@ -53,6 +70,19 @@ func PossibleValuesForPolicyExportFormat() []string { } } +func (s *PolicyExportFormat) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePolicyExportFormat(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parsePolicyExportFormat(input string) (*PolicyExportFormat, error) { vals := map[string]PolicyExportFormat{ "rawxml": PolicyExportFormatRawxml, diff --git a/resource-manager/apimanagement/2022-08-01/apipolicy/method_createorupdate.go b/resource-manager/apimanagement/2022-08-01/apipolicy/method_createorupdate.go new file mode 100644 index 00000000000..34932d9e40b --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/apipolicy/method_createorupdate.go @@ -0,0 +1,85 @@ +package apipolicy + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PolicyContract +} + +type CreateOrUpdateOperationOptions struct { + IfMatch *string +} + +func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { + return CreateOrUpdateOperationOptions{} +} + +func (o CreateOrUpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o CreateOrUpdateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o CreateOrUpdateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// CreateOrUpdate ... +func (c ApiPolicyClient) CreateOrUpdate(ctx context.Context, id ApiId, input PolicyContract, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/policies/policy", id.ID()), + OptionsObject: options, + } + + 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/apimanagement/2022-08-01/apipolicy/method_createorupdate_autorest.go b/resource-manager/apimanagement/2022-08-01/apipolicy/method_createorupdate_autorest.go deleted file mode 100644 index 1d3e07d089c..00000000000 --- a/resource-manager/apimanagement/2022-08-01/apipolicy/method_createorupdate_autorest.go +++ /dev/null @@ -1,99 +0,0 @@ -package apipolicy - -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 CreateOrUpdateOperationResponse struct { - HttpResponse *http.Response - Model *PolicyContract -} - -type CreateOrUpdateOperationOptions struct { - IfMatch *string -} - -func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { - return CreateOrUpdateOperationOptions{} -} - -func (o CreateOrUpdateOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o CreateOrUpdateOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// CreateOrUpdate ... -func (c ApiPolicyClient) CreateOrUpdate(ctx context.Context, id ApiId, input PolicyContract, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdate(ctx, id, input, options) - if err != nil { - err = autorest.NewErrorWithError(err, "apipolicy.ApiPolicyClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apipolicy.ApiPolicyClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCreateOrUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apipolicy.ApiPolicyClient", "CreateOrUpdate", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCreateOrUpdate prepares the CreateOrUpdate request. -func (c ApiPolicyClient) preparerForCreateOrUpdate(ctx context.Context, id ApiId, input PolicyContract, options CreateOrUpdateOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/policies/policy", 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 ApiPolicyClient) responderForCreateOrUpdate(resp *http.Response) (result CreateOrUpdateOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2022-08-01/apipolicy/method_delete.go b/resource-manager/apimanagement/2022-08-01/apipolicy/method_delete.go new file mode 100644 index 00000000000..10b8c3c63c0 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/apipolicy/method_delete.go @@ -0,0 +1,76 @@ +package apipolicy + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +type DeleteOperationOptions struct { + IfMatch *string +} + +func DefaultDeleteOperationOptions() DeleteOperationOptions { + return DeleteOperationOptions{} +} + +func (o DeleteOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o DeleteOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o DeleteOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// Delete ... +func (c ApiPolicyClient) Delete(ctx context.Context, id ApiId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: fmt.Sprintf("%s/policies/policy", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2022-08-01/apipolicy/method_delete_autorest.go b/resource-manager/apimanagement/2022-08-01/apipolicy/method_delete_autorest.go deleted file mode 100644 index 010fbd8de58..00000000000 --- a/resource-manager/apimanagement/2022-08-01/apipolicy/method_delete_autorest.go +++ /dev/null @@ -1,96 +0,0 @@ -package apipolicy - -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 DeleteOperationResponse struct { - HttpResponse *http.Response -} - -type DeleteOperationOptions struct { - IfMatch *string -} - -func DefaultDeleteOperationOptions() DeleteOperationOptions { - return DeleteOperationOptions{} -} - -func (o DeleteOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o DeleteOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// Delete ... -func (c ApiPolicyClient) Delete(ctx context.Context, id ApiId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { - req, err := c.preparerForDelete(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "apipolicy.ApiPolicyClient", "Delete", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apipolicy.ApiPolicyClient", "Delete", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForDelete(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apipolicy.ApiPolicyClient", "Delete", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForDelete prepares the Delete request. -func (c ApiPolicyClient) preparerForDelete(ctx context.Context, id ApiId, options DeleteOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/policies/policy", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForDelete handles the response to the Delete request. The method always -// closes the http.Response Body. -func (c ApiPolicyClient) responderForDelete(resp *http.Response) (result DeleteOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2022-08-01/apipolicy/method_get.go b/resource-manager/apimanagement/2022-08-01/apipolicy/method_get.go new file mode 100644 index 00000000000..aaa7b1d2c78 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/apipolicy/method_get.go @@ -0,0 +1,80 @@ +package apipolicy + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PolicyContract +} + +type GetOperationOptions struct { + Format *PolicyExportFormat +} + +func DefaultGetOperationOptions() GetOperationOptions { + return GetOperationOptions{} +} + +func (o GetOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o GetOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o GetOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Format != nil { + out.Append("format", fmt.Sprintf("%v", *o.Format)) + } + return &out +} + +// Get ... +func (c ApiPolicyClient) Get(ctx context.Context, id ApiId, options GetOperationOptions) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/policies/policy", id.ID()), + OptionsObject: options, + } + + 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/apimanagement/2022-08-01/apipolicy/method_get_autorest.go b/resource-manager/apimanagement/2022-08-01/apipolicy/method_get_autorest.go deleted file mode 100644 index 4003515afa2..00000000000 --- a/resource-manager/apimanagement/2022-08-01/apipolicy/method_get_autorest.go +++ /dev/null @@ -1,98 +0,0 @@ -package apipolicy - -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 GetOperationResponse struct { - HttpResponse *http.Response - Model *PolicyContract -} - -type GetOperationOptions struct { - Format *PolicyExportFormat -} - -func DefaultGetOperationOptions() GetOperationOptions { - return GetOperationOptions{} -} - -func (o GetOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o GetOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Format != nil { - out["format"] = *o.Format - } - - return out -} - -// Get ... -func (c ApiPolicyClient) Get(ctx context.Context, id ApiId, options GetOperationOptions) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "apipolicy.ApiPolicyClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apipolicy.ApiPolicyClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apipolicy.ApiPolicyClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c ApiPolicyClient) preparerForGet(ctx context.Context, id ApiId, options GetOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/policies/policy", 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 ApiPolicyClient) 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/apimanagement/2022-08-01/apipolicy/method_getentitytag.go b/resource-manager/apimanagement/2022-08-01/apipolicy/method_getentitytag.go new file mode 100644 index 00000000000..5ab255150b8 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/apipolicy/method_getentitytag.go @@ -0,0 +1,47 @@ +package apipolicy + +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 GetEntityTagOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// GetEntityTag ... +func (c ApiPolicyClient) GetEntityTag(ctx context.Context, id ApiId) (result GetEntityTagOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodHead, + Path: fmt.Sprintf("%s/policies/policy", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2022-08-01/apipolicy/method_getentitytag_autorest.go b/resource-manager/apimanagement/2022-08-01/apipolicy/method_getentitytag_autorest.go deleted file mode 100644 index 522426b034b..00000000000 --- a/resource-manager/apimanagement/2022-08-01/apipolicy/method_getentitytag_autorest.go +++ /dev/null @@ -1,67 +0,0 @@ -package apipolicy - -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 GetEntityTagOperationResponse struct { - HttpResponse *http.Response -} - -// GetEntityTag ... -func (c ApiPolicyClient) GetEntityTag(ctx context.Context, id ApiId) (result GetEntityTagOperationResponse, err error) { - req, err := c.preparerForGetEntityTag(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "apipolicy.ApiPolicyClient", "GetEntityTag", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apipolicy.ApiPolicyClient", "GetEntityTag", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetEntityTag(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apipolicy.ApiPolicyClient", "GetEntityTag", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetEntityTag prepares the GetEntityTag request. -func (c ApiPolicyClient) preparerForGetEntityTag(ctx context.Context, id ApiId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsHead(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/policies/policy", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetEntityTag handles the response to the GetEntityTag request. The method always -// closes the http.Response Body. -func (c ApiPolicyClient) responderForGetEntityTag(resp *http.Response) (result GetEntityTagOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2022-08-01/apipolicy/method_listbyapi.go b/resource-manager/apimanagement/2022-08-01/apipolicy/method_listbyapi.go new file mode 100644 index 00000000000..5afb8149c87 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/apipolicy/method_listbyapi.go @@ -0,0 +1,52 @@ +package apipolicy + +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 ListByApiOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PolicyCollection +} + +// ListByApi ... +func (c ApiPolicyClient) ListByApi(ctx context.Context, id ApiId) (result ListByApiOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/policies", 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/apimanagement/2022-08-01/apipolicy/method_listbyapi_autorest.go b/resource-manager/apimanagement/2022-08-01/apipolicy/method_listbyapi_autorest.go deleted file mode 100644 index 3c5cfc6d95f..00000000000 --- a/resource-manager/apimanagement/2022-08-01/apipolicy/method_listbyapi_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package apipolicy - -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 ListByApiOperationResponse struct { - HttpResponse *http.Response - Model *PolicyCollection -} - -// ListByApi ... -func (c ApiPolicyClient) ListByApi(ctx context.Context, id ApiId) (result ListByApiOperationResponse, err error) { - req, err := c.preparerForListByApi(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "apipolicy.ApiPolicyClient", "ListByApi", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apipolicy.ApiPolicyClient", "ListByApi", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByApi(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apipolicy.ApiPolicyClient", "ListByApi", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForListByApi prepares the ListByApi request. -func (c ApiPolicyClient) preparerForListByApi(ctx context.Context, id ApiId) (*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/policies", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListByApi handles the response to the ListByApi request. The method always -// closes the http.Response Body. -func (c ApiPolicyClient) responderForListByApi(resp *http.Response) (result ListByApiOperationResponse, 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/apimanagement/2022-08-01/apiproduct/client.go b/resource-manager/apimanagement/2022-08-01/apiproduct/client.go index 4c35dacbaa3..87853216789 100644 --- a/resource-manager/apimanagement/2022-08-01/apiproduct/client.go +++ b/resource-manager/apimanagement/2022-08-01/apiproduct/client.go @@ -1,18 +1,26 @@ package apiproduct -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 ApiProductClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewApiProductClientWithBaseURI(endpoint string) ApiProductClient { - return ApiProductClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewApiProductClientWithBaseURI(api environments.Api) (*ApiProductClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "apiproduct", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ApiProductClient: %+v", err) } + + return &ApiProductClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2022-08-01/apiproduct/constants.go b/resource-manager/apimanagement/2022-08-01/apiproduct/constants.go index f0fb051f3c2..12fdc8dd3d6 100644 --- a/resource-manager/apimanagement/2022-08-01/apiproduct/constants.go +++ b/resource-manager/apimanagement/2022-08-01/apiproduct/constants.go @@ -1,6 +1,10 @@ package apiproduct -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 PossibleValuesForProductState() []string { } } +func (s *ProductState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProductState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseProductState(input string) (*ProductState, error) { vals := map[string]ProductState{ "notpublished": ProductStateNotPublished, diff --git a/resource-manager/apimanagement/2022-08-01/apiproduct/method_listbyapis.go b/resource-manager/apimanagement/2022-08-01/apiproduct/method_listbyapis.go new file mode 100644 index 00000000000..2acd3899dfb --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/apiproduct/method_listbyapis.go @@ -0,0 +1,125 @@ +package apiproduct + +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 ListByApisOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ProductContract +} + +type ListByApisCompleteResult struct { + Items []ProductContract +} + +type ListByApisOperationOptions struct { + Filter *string + Skip *int64 + Top *int64 +} + +func DefaultListByApisOperationOptions() ListByApisOperationOptions { + return ListByApisOperationOptions{} +} + +func (o ListByApisOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListByApisOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListByApisOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.Skip != nil { + out.Append("$skip", fmt.Sprintf("%v", *o.Skip)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +// ListByApis ... +func (c ApiProductClient) ListByApis(ctx context.Context, id ApiId, options ListByApisOperationOptions) (result ListByApisOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/products", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ProductContract `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByApisComplete retrieves all the results into a single object +func (c ApiProductClient) ListByApisComplete(ctx context.Context, id ApiId, options ListByApisOperationOptions) (ListByApisCompleteResult, error) { + return c.ListByApisCompleteMatchingPredicate(ctx, id, options, ProductContractOperationPredicate{}) +} + +// ListByApisCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ApiProductClient) ListByApisCompleteMatchingPredicate(ctx context.Context, id ApiId, options ListByApisOperationOptions, predicate ProductContractOperationPredicate) (result ListByApisCompleteResult, err error) { + items := make([]ProductContract, 0) + + resp, err := c.ListByApis(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByApisCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/apimanagement/2022-08-01/apiproduct/method_listbyapis_autorest.go b/resource-manager/apimanagement/2022-08-01/apiproduct/method_listbyapis_autorest.go deleted file mode 100644 index 3ef1fe2b276..00000000000 --- a/resource-manager/apimanagement/2022-08-01/apiproduct/method_listbyapis_autorest.go +++ /dev/null @@ -1,225 +0,0 @@ -package apiproduct - -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 ListByApisOperationResponse struct { - HttpResponse *http.Response - Model *[]ProductContract - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListByApisOperationResponse, error) -} - -type ListByApisCompleteResult struct { - Items []ProductContract -} - -func (r ListByApisOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListByApisOperationResponse) LoadMore(ctx context.Context) (resp ListByApisOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -type ListByApisOperationOptions struct { - Filter *string - Skip *int64 - Top *int64 -} - -func DefaultListByApisOperationOptions() ListByApisOperationOptions { - return ListByApisOperationOptions{} -} - -func (o ListByApisOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o ListByApisOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Filter != nil { - out["$filter"] = *o.Filter - } - - if o.Skip != nil { - out["$skip"] = *o.Skip - } - - if o.Top != nil { - out["$top"] = *o.Top - } - - return out -} - -// ListByApis ... -func (c ApiProductClient) ListByApis(ctx context.Context, id ApiId, options ListByApisOperationOptions) (resp ListByApisOperationResponse, err error) { - req, err := c.preparerForListByApis(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "apiproduct.ApiProductClient", "ListByApis", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apiproduct.ApiProductClient", "ListByApis", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListByApis(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apiproduct.ApiProductClient", "ListByApis", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListByApis prepares the ListByApis request. -func (c ApiProductClient) preparerForListByApis(ctx context.Context, id ApiId, options ListByApisOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/products", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListByApisWithNextLink prepares the ListByApis request with the given nextLink token. -func (c ApiProductClient) preparerForListByApisWithNextLink(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)) -} - -// responderForListByApis handles the response to the ListByApis request. The method always -// closes the http.Response Body. -func (c ApiProductClient) responderForListByApis(resp *http.Response) (result ListByApisOperationResponse, err error) { - type page struct { - Values []ProductContract `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 ListByApisOperationResponse, err error) { - req, err := c.preparerForListByApisWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "apiproduct.ApiProductClient", "ListByApis", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apiproduct.ApiProductClient", "ListByApis", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByApis(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apiproduct.ApiProductClient", "ListByApis", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListByApisComplete retrieves all of the results into a single object -func (c ApiProductClient) ListByApisComplete(ctx context.Context, id ApiId, options ListByApisOperationOptions) (ListByApisCompleteResult, error) { - return c.ListByApisCompleteMatchingPredicate(ctx, id, options, ProductContractOperationPredicate{}) -} - -// ListByApisCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c ApiProductClient) ListByApisCompleteMatchingPredicate(ctx context.Context, id ApiId, options ListByApisOperationOptions, predicate ProductContractOperationPredicate) (resp ListByApisCompleteResult, err error) { - items := make([]ProductContract, 0) - - page, err := c.ListByApis(ctx, id, options) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListByApisCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/apimanagement/2022-08-01/apirelease/client.go b/resource-manager/apimanagement/2022-08-01/apirelease/client.go index 7daeaa5351d..452fd61dfa4 100644 --- a/resource-manager/apimanagement/2022-08-01/apirelease/client.go +++ b/resource-manager/apimanagement/2022-08-01/apirelease/client.go @@ -1,18 +1,26 @@ package apirelease -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 ApiReleaseClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewApiReleaseClientWithBaseURI(endpoint string) ApiReleaseClient { - return ApiReleaseClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewApiReleaseClientWithBaseURI(api environments.Api) (*ApiReleaseClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "apirelease", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ApiReleaseClient: %+v", err) } + + return &ApiReleaseClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2022-08-01/apirelease/method_createorupdate.go b/resource-manager/apimanagement/2022-08-01/apirelease/method_createorupdate.go new file mode 100644 index 00000000000..406976fb2f8 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/apirelease/method_createorupdate.go @@ -0,0 +1,85 @@ +package apirelease + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ApiReleaseContract +} + +type CreateOrUpdateOperationOptions struct { + IfMatch *string +} + +func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { + return CreateOrUpdateOperationOptions{} +} + +func (o CreateOrUpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o CreateOrUpdateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o CreateOrUpdateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// CreateOrUpdate ... +func (c ApiReleaseClient) CreateOrUpdate(ctx context.Context, id ReleaseId, input ApiReleaseContract, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + OptionsObject: options, + } + + 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/apimanagement/2022-08-01/apirelease/method_createorupdate_autorest.go b/resource-manager/apimanagement/2022-08-01/apirelease/method_createorupdate_autorest.go deleted file mode 100644 index a9bb0d861fe..00000000000 --- a/resource-manager/apimanagement/2022-08-01/apirelease/method_createorupdate_autorest.go +++ /dev/null @@ -1,98 +0,0 @@ -package apirelease - -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 *ApiReleaseContract -} - -type CreateOrUpdateOperationOptions struct { - IfMatch *string -} - -func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { - return CreateOrUpdateOperationOptions{} -} - -func (o CreateOrUpdateOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o CreateOrUpdateOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// CreateOrUpdate ... -func (c ApiReleaseClient) CreateOrUpdate(ctx context.Context, id ReleaseId, input ApiReleaseContract, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdate(ctx, id, input, options) - if err != nil { - err = autorest.NewErrorWithError(err, "apirelease.ApiReleaseClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apirelease.ApiReleaseClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCreateOrUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apirelease.ApiReleaseClient", "CreateOrUpdate", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCreateOrUpdate prepares the CreateOrUpdate request. -func (c ApiReleaseClient) preparerForCreateOrUpdate(ctx context.Context, id ReleaseId, input ApiReleaseContract, options CreateOrUpdateOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - 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 ApiReleaseClient) responderForCreateOrUpdate(resp *http.Response) (result CreateOrUpdateOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2022-08-01/apirelease/method_delete.go b/resource-manager/apimanagement/2022-08-01/apirelease/method_delete.go new file mode 100644 index 00000000000..cdfaf120b2b --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/apirelease/method_delete.go @@ -0,0 +1,76 @@ +package apirelease + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +type DeleteOperationOptions struct { + IfMatch *string +} + +func DefaultDeleteOperationOptions() DeleteOperationOptions { + return DeleteOperationOptions{} +} + +func (o DeleteOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o DeleteOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o DeleteOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// Delete ... +func (c ApiReleaseClient) Delete(ctx context.Context, id ReleaseId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2022-08-01/apirelease/method_delete_autorest.go b/resource-manager/apimanagement/2022-08-01/apirelease/method_delete_autorest.go deleted file mode 100644 index d5290cd9c81..00000000000 --- a/resource-manager/apimanagement/2022-08-01/apirelease/method_delete_autorest.go +++ /dev/null @@ -1,95 +0,0 @@ -package apirelease - -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 DeleteOperationResponse struct { - HttpResponse *http.Response -} - -type DeleteOperationOptions struct { - IfMatch *string -} - -func DefaultDeleteOperationOptions() DeleteOperationOptions { - return DeleteOperationOptions{} -} - -func (o DeleteOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o DeleteOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// Delete ... -func (c ApiReleaseClient) Delete(ctx context.Context, id ReleaseId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { - req, err := c.preparerForDelete(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "apirelease.ApiReleaseClient", "Delete", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apirelease.ApiReleaseClient", "Delete", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForDelete(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apirelease.ApiReleaseClient", "Delete", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForDelete prepares the Delete request. -func (c ApiReleaseClient) preparerForDelete(ctx context.Context, id ReleaseId, options DeleteOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForDelete handles the response to the Delete request. The method always -// closes the http.Response Body. -func (c ApiReleaseClient) responderForDelete(resp *http.Response) (result DeleteOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2022-08-01/apirelease/method_get.go b/resource-manager/apimanagement/2022-08-01/apirelease/method_get.go new file mode 100644 index 00000000000..afe7107ae45 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/apirelease/method_get.go @@ -0,0 +1,51 @@ +package apirelease + +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 *ApiReleaseContract +} + +// Get ... +func (c ApiReleaseClient) Get(ctx context.Context, id ReleaseId) (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/apimanagement/2022-08-01/apirelease/method_get_autorest.go b/resource-manager/apimanagement/2022-08-01/apirelease/method_get_autorest.go deleted file mode 100644 index 6b5b8bbd11a..00000000000 --- a/resource-manager/apimanagement/2022-08-01/apirelease/method_get_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package apirelease - -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 *ApiReleaseContract -} - -// Get ... -func (c ApiReleaseClient) Get(ctx context.Context, id ReleaseId) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "apirelease.ApiReleaseClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apirelease.ApiReleaseClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apirelease.ApiReleaseClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c ApiReleaseClient) preparerForGet(ctx context.Context, id ReleaseId) (*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 ApiReleaseClient) 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/apimanagement/2022-08-01/apirelease/method_getentitytag.go b/resource-manager/apimanagement/2022-08-01/apirelease/method_getentitytag.go new file mode 100644 index 00000000000..97a2ff54ef1 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/apirelease/method_getentitytag.go @@ -0,0 +1,46 @@ +package apirelease + +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 GetEntityTagOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// GetEntityTag ... +func (c ApiReleaseClient) GetEntityTag(ctx context.Context, id ReleaseId) (result GetEntityTagOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodHead, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2022-08-01/apirelease/method_getentitytag_autorest.go b/resource-manager/apimanagement/2022-08-01/apirelease/method_getentitytag_autorest.go deleted file mode 100644 index 67f795accdb..00000000000 --- a/resource-manager/apimanagement/2022-08-01/apirelease/method_getentitytag_autorest.go +++ /dev/null @@ -1,66 +0,0 @@ -package apirelease - -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 GetEntityTagOperationResponse struct { - HttpResponse *http.Response -} - -// GetEntityTag ... -func (c ApiReleaseClient) GetEntityTag(ctx context.Context, id ReleaseId) (result GetEntityTagOperationResponse, err error) { - req, err := c.preparerForGetEntityTag(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "apirelease.ApiReleaseClient", "GetEntityTag", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apirelease.ApiReleaseClient", "GetEntityTag", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetEntityTag(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apirelease.ApiReleaseClient", "GetEntityTag", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetEntityTag prepares the GetEntityTag request. -func (c ApiReleaseClient) preparerForGetEntityTag(ctx context.Context, id ReleaseId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsHead(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetEntityTag handles the response to the GetEntityTag request. The method always -// closes the http.Response Body. -func (c ApiReleaseClient) responderForGetEntityTag(resp *http.Response) (result GetEntityTagOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2022-08-01/apirelease/method_listbyservice.go b/resource-manager/apimanagement/2022-08-01/apirelease/method_listbyservice.go new file mode 100644 index 00000000000..ffb1a5e65b4 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/apirelease/method_listbyservice.go @@ -0,0 +1,125 @@ +package apirelease + +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 ListByServiceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ApiReleaseContract +} + +type ListByServiceCompleteResult struct { + Items []ApiReleaseContract +} + +type ListByServiceOperationOptions struct { + Filter *string + Skip *int64 + Top *int64 +} + +func DefaultListByServiceOperationOptions() ListByServiceOperationOptions { + return ListByServiceOperationOptions{} +} + +func (o ListByServiceOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListByServiceOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListByServiceOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.Skip != nil { + out.Append("$skip", fmt.Sprintf("%v", *o.Skip)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +// ListByService ... +func (c ApiReleaseClient) ListByService(ctx context.Context, id ApiId, options ListByServiceOperationOptions) (result ListByServiceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/releases", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ApiReleaseContract `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByServiceComplete retrieves all the results into a single object +func (c ApiReleaseClient) ListByServiceComplete(ctx context.Context, id ApiId, options ListByServiceOperationOptions) (ListByServiceCompleteResult, error) { + return c.ListByServiceCompleteMatchingPredicate(ctx, id, options, ApiReleaseContractOperationPredicate{}) +} + +// ListByServiceCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ApiReleaseClient) ListByServiceCompleteMatchingPredicate(ctx context.Context, id ApiId, options ListByServiceOperationOptions, predicate ApiReleaseContractOperationPredicate) (result ListByServiceCompleteResult, err error) { + items := make([]ApiReleaseContract, 0) + + resp, err := c.ListByService(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByServiceCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/apimanagement/2022-08-01/apirelease/method_listbyservice_autorest.go b/resource-manager/apimanagement/2022-08-01/apirelease/method_listbyservice_autorest.go deleted file mode 100644 index a503853e31a..00000000000 --- a/resource-manager/apimanagement/2022-08-01/apirelease/method_listbyservice_autorest.go +++ /dev/null @@ -1,225 +0,0 @@ -package apirelease - -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 ListByServiceOperationResponse struct { - HttpResponse *http.Response - Model *[]ApiReleaseContract - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListByServiceOperationResponse, error) -} - -type ListByServiceCompleteResult struct { - Items []ApiReleaseContract -} - -func (r ListByServiceOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListByServiceOperationResponse) LoadMore(ctx context.Context) (resp ListByServiceOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -type ListByServiceOperationOptions struct { - Filter *string - Skip *int64 - Top *int64 -} - -func DefaultListByServiceOperationOptions() ListByServiceOperationOptions { - return ListByServiceOperationOptions{} -} - -func (o ListByServiceOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o ListByServiceOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Filter != nil { - out["$filter"] = *o.Filter - } - - if o.Skip != nil { - out["$skip"] = *o.Skip - } - - if o.Top != nil { - out["$top"] = *o.Top - } - - return out -} - -// ListByService ... -func (c ApiReleaseClient) ListByService(ctx context.Context, id ApiId, options ListByServiceOperationOptions) (resp ListByServiceOperationResponse, err error) { - req, err := c.preparerForListByService(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "apirelease.ApiReleaseClient", "ListByService", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apirelease.ApiReleaseClient", "ListByService", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListByService(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apirelease.ApiReleaseClient", "ListByService", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListByService prepares the ListByService request. -func (c ApiReleaseClient) preparerForListByService(ctx context.Context, id ApiId, options ListByServiceOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/releases", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListByServiceWithNextLink prepares the ListByService request with the given nextLink token. -func (c ApiReleaseClient) preparerForListByServiceWithNextLink(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)) -} - -// responderForListByService handles the response to the ListByService request. The method always -// closes the http.Response Body. -func (c ApiReleaseClient) responderForListByService(resp *http.Response) (result ListByServiceOperationResponse, err error) { - type page struct { - Values []ApiReleaseContract `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 ListByServiceOperationResponse, err error) { - req, err := c.preparerForListByServiceWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "apirelease.ApiReleaseClient", "ListByService", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apirelease.ApiReleaseClient", "ListByService", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByService(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apirelease.ApiReleaseClient", "ListByService", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListByServiceComplete retrieves all of the results into a single object -func (c ApiReleaseClient) ListByServiceComplete(ctx context.Context, id ApiId, options ListByServiceOperationOptions) (ListByServiceCompleteResult, error) { - return c.ListByServiceCompleteMatchingPredicate(ctx, id, options, ApiReleaseContractOperationPredicate{}) -} - -// ListByServiceCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c ApiReleaseClient) ListByServiceCompleteMatchingPredicate(ctx context.Context, id ApiId, options ListByServiceOperationOptions, predicate ApiReleaseContractOperationPredicate) (resp ListByServiceCompleteResult, err error) { - items := make([]ApiReleaseContract, 0) - - page, err := c.ListByService(ctx, id, options) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListByServiceCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/apimanagement/2022-08-01/apirelease/method_update.go b/resource-manager/apimanagement/2022-08-01/apirelease/method_update.go new file mode 100644 index 00000000000..23af82628f6 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/apirelease/method_update.go @@ -0,0 +1,84 @@ +package apirelease + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ApiReleaseContract +} + +type UpdateOperationOptions struct { + IfMatch *string +} + +func DefaultUpdateOperationOptions() UpdateOperationOptions { + return UpdateOperationOptions{} +} + +func (o UpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o UpdateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o UpdateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// Update ... +func (c ApiReleaseClient) Update(ctx context.Context, id ReleaseId, input ApiReleaseContract, options UpdateOperationOptions) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + OptionsObject: options, + } + + 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/apimanagement/2022-08-01/apirelease/method_update_autorest.go b/resource-manager/apimanagement/2022-08-01/apirelease/method_update_autorest.go deleted file mode 100644 index b94e10e254e..00000000000 --- a/resource-manager/apimanagement/2022-08-01/apirelease/method_update_autorest.go +++ /dev/null @@ -1,98 +0,0 @@ -package apirelease - -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 *ApiReleaseContract -} - -type UpdateOperationOptions struct { - IfMatch *string -} - -func DefaultUpdateOperationOptions() UpdateOperationOptions { - return UpdateOperationOptions{} -} - -func (o UpdateOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o UpdateOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// Update ... -func (c ApiReleaseClient) Update(ctx context.Context, id ReleaseId, input ApiReleaseContract, options UpdateOperationOptions) (result UpdateOperationResponse, err error) { - req, err := c.preparerForUpdate(ctx, id, input, options) - if err != nil { - err = autorest.NewErrorWithError(err, "apirelease.ApiReleaseClient", "Update", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apirelease.ApiReleaseClient", "Update", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apirelease.ApiReleaseClient", "Update", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForUpdate prepares the Update request. -func (c ApiReleaseClient) preparerForUpdate(ctx context.Context, id ReleaseId, input ApiReleaseContract, options UpdateOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPatch(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - 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 ApiReleaseClient) 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/apimanagement/2022-08-01/apirevision/client.go b/resource-manager/apimanagement/2022-08-01/apirevision/client.go index 4f27298efa9..3efc0f7c9fe 100644 --- a/resource-manager/apimanagement/2022-08-01/apirevision/client.go +++ b/resource-manager/apimanagement/2022-08-01/apirevision/client.go @@ -1,18 +1,26 @@ package apirevision -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 ApiRevisionClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewApiRevisionClientWithBaseURI(endpoint string) ApiRevisionClient { - return ApiRevisionClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewApiRevisionClientWithBaseURI(api environments.Api) (*ApiRevisionClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "apirevision", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ApiRevisionClient: %+v", err) } + + return &ApiRevisionClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2022-08-01/apirevision/method_listbyservice.go b/resource-manager/apimanagement/2022-08-01/apirevision/method_listbyservice.go new file mode 100644 index 00000000000..ddc821890de --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/apirevision/method_listbyservice.go @@ -0,0 +1,125 @@ +package apirevision + +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 ListByServiceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ApiRevisionContract +} + +type ListByServiceCompleteResult struct { + Items []ApiRevisionContract +} + +type ListByServiceOperationOptions struct { + Filter *string + Skip *int64 + Top *int64 +} + +func DefaultListByServiceOperationOptions() ListByServiceOperationOptions { + return ListByServiceOperationOptions{} +} + +func (o ListByServiceOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListByServiceOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListByServiceOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.Skip != nil { + out.Append("$skip", fmt.Sprintf("%v", *o.Skip)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +// ListByService ... +func (c ApiRevisionClient) ListByService(ctx context.Context, id ApiId, options ListByServiceOperationOptions) (result ListByServiceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/revisions", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ApiRevisionContract `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByServiceComplete retrieves all the results into a single object +func (c ApiRevisionClient) ListByServiceComplete(ctx context.Context, id ApiId, options ListByServiceOperationOptions) (ListByServiceCompleteResult, error) { + return c.ListByServiceCompleteMatchingPredicate(ctx, id, options, ApiRevisionContractOperationPredicate{}) +} + +// ListByServiceCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ApiRevisionClient) ListByServiceCompleteMatchingPredicate(ctx context.Context, id ApiId, options ListByServiceOperationOptions, predicate ApiRevisionContractOperationPredicate) (result ListByServiceCompleteResult, err error) { + items := make([]ApiRevisionContract, 0) + + resp, err := c.ListByService(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByServiceCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/apimanagement/2022-08-01/apirevision/method_listbyservice_autorest.go b/resource-manager/apimanagement/2022-08-01/apirevision/method_listbyservice_autorest.go deleted file mode 100644 index 02f5fa345c9..00000000000 --- a/resource-manager/apimanagement/2022-08-01/apirevision/method_listbyservice_autorest.go +++ /dev/null @@ -1,225 +0,0 @@ -package apirevision - -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 ListByServiceOperationResponse struct { - HttpResponse *http.Response - Model *[]ApiRevisionContract - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListByServiceOperationResponse, error) -} - -type ListByServiceCompleteResult struct { - Items []ApiRevisionContract -} - -func (r ListByServiceOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListByServiceOperationResponse) LoadMore(ctx context.Context) (resp ListByServiceOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -type ListByServiceOperationOptions struct { - Filter *string - Skip *int64 - Top *int64 -} - -func DefaultListByServiceOperationOptions() ListByServiceOperationOptions { - return ListByServiceOperationOptions{} -} - -func (o ListByServiceOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o ListByServiceOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Filter != nil { - out["$filter"] = *o.Filter - } - - if o.Skip != nil { - out["$skip"] = *o.Skip - } - - if o.Top != nil { - out["$top"] = *o.Top - } - - return out -} - -// ListByService ... -func (c ApiRevisionClient) ListByService(ctx context.Context, id ApiId, options ListByServiceOperationOptions) (resp ListByServiceOperationResponse, err error) { - req, err := c.preparerForListByService(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "apirevision.ApiRevisionClient", "ListByService", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apirevision.ApiRevisionClient", "ListByService", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListByService(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apirevision.ApiRevisionClient", "ListByService", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListByService prepares the ListByService request. -func (c ApiRevisionClient) preparerForListByService(ctx context.Context, id ApiId, options ListByServiceOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/revisions", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListByServiceWithNextLink prepares the ListByService request with the given nextLink token. -func (c ApiRevisionClient) preparerForListByServiceWithNextLink(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)) -} - -// responderForListByService handles the response to the ListByService request. The method always -// closes the http.Response Body. -func (c ApiRevisionClient) responderForListByService(resp *http.Response) (result ListByServiceOperationResponse, err error) { - type page struct { - Values []ApiRevisionContract `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 ListByServiceOperationResponse, err error) { - req, err := c.preparerForListByServiceWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "apirevision.ApiRevisionClient", "ListByService", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apirevision.ApiRevisionClient", "ListByService", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByService(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apirevision.ApiRevisionClient", "ListByService", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListByServiceComplete retrieves all of the results into a single object -func (c ApiRevisionClient) ListByServiceComplete(ctx context.Context, id ApiId, options ListByServiceOperationOptions) (ListByServiceCompleteResult, error) { - return c.ListByServiceCompleteMatchingPredicate(ctx, id, options, ApiRevisionContractOperationPredicate{}) -} - -// ListByServiceCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c ApiRevisionClient) ListByServiceCompleteMatchingPredicate(ctx context.Context, id ApiId, options ListByServiceOperationOptions, predicate ApiRevisionContractOperationPredicate) (resp ListByServiceCompleteResult, err error) { - items := make([]ApiRevisionContract, 0) - - page, err := c.ListByService(ctx, id, options) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListByServiceCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/apimanagement/2022-08-01/apisbytag/client.go b/resource-manager/apimanagement/2022-08-01/apisbytag/client.go index 300fac77149..a2f766f24fe 100644 --- a/resource-manager/apimanagement/2022-08-01/apisbytag/client.go +++ b/resource-manager/apimanagement/2022-08-01/apisbytag/client.go @@ -1,18 +1,26 @@ package apisbytag -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 ApisByTagClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewApisByTagClientWithBaseURI(endpoint string) ApisByTagClient { - return ApisByTagClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewApisByTagClientWithBaseURI(api environments.Api) (*ApisByTagClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "apisbytag", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ApisByTagClient: %+v", err) } + + return &ApisByTagClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2022-08-01/apisbytag/constants.go b/resource-manager/apimanagement/2022-08-01/apisbytag/constants.go index 6f6b4ccc0c1..66e070901d4 100644 --- a/resource-manager/apimanagement/2022-08-01/apisbytag/constants.go +++ b/resource-manager/apimanagement/2022-08-01/apisbytag/constants.go @@ -1,6 +1,10 @@ package apisbytag -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 PossibleValuesForApiType() []string { } } +func (s *ApiType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseApiType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseApiType(input string) (*ApiType, error) { vals := map[string]ApiType{ "graphql": ApiTypeGraphql, @@ -53,6 +70,19 @@ func PossibleValuesForBearerTokenSendingMethods() []string { } } +func (s *BearerTokenSendingMethods) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseBearerTokenSendingMethods(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseBearerTokenSendingMethods(input string) (*BearerTokenSendingMethods, error) { vals := map[string]BearerTokenSendingMethods{ "authorizationheader": BearerTokenSendingMethodsAuthorizationHeader, @@ -81,6 +111,19 @@ func PossibleValuesForProductState() []string { } } +func (s *ProductState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProductState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseProductState(input string) (*ProductState, error) { vals := map[string]ProductState{ "notpublished": ProductStateNotPublished, @@ -113,6 +156,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{ "http": ProtocolHTTP, diff --git a/resource-manager/apimanagement/2022-08-01/apisbytag/method_apilistbytags.go b/resource-manager/apimanagement/2022-08-01/apisbytag/method_apilistbytags.go new file mode 100644 index 00000000000..80debd8f476 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/apisbytag/method_apilistbytags.go @@ -0,0 +1,129 @@ +package apisbytag + +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 ApiListByTagsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]TagResourceContract +} + +type ApiListByTagsCompleteResult struct { + Items []TagResourceContract +} + +type ApiListByTagsOperationOptions struct { + Filter *string + IncludeNotTaggedApis *bool + Skip *int64 + Top *int64 +} + +func DefaultApiListByTagsOperationOptions() ApiListByTagsOperationOptions { + return ApiListByTagsOperationOptions{} +} + +func (o ApiListByTagsOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ApiListByTagsOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ApiListByTagsOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.IncludeNotTaggedApis != nil { + out.Append("includeNotTaggedApis", fmt.Sprintf("%v", *o.IncludeNotTaggedApis)) + } + if o.Skip != nil { + out.Append("$skip", fmt.Sprintf("%v", *o.Skip)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +// ApiListByTags ... +func (c ApisByTagClient) ApiListByTags(ctx context.Context, id ServiceId, options ApiListByTagsOperationOptions) (result ApiListByTagsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/apisByTags", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]TagResourceContract `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ApiListByTagsComplete retrieves all the results into a single object +func (c ApisByTagClient) ApiListByTagsComplete(ctx context.Context, id ServiceId, options ApiListByTagsOperationOptions) (ApiListByTagsCompleteResult, error) { + return c.ApiListByTagsCompleteMatchingPredicate(ctx, id, options, TagResourceContractOperationPredicate{}) +} + +// ApiListByTagsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ApisByTagClient) ApiListByTagsCompleteMatchingPredicate(ctx context.Context, id ServiceId, options ApiListByTagsOperationOptions, predicate TagResourceContractOperationPredicate) (result ApiListByTagsCompleteResult, err error) { + items := make([]TagResourceContract, 0) + + resp, err := c.ApiListByTags(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ApiListByTagsCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/apimanagement/2022-08-01/apisbytag/method_apilistbytags_autorest.go b/resource-manager/apimanagement/2022-08-01/apisbytag/method_apilistbytags_autorest.go deleted file mode 100644 index 5cb4c9a2e49..00000000000 --- a/resource-manager/apimanagement/2022-08-01/apisbytag/method_apilistbytags_autorest.go +++ /dev/null @@ -1,230 +0,0 @@ -package apisbytag - -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 ApiListByTagsOperationResponse struct { - HttpResponse *http.Response - Model *[]TagResourceContract - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ApiListByTagsOperationResponse, error) -} - -type ApiListByTagsCompleteResult struct { - Items []TagResourceContract -} - -func (r ApiListByTagsOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ApiListByTagsOperationResponse) LoadMore(ctx context.Context) (resp ApiListByTagsOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -type ApiListByTagsOperationOptions struct { - Filter *string - IncludeNotTaggedApis *bool - Skip *int64 - Top *int64 -} - -func DefaultApiListByTagsOperationOptions() ApiListByTagsOperationOptions { - return ApiListByTagsOperationOptions{} -} - -func (o ApiListByTagsOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o ApiListByTagsOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Filter != nil { - out["$filter"] = *o.Filter - } - - if o.IncludeNotTaggedApis != nil { - out["includeNotTaggedApis"] = *o.IncludeNotTaggedApis - } - - if o.Skip != nil { - out["$skip"] = *o.Skip - } - - if o.Top != nil { - out["$top"] = *o.Top - } - - return out -} - -// ApiListByTags ... -func (c ApisByTagClient) ApiListByTags(ctx context.Context, id ServiceId, options ApiListByTagsOperationOptions) (resp ApiListByTagsOperationResponse, err error) { - req, err := c.preparerForApiListByTags(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "apisbytag.ApisByTagClient", "ApiListByTags", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apisbytag.ApisByTagClient", "ApiListByTags", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForApiListByTags(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apisbytag.ApisByTagClient", "ApiListByTags", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForApiListByTags prepares the ApiListByTags request. -func (c ApisByTagClient) preparerForApiListByTags(ctx context.Context, id ServiceId, options ApiListByTagsOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/apisByTags", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForApiListByTagsWithNextLink prepares the ApiListByTags request with the given nextLink token. -func (c ApisByTagClient) preparerForApiListByTagsWithNextLink(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)) -} - -// responderForApiListByTags handles the response to the ApiListByTags request. The method always -// closes the http.Response Body. -func (c ApisByTagClient) responderForApiListByTags(resp *http.Response) (result ApiListByTagsOperationResponse, err error) { - type page struct { - Values []TagResourceContract `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 ApiListByTagsOperationResponse, err error) { - req, err := c.preparerForApiListByTagsWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "apisbytag.ApisByTagClient", "ApiListByTags", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apisbytag.ApisByTagClient", "ApiListByTags", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForApiListByTags(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apisbytag.ApisByTagClient", "ApiListByTags", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ApiListByTagsComplete retrieves all of the results into a single object -func (c ApisByTagClient) ApiListByTagsComplete(ctx context.Context, id ServiceId, options ApiListByTagsOperationOptions) (ApiListByTagsCompleteResult, error) { - return c.ApiListByTagsCompleteMatchingPredicate(ctx, id, options, TagResourceContractOperationPredicate{}) -} - -// ApiListByTagsCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c ApisByTagClient) ApiListByTagsCompleteMatchingPredicate(ctx context.Context, id ServiceId, options ApiListByTagsOperationOptions, predicate TagResourceContractOperationPredicate) (resp ApiListByTagsCompleteResult, err error) { - items := make([]TagResourceContract, 0) - - page, err := c.ApiListByTags(ctx, id, options) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ApiListByTagsCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/apimanagement/2022-08-01/apischema/client.go b/resource-manager/apimanagement/2022-08-01/apischema/client.go index 1b7ddf09061..c958a1a817f 100644 --- a/resource-manager/apimanagement/2022-08-01/apischema/client.go +++ b/resource-manager/apimanagement/2022-08-01/apischema/client.go @@ -1,18 +1,26 @@ package apischema -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 ApiSchemaClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewApiSchemaClientWithBaseURI(endpoint string) ApiSchemaClient { - return ApiSchemaClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewApiSchemaClientWithBaseURI(api environments.Api) (*ApiSchemaClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "apischema", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ApiSchemaClient: %+v", err) } + + return &ApiSchemaClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2022-08-01/apischema/method_createorupdate.go b/resource-manager/apimanagement/2022-08-01/apischema/method_createorupdate.go new file mode 100644 index 00000000000..ee50a77ff43 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/apischema/method_createorupdate.go @@ -0,0 +1,103 @@ +package apischema + +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 +} + +type CreateOrUpdateOperationOptions struct { + IfMatch *string +} + +func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { + return CreateOrUpdateOperationOptions{} +} + +func (o CreateOrUpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o CreateOrUpdateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o CreateOrUpdateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// CreateOrUpdate ... +func (c ApiSchemaClient) CreateOrUpdate(ctx context.Context, id ApiSchemaId, input SchemaContract, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + OptionsObject: options, + } + + 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 ApiSchemaClient) CreateOrUpdateThenPoll(ctx context.Context, id ApiSchemaId, input SchemaContract, options CreateOrUpdateOperationOptions) error { + result, err := c.CreateOrUpdate(ctx, id, input, options) + 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/apimanagement/2022-08-01/apischema/method_createorupdate_autorest.go b/resource-manager/apimanagement/2022-08-01/apischema/method_createorupdate_autorest.go deleted file mode 100644 index b66a431a79b..00000000000 --- a/resource-manager/apimanagement/2022-08-01/apischema/method_createorupdate_autorest.go +++ /dev/null @@ -1,108 +0,0 @@ -package apischema - -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 -} - -type CreateOrUpdateOperationOptions struct { - IfMatch *string -} - -func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { - return CreateOrUpdateOperationOptions{} -} - -func (o CreateOrUpdateOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o CreateOrUpdateOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// CreateOrUpdate ... -func (c ApiSchemaClient) CreateOrUpdate(ctx context.Context, id ApiSchemaId, input SchemaContract, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdate(ctx, id, input, options) - if err != nil { - err = autorest.NewErrorWithError(err, "apischema.ApiSchemaClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result, err = c.senderForCreateOrUpdate(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "apischema.ApiSchemaClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed -func (c ApiSchemaClient) CreateOrUpdateThenPoll(ctx context.Context, id ApiSchemaId, input SchemaContract, options CreateOrUpdateOperationOptions) error { - result, err := c.CreateOrUpdate(ctx, id, input, options) - 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 ApiSchemaClient) preparerForCreateOrUpdate(ctx context.Context, id ApiSchemaId, input SchemaContract, options CreateOrUpdateOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - 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 ApiSchemaClient) 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/apimanagement/2022-08-01/apischema/method_delete.go b/resource-manager/apimanagement/2022-08-01/apischema/method_delete.go new file mode 100644 index 00000000000..6fab6914573 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/apischema/method_delete.go @@ -0,0 +1,79 @@ +package apischema + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +type DeleteOperationOptions struct { + Force *bool + IfMatch *string +} + +func DefaultDeleteOperationOptions() DeleteOperationOptions { + return DeleteOperationOptions{} +} + +func (o DeleteOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o DeleteOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o DeleteOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Force != nil { + out.Append("force", fmt.Sprintf("%v", *o.Force)) + } + return &out +} + +// Delete ... +func (c ApiSchemaClient) Delete(ctx context.Context, id ApiSchemaId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2022-08-01/apischema/method_delete_autorest.go b/resource-manager/apimanagement/2022-08-01/apischema/method_delete_autorest.go deleted file mode 100644 index 861123ba5f1..00000000000 --- a/resource-manager/apimanagement/2022-08-01/apischema/method_delete_autorest.go +++ /dev/null @@ -1,100 +0,0 @@ -package apischema - -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 DeleteOperationResponse struct { - HttpResponse *http.Response -} - -type DeleteOperationOptions struct { - Force *bool - IfMatch *string -} - -func DefaultDeleteOperationOptions() DeleteOperationOptions { - return DeleteOperationOptions{} -} - -func (o DeleteOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o DeleteOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Force != nil { - out["force"] = *o.Force - } - - return out -} - -// Delete ... -func (c ApiSchemaClient) Delete(ctx context.Context, id ApiSchemaId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { - req, err := c.preparerForDelete(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "apischema.ApiSchemaClient", "Delete", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apischema.ApiSchemaClient", "Delete", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForDelete(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apischema.ApiSchemaClient", "Delete", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForDelete prepares the Delete request. -func (c ApiSchemaClient) preparerForDelete(ctx context.Context, id ApiSchemaId, options DeleteOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForDelete handles the response to the Delete request. The method always -// closes the http.Response Body. -func (c ApiSchemaClient) responderForDelete(resp *http.Response) (result DeleteOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2022-08-01/apischema/method_get.go b/resource-manager/apimanagement/2022-08-01/apischema/method_get.go new file mode 100644 index 00000000000..544b5401b16 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/apischema/method_get.go @@ -0,0 +1,51 @@ +package apischema + +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 *SchemaContract +} + +// Get ... +func (c ApiSchemaClient) Get(ctx context.Context, id ApiSchemaId) (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/apimanagement/2022-08-01/apischema/method_get_autorest.go b/resource-manager/apimanagement/2022-08-01/apischema/method_get_autorest.go deleted file mode 100644 index a2f6ed627d0..00000000000 --- a/resource-manager/apimanagement/2022-08-01/apischema/method_get_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package apischema - -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 *SchemaContract -} - -// Get ... -func (c ApiSchemaClient) Get(ctx context.Context, id ApiSchemaId) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "apischema.ApiSchemaClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apischema.ApiSchemaClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apischema.ApiSchemaClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c ApiSchemaClient) preparerForGet(ctx context.Context, id ApiSchemaId) (*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 ApiSchemaClient) 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/apimanagement/2022-08-01/apischema/method_getentitytag.go b/resource-manager/apimanagement/2022-08-01/apischema/method_getentitytag.go new file mode 100644 index 00000000000..06aa5ede3ba --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/apischema/method_getentitytag.go @@ -0,0 +1,46 @@ +package apischema + +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 GetEntityTagOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// GetEntityTag ... +func (c ApiSchemaClient) GetEntityTag(ctx context.Context, id ApiSchemaId) (result GetEntityTagOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodHead, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2022-08-01/apischema/method_getentitytag_autorest.go b/resource-manager/apimanagement/2022-08-01/apischema/method_getentitytag_autorest.go deleted file mode 100644 index fc901aa3419..00000000000 --- a/resource-manager/apimanagement/2022-08-01/apischema/method_getentitytag_autorest.go +++ /dev/null @@ -1,66 +0,0 @@ -package apischema - -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 GetEntityTagOperationResponse struct { - HttpResponse *http.Response -} - -// GetEntityTag ... -func (c ApiSchemaClient) GetEntityTag(ctx context.Context, id ApiSchemaId) (result GetEntityTagOperationResponse, err error) { - req, err := c.preparerForGetEntityTag(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "apischema.ApiSchemaClient", "GetEntityTag", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apischema.ApiSchemaClient", "GetEntityTag", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetEntityTag(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apischema.ApiSchemaClient", "GetEntityTag", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetEntityTag prepares the GetEntityTag request. -func (c ApiSchemaClient) preparerForGetEntityTag(ctx context.Context, id ApiSchemaId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsHead(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetEntityTag handles the response to the GetEntityTag request. The method always -// closes the http.Response Body. -func (c ApiSchemaClient) responderForGetEntityTag(resp *http.Response) (result GetEntityTagOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2022-08-01/apischema/method_listbyapi.go b/resource-manager/apimanagement/2022-08-01/apischema/method_listbyapi.go new file mode 100644 index 00000000000..8486736bbe2 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/apischema/method_listbyapi.go @@ -0,0 +1,125 @@ +package apischema + +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 ListByApiOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]SchemaContract +} + +type ListByApiCompleteResult struct { + Items []SchemaContract +} + +type ListByApiOperationOptions struct { + Filter *string + Skip *int64 + Top *int64 +} + +func DefaultListByApiOperationOptions() ListByApiOperationOptions { + return ListByApiOperationOptions{} +} + +func (o ListByApiOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListByApiOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListByApiOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.Skip != nil { + out.Append("$skip", fmt.Sprintf("%v", *o.Skip)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +// ListByApi ... +func (c ApiSchemaClient) ListByApi(ctx context.Context, id ApiId, options ListByApiOperationOptions) (result ListByApiOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/schemas", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]SchemaContract `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByApiComplete retrieves all the results into a single object +func (c ApiSchemaClient) ListByApiComplete(ctx context.Context, id ApiId, options ListByApiOperationOptions) (ListByApiCompleteResult, error) { + return c.ListByApiCompleteMatchingPredicate(ctx, id, options, SchemaContractOperationPredicate{}) +} + +// ListByApiCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ApiSchemaClient) ListByApiCompleteMatchingPredicate(ctx context.Context, id ApiId, options ListByApiOperationOptions, predicate SchemaContractOperationPredicate) (result ListByApiCompleteResult, err error) { + items := make([]SchemaContract, 0) + + resp, err := c.ListByApi(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByApiCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/apimanagement/2022-08-01/apischema/method_listbyapi_autorest.go b/resource-manager/apimanagement/2022-08-01/apischema/method_listbyapi_autorest.go deleted file mode 100644 index c29a0ea33a5..00000000000 --- a/resource-manager/apimanagement/2022-08-01/apischema/method_listbyapi_autorest.go +++ /dev/null @@ -1,225 +0,0 @@ -package apischema - -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 ListByApiOperationResponse struct { - HttpResponse *http.Response - Model *[]SchemaContract - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListByApiOperationResponse, error) -} - -type ListByApiCompleteResult struct { - Items []SchemaContract -} - -func (r ListByApiOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListByApiOperationResponse) LoadMore(ctx context.Context) (resp ListByApiOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -type ListByApiOperationOptions struct { - Filter *string - Skip *int64 - Top *int64 -} - -func DefaultListByApiOperationOptions() ListByApiOperationOptions { - return ListByApiOperationOptions{} -} - -func (o ListByApiOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o ListByApiOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Filter != nil { - out["$filter"] = *o.Filter - } - - if o.Skip != nil { - out["$skip"] = *o.Skip - } - - if o.Top != nil { - out["$top"] = *o.Top - } - - return out -} - -// ListByApi ... -func (c ApiSchemaClient) ListByApi(ctx context.Context, id ApiId, options ListByApiOperationOptions) (resp ListByApiOperationResponse, err error) { - req, err := c.preparerForListByApi(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "apischema.ApiSchemaClient", "ListByApi", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apischema.ApiSchemaClient", "ListByApi", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListByApi(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apischema.ApiSchemaClient", "ListByApi", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListByApi prepares the ListByApi request. -func (c ApiSchemaClient) preparerForListByApi(ctx context.Context, id ApiId, options ListByApiOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/schemas", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListByApiWithNextLink prepares the ListByApi request with the given nextLink token. -func (c ApiSchemaClient) preparerForListByApiWithNextLink(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)) -} - -// responderForListByApi handles the response to the ListByApi request. The method always -// closes the http.Response Body. -func (c ApiSchemaClient) responderForListByApi(resp *http.Response) (result ListByApiOperationResponse, err error) { - type page struct { - Values []SchemaContract `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 ListByApiOperationResponse, err error) { - req, err := c.preparerForListByApiWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "apischema.ApiSchemaClient", "ListByApi", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apischema.ApiSchemaClient", "ListByApi", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByApi(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apischema.ApiSchemaClient", "ListByApi", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListByApiComplete retrieves all of the results into a single object -func (c ApiSchemaClient) ListByApiComplete(ctx context.Context, id ApiId, options ListByApiOperationOptions) (ListByApiCompleteResult, error) { - return c.ListByApiCompleteMatchingPredicate(ctx, id, options, SchemaContractOperationPredicate{}) -} - -// ListByApiCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c ApiSchemaClient) ListByApiCompleteMatchingPredicate(ctx context.Context, id ApiId, options ListByApiOperationOptions, predicate SchemaContractOperationPredicate) (resp ListByApiCompleteResult, err error) { - items := make([]SchemaContract, 0) - - page, err := c.ListByApi(ctx, id, options) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListByApiCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/apimanagement/2022-08-01/apitag/client.go b/resource-manager/apimanagement/2022-08-01/apitag/client.go index 6224a081278..3bf88479c6c 100644 --- a/resource-manager/apimanagement/2022-08-01/apitag/client.go +++ b/resource-manager/apimanagement/2022-08-01/apitag/client.go @@ -1,18 +1,26 @@ package apitag -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 ApiTagClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewApiTagClientWithBaseURI(endpoint string) ApiTagClient { - return ApiTagClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewApiTagClientWithBaseURI(api environments.Api) (*ApiTagClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "apitag", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ApiTagClient: %+v", err) } + + return &ApiTagClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2022-08-01/apitag/method_tagassigntoapi.go b/resource-manager/apimanagement/2022-08-01/apitag/method_tagassigntoapi.go new file mode 100644 index 00000000000..96c964a74bd --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/apitag/method_tagassigntoapi.go @@ -0,0 +1,52 @@ +package apitag + +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 TagAssignToApiOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *TagContract +} + +// TagAssignToApi ... +func (c ApiTagClient) TagAssignToApi(ctx context.Context, id ApiTagId) (result TagAssignToApiOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + 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/apimanagement/2022-08-01/apitag/method_tagassigntoapi_autorest.go b/resource-manager/apimanagement/2022-08-01/apitag/method_tagassigntoapi_autorest.go deleted file mode 100644 index e08a016a227..00000000000 --- a/resource-manager/apimanagement/2022-08-01/apitag/method_tagassigntoapi_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package apitag - -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 TagAssignToApiOperationResponse struct { - HttpResponse *http.Response - Model *TagContract -} - -// TagAssignToApi ... -func (c ApiTagClient) TagAssignToApi(ctx context.Context, id ApiTagId) (result TagAssignToApiOperationResponse, err error) { - req, err := c.preparerForTagAssignToApi(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "apitag.ApiTagClient", "TagAssignToApi", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apitag.ApiTagClient", "TagAssignToApi", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForTagAssignToApi(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apitag.ApiTagClient", "TagAssignToApi", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForTagAssignToApi prepares the TagAssignToApi request. -func (c ApiTagClient) preparerForTagAssignToApi(ctx context.Context, id ApiTagId) (*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.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForTagAssignToApi handles the response to the TagAssignToApi request. The method always -// closes the http.Response Body. -func (c ApiTagClient) responderForTagAssignToApi(resp *http.Response) (result TagAssignToApiOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2022-08-01/apitag/method_tagdetachfromapi.go b/resource-manager/apimanagement/2022-08-01/apitag/method_tagdetachfromapi.go new file mode 100644 index 00000000000..ad546cf7c3c --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/apitag/method_tagdetachfromapi.go @@ -0,0 +1,47 @@ +package apitag + +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 TagDetachFromApiOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// TagDetachFromApi ... +func (c ApiTagClient) TagDetachFromApi(ctx context.Context, id ApiTagId) (result TagDetachFromApiOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2022-08-01/apitag/method_tagdetachfromapi_autorest.go b/resource-manager/apimanagement/2022-08-01/apitag/method_tagdetachfromapi_autorest.go deleted file mode 100644 index e7ecb70287d..00000000000 --- a/resource-manager/apimanagement/2022-08-01/apitag/method_tagdetachfromapi_autorest.go +++ /dev/null @@ -1,66 +0,0 @@ -package apitag - -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 TagDetachFromApiOperationResponse struct { - HttpResponse *http.Response -} - -// TagDetachFromApi ... -func (c ApiTagClient) TagDetachFromApi(ctx context.Context, id ApiTagId) (result TagDetachFromApiOperationResponse, err error) { - req, err := c.preparerForTagDetachFromApi(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "apitag.ApiTagClient", "TagDetachFromApi", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apitag.ApiTagClient", "TagDetachFromApi", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForTagDetachFromApi(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apitag.ApiTagClient", "TagDetachFromApi", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForTagDetachFromApi prepares the TagDetachFromApi request. -func (c ApiTagClient) preparerForTagDetachFromApi(ctx context.Context, id ApiTagId) (*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)) -} - -// responderForTagDetachFromApi handles the response to the TagDetachFromApi request. The method always -// closes the http.Response Body. -func (c ApiTagClient) responderForTagDetachFromApi(resp *http.Response) (result TagDetachFromApiOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2022-08-01/apitag/method_taggetbyapi.go b/resource-manager/apimanagement/2022-08-01/apitag/method_taggetbyapi.go new file mode 100644 index 00000000000..97876d1178c --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/apitag/method_taggetbyapi.go @@ -0,0 +1,51 @@ +package apitag + +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 TagGetByApiOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *TagContract +} + +// TagGetByApi ... +func (c ApiTagClient) TagGetByApi(ctx context.Context, id ApiTagId) (result TagGetByApiOperationResponse, 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/apimanagement/2022-08-01/apitag/method_taggetbyapi_autorest.go b/resource-manager/apimanagement/2022-08-01/apitag/method_taggetbyapi_autorest.go deleted file mode 100644 index cdc7b57c932..00000000000 --- a/resource-manager/apimanagement/2022-08-01/apitag/method_taggetbyapi_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package apitag - -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 TagGetByApiOperationResponse struct { - HttpResponse *http.Response - Model *TagContract -} - -// TagGetByApi ... -func (c ApiTagClient) TagGetByApi(ctx context.Context, id ApiTagId) (result TagGetByApiOperationResponse, err error) { - req, err := c.preparerForTagGetByApi(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "apitag.ApiTagClient", "TagGetByApi", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apitag.ApiTagClient", "TagGetByApi", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForTagGetByApi(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apitag.ApiTagClient", "TagGetByApi", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForTagGetByApi prepares the TagGetByApi request. -func (c ApiTagClient) preparerForTagGetByApi(ctx context.Context, id ApiTagId) (*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)) -} - -// responderForTagGetByApi handles the response to the TagGetByApi request. The method always -// closes the http.Response Body. -func (c ApiTagClient) responderForTagGetByApi(resp *http.Response) (result TagGetByApiOperationResponse, 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/apimanagement/2022-08-01/apitag/method_taggetentitystatebyapi.go b/resource-manager/apimanagement/2022-08-01/apitag/method_taggetentitystatebyapi.go new file mode 100644 index 00000000000..eb833e96b2a --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/apitag/method_taggetentitystatebyapi.go @@ -0,0 +1,46 @@ +package apitag + +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 TagGetEntityStateByApiOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// TagGetEntityStateByApi ... +func (c ApiTagClient) TagGetEntityStateByApi(ctx context.Context, id ApiTagId) (result TagGetEntityStateByApiOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodHead, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2022-08-01/apitag/method_taggetentitystatebyapi_autorest.go b/resource-manager/apimanagement/2022-08-01/apitag/method_taggetentitystatebyapi_autorest.go deleted file mode 100644 index f0c60a63c86..00000000000 --- a/resource-manager/apimanagement/2022-08-01/apitag/method_taggetentitystatebyapi_autorest.go +++ /dev/null @@ -1,66 +0,0 @@ -package apitag - -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 TagGetEntityStateByApiOperationResponse struct { - HttpResponse *http.Response -} - -// TagGetEntityStateByApi ... -func (c ApiTagClient) TagGetEntityStateByApi(ctx context.Context, id ApiTagId) (result TagGetEntityStateByApiOperationResponse, err error) { - req, err := c.preparerForTagGetEntityStateByApi(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "apitag.ApiTagClient", "TagGetEntityStateByApi", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apitag.ApiTagClient", "TagGetEntityStateByApi", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForTagGetEntityStateByApi(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apitag.ApiTagClient", "TagGetEntityStateByApi", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForTagGetEntityStateByApi prepares the TagGetEntityStateByApi request. -func (c ApiTagClient) preparerForTagGetEntityStateByApi(ctx context.Context, id ApiTagId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsHead(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForTagGetEntityStateByApi handles the response to the TagGetEntityStateByApi request. The method always -// closes the http.Response Body. -func (c ApiTagClient) responderForTagGetEntityStateByApi(resp *http.Response) (result TagGetEntityStateByApiOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2022-08-01/apitag/method_taglistbyapi.go b/resource-manager/apimanagement/2022-08-01/apitag/method_taglistbyapi.go new file mode 100644 index 00000000000..9ab4d2bb22c --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/apitag/method_taglistbyapi.go @@ -0,0 +1,125 @@ +package apitag + +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 TagListByApiOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]TagContract +} + +type TagListByApiCompleteResult struct { + Items []TagContract +} + +type TagListByApiOperationOptions struct { + Filter *string + Skip *int64 + Top *int64 +} + +func DefaultTagListByApiOperationOptions() TagListByApiOperationOptions { + return TagListByApiOperationOptions{} +} + +func (o TagListByApiOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o TagListByApiOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o TagListByApiOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.Skip != nil { + out.Append("$skip", fmt.Sprintf("%v", *o.Skip)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +// TagListByApi ... +func (c ApiTagClient) TagListByApi(ctx context.Context, id ApiId, options TagListByApiOperationOptions) (result TagListByApiOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/tags", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]TagContract `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// TagListByApiComplete retrieves all the results into a single object +func (c ApiTagClient) TagListByApiComplete(ctx context.Context, id ApiId, options TagListByApiOperationOptions) (TagListByApiCompleteResult, error) { + return c.TagListByApiCompleteMatchingPredicate(ctx, id, options, TagContractOperationPredicate{}) +} + +// TagListByApiCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ApiTagClient) TagListByApiCompleteMatchingPredicate(ctx context.Context, id ApiId, options TagListByApiOperationOptions, predicate TagContractOperationPredicate) (result TagListByApiCompleteResult, err error) { + items := make([]TagContract, 0) + + resp, err := c.TagListByApi(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = TagListByApiCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/apimanagement/2022-08-01/apitag/method_taglistbyapi_autorest.go b/resource-manager/apimanagement/2022-08-01/apitag/method_taglistbyapi_autorest.go deleted file mode 100644 index 750fb144087..00000000000 --- a/resource-manager/apimanagement/2022-08-01/apitag/method_taglistbyapi_autorest.go +++ /dev/null @@ -1,225 +0,0 @@ -package apitag - -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 TagListByApiOperationResponse struct { - HttpResponse *http.Response - Model *[]TagContract - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (TagListByApiOperationResponse, error) -} - -type TagListByApiCompleteResult struct { - Items []TagContract -} - -func (r TagListByApiOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r TagListByApiOperationResponse) LoadMore(ctx context.Context) (resp TagListByApiOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -type TagListByApiOperationOptions struct { - Filter *string - Skip *int64 - Top *int64 -} - -func DefaultTagListByApiOperationOptions() TagListByApiOperationOptions { - return TagListByApiOperationOptions{} -} - -func (o TagListByApiOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o TagListByApiOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Filter != nil { - out["$filter"] = *o.Filter - } - - if o.Skip != nil { - out["$skip"] = *o.Skip - } - - if o.Top != nil { - out["$top"] = *o.Top - } - - return out -} - -// TagListByApi ... -func (c ApiTagClient) TagListByApi(ctx context.Context, id ApiId, options TagListByApiOperationOptions) (resp TagListByApiOperationResponse, err error) { - req, err := c.preparerForTagListByApi(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "apitag.ApiTagClient", "TagListByApi", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apitag.ApiTagClient", "TagListByApi", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForTagListByApi(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apitag.ApiTagClient", "TagListByApi", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForTagListByApi prepares the TagListByApi request. -func (c ApiTagClient) preparerForTagListByApi(ctx context.Context, id ApiId, options TagListByApiOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/tags", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForTagListByApiWithNextLink prepares the TagListByApi request with the given nextLink token. -func (c ApiTagClient) preparerForTagListByApiWithNextLink(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)) -} - -// responderForTagListByApi handles the response to the TagListByApi request. The method always -// closes the http.Response Body. -func (c ApiTagClient) responderForTagListByApi(resp *http.Response) (result TagListByApiOperationResponse, err error) { - type page struct { - Values []TagContract `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 TagListByApiOperationResponse, err error) { - req, err := c.preparerForTagListByApiWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "apitag.ApiTagClient", "TagListByApi", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apitag.ApiTagClient", "TagListByApi", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForTagListByApi(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apitag.ApiTagClient", "TagListByApi", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// TagListByApiComplete retrieves all of the results into a single object -func (c ApiTagClient) TagListByApiComplete(ctx context.Context, id ApiId, options TagListByApiOperationOptions) (TagListByApiCompleteResult, error) { - return c.TagListByApiCompleteMatchingPredicate(ctx, id, options, TagContractOperationPredicate{}) -} - -// TagListByApiCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c ApiTagClient) TagListByApiCompleteMatchingPredicate(ctx context.Context, id ApiId, options TagListByApiOperationOptions, predicate TagContractOperationPredicate) (resp TagListByApiCompleteResult, err error) { - items := make([]TagContract, 0) - - page, err := c.TagListByApi(ctx, id, options) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := TagListByApiCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/apimanagement/2022-08-01/apitagdescription/client.go b/resource-manager/apimanagement/2022-08-01/apitagdescription/client.go index e11c12678bb..dc91413d9ab 100644 --- a/resource-manager/apimanagement/2022-08-01/apitagdescription/client.go +++ b/resource-manager/apimanagement/2022-08-01/apitagdescription/client.go @@ -1,18 +1,26 @@ package apitagdescription -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 ApiTagDescriptionClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewApiTagDescriptionClientWithBaseURI(endpoint string) ApiTagDescriptionClient { - return ApiTagDescriptionClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewApiTagDescriptionClientWithBaseURI(api environments.Api) (*ApiTagDescriptionClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "apitagdescription", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ApiTagDescriptionClient: %+v", err) } + + return &ApiTagDescriptionClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2022-08-01/apitagdescription/method_createorupdate.go b/resource-manager/apimanagement/2022-08-01/apitagdescription/method_createorupdate.go new file mode 100644 index 00000000000..08f839f5fe5 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/apitagdescription/method_createorupdate.go @@ -0,0 +1,85 @@ +package apitagdescription + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *TagDescriptionContract +} + +type CreateOrUpdateOperationOptions struct { + IfMatch *string +} + +func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { + return CreateOrUpdateOperationOptions{} +} + +func (o CreateOrUpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o CreateOrUpdateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o CreateOrUpdateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// CreateOrUpdate ... +func (c ApiTagDescriptionClient) CreateOrUpdate(ctx context.Context, id TagDescriptionId, input TagDescriptionCreateParameters, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + OptionsObject: options, + } + + 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/apimanagement/2022-08-01/apitagdescription/method_createorupdate_autorest.go b/resource-manager/apimanagement/2022-08-01/apitagdescription/method_createorupdate_autorest.go deleted file mode 100644 index 876ae7520b3..00000000000 --- a/resource-manager/apimanagement/2022-08-01/apitagdescription/method_createorupdate_autorest.go +++ /dev/null @@ -1,98 +0,0 @@ -package apitagdescription - -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 *TagDescriptionContract -} - -type CreateOrUpdateOperationOptions struct { - IfMatch *string -} - -func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { - return CreateOrUpdateOperationOptions{} -} - -func (o CreateOrUpdateOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o CreateOrUpdateOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// CreateOrUpdate ... -func (c ApiTagDescriptionClient) CreateOrUpdate(ctx context.Context, id TagDescriptionId, input TagDescriptionCreateParameters, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdate(ctx, id, input, options) - if err != nil { - err = autorest.NewErrorWithError(err, "apitagdescription.ApiTagDescriptionClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apitagdescription.ApiTagDescriptionClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCreateOrUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apitagdescription.ApiTagDescriptionClient", "CreateOrUpdate", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCreateOrUpdate prepares the CreateOrUpdate request. -func (c ApiTagDescriptionClient) preparerForCreateOrUpdate(ctx context.Context, id TagDescriptionId, input TagDescriptionCreateParameters, options CreateOrUpdateOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - 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 ApiTagDescriptionClient) responderForCreateOrUpdate(resp *http.Response) (result CreateOrUpdateOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2022-08-01/apitagdescription/method_delete.go b/resource-manager/apimanagement/2022-08-01/apitagdescription/method_delete.go new file mode 100644 index 00000000000..bc50e1495af --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/apitagdescription/method_delete.go @@ -0,0 +1,76 @@ +package apitagdescription + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +type DeleteOperationOptions struct { + IfMatch *string +} + +func DefaultDeleteOperationOptions() DeleteOperationOptions { + return DeleteOperationOptions{} +} + +func (o DeleteOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o DeleteOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o DeleteOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// Delete ... +func (c ApiTagDescriptionClient) Delete(ctx context.Context, id TagDescriptionId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2022-08-01/apitagdescription/method_delete_autorest.go b/resource-manager/apimanagement/2022-08-01/apitagdescription/method_delete_autorest.go deleted file mode 100644 index a383875ca12..00000000000 --- a/resource-manager/apimanagement/2022-08-01/apitagdescription/method_delete_autorest.go +++ /dev/null @@ -1,95 +0,0 @@ -package apitagdescription - -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 DeleteOperationResponse struct { - HttpResponse *http.Response -} - -type DeleteOperationOptions struct { - IfMatch *string -} - -func DefaultDeleteOperationOptions() DeleteOperationOptions { - return DeleteOperationOptions{} -} - -func (o DeleteOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o DeleteOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// Delete ... -func (c ApiTagDescriptionClient) Delete(ctx context.Context, id TagDescriptionId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { - req, err := c.preparerForDelete(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "apitagdescription.ApiTagDescriptionClient", "Delete", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apitagdescription.ApiTagDescriptionClient", "Delete", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForDelete(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apitagdescription.ApiTagDescriptionClient", "Delete", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForDelete prepares the Delete request. -func (c ApiTagDescriptionClient) preparerForDelete(ctx context.Context, id TagDescriptionId, options DeleteOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForDelete handles the response to the Delete request. The method always -// closes the http.Response Body. -func (c ApiTagDescriptionClient) responderForDelete(resp *http.Response) (result DeleteOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2022-08-01/apitagdescription/method_get.go b/resource-manager/apimanagement/2022-08-01/apitagdescription/method_get.go new file mode 100644 index 00000000000..b4eb50d639b --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/apitagdescription/method_get.go @@ -0,0 +1,51 @@ +package apitagdescription + +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 *TagDescriptionContract +} + +// Get ... +func (c ApiTagDescriptionClient) Get(ctx context.Context, id TagDescriptionId) (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/apimanagement/2022-08-01/apitagdescription/method_get_autorest.go b/resource-manager/apimanagement/2022-08-01/apitagdescription/method_get_autorest.go deleted file mode 100644 index 062aee3683f..00000000000 --- a/resource-manager/apimanagement/2022-08-01/apitagdescription/method_get_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package apitagdescription - -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 *TagDescriptionContract -} - -// Get ... -func (c ApiTagDescriptionClient) Get(ctx context.Context, id TagDescriptionId) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "apitagdescription.ApiTagDescriptionClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apitagdescription.ApiTagDescriptionClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apitagdescription.ApiTagDescriptionClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c ApiTagDescriptionClient) preparerForGet(ctx context.Context, id TagDescriptionId) (*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 ApiTagDescriptionClient) 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/apimanagement/2022-08-01/apitagdescription/method_getentitytag.go b/resource-manager/apimanagement/2022-08-01/apitagdescription/method_getentitytag.go new file mode 100644 index 00000000000..1db8e6e13d4 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/apitagdescription/method_getentitytag.go @@ -0,0 +1,46 @@ +package apitagdescription + +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 GetEntityTagOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// GetEntityTag ... +func (c ApiTagDescriptionClient) GetEntityTag(ctx context.Context, id TagDescriptionId) (result GetEntityTagOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodHead, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2022-08-01/apitagdescription/method_getentitytag_autorest.go b/resource-manager/apimanagement/2022-08-01/apitagdescription/method_getentitytag_autorest.go deleted file mode 100644 index f75e60f2cdd..00000000000 --- a/resource-manager/apimanagement/2022-08-01/apitagdescription/method_getentitytag_autorest.go +++ /dev/null @@ -1,66 +0,0 @@ -package apitagdescription - -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 GetEntityTagOperationResponse struct { - HttpResponse *http.Response -} - -// GetEntityTag ... -func (c ApiTagDescriptionClient) GetEntityTag(ctx context.Context, id TagDescriptionId) (result GetEntityTagOperationResponse, err error) { - req, err := c.preparerForGetEntityTag(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "apitagdescription.ApiTagDescriptionClient", "GetEntityTag", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apitagdescription.ApiTagDescriptionClient", "GetEntityTag", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetEntityTag(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apitagdescription.ApiTagDescriptionClient", "GetEntityTag", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetEntityTag prepares the GetEntityTag request. -func (c ApiTagDescriptionClient) preparerForGetEntityTag(ctx context.Context, id TagDescriptionId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsHead(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetEntityTag handles the response to the GetEntityTag request. The method always -// closes the http.Response Body. -func (c ApiTagDescriptionClient) responderForGetEntityTag(resp *http.Response) (result GetEntityTagOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2022-08-01/apitagdescription/method_listbyservice.go b/resource-manager/apimanagement/2022-08-01/apitagdescription/method_listbyservice.go new file mode 100644 index 00000000000..ccc6ebbef03 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/apitagdescription/method_listbyservice.go @@ -0,0 +1,125 @@ +package apitagdescription + +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 ListByServiceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]TagDescriptionContract +} + +type ListByServiceCompleteResult struct { + Items []TagDescriptionContract +} + +type ListByServiceOperationOptions struct { + Filter *string + Skip *int64 + Top *int64 +} + +func DefaultListByServiceOperationOptions() ListByServiceOperationOptions { + return ListByServiceOperationOptions{} +} + +func (o ListByServiceOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListByServiceOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListByServiceOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.Skip != nil { + out.Append("$skip", fmt.Sprintf("%v", *o.Skip)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +// ListByService ... +func (c ApiTagDescriptionClient) ListByService(ctx context.Context, id ApiId, options ListByServiceOperationOptions) (result ListByServiceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/tagDescriptions", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]TagDescriptionContract `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByServiceComplete retrieves all the results into a single object +func (c ApiTagDescriptionClient) ListByServiceComplete(ctx context.Context, id ApiId, options ListByServiceOperationOptions) (ListByServiceCompleteResult, error) { + return c.ListByServiceCompleteMatchingPredicate(ctx, id, options, TagDescriptionContractOperationPredicate{}) +} + +// ListByServiceCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ApiTagDescriptionClient) ListByServiceCompleteMatchingPredicate(ctx context.Context, id ApiId, options ListByServiceOperationOptions, predicate TagDescriptionContractOperationPredicate) (result ListByServiceCompleteResult, err error) { + items := make([]TagDescriptionContract, 0) + + resp, err := c.ListByService(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByServiceCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/apimanagement/2022-08-01/apitagdescription/method_listbyservice_autorest.go b/resource-manager/apimanagement/2022-08-01/apitagdescription/method_listbyservice_autorest.go deleted file mode 100644 index d6970e826db..00000000000 --- a/resource-manager/apimanagement/2022-08-01/apitagdescription/method_listbyservice_autorest.go +++ /dev/null @@ -1,225 +0,0 @@ -package apitagdescription - -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 ListByServiceOperationResponse struct { - HttpResponse *http.Response - Model *[]TagDescriptionContract - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListByServiceOperationResponse, error) -} - -type ListByServiceCompleteResult struct { - Items []TagDescriptionContract -} - -func (r ListByServiceOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListByServiceOperationResponse) LoadMore(ctx context.Context) (resp ListByServiceOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -type ListByServiceOperationOptions struct { - Filter *string - Skip *int64 - Top *int64 -} - -func DefaultListByServiceOperationOptions() ListByServiceOperationOptions { - return ListByServiceOperationOptions{} -} - -func (o ListByServiceOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o ListByServiceOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Filter != nil { - out["$filter"] = *o.Filter - } - - if o.Skip != nil { - out["$skip"] = *o.Skip - } - - if o.Top != nil { - out["$top"] = *o.Top - } - - return out -} - -// ListByService ... -func (c ApiTagDescriptionClient) ListByService(ctx context.Context, id ApiId, options ListByServiceOperationOptions) (resp ListByServiceOperationResponse, err error) { - req, err := c.preparerForListByService(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "apitagdescription.ApiTagDescriptionClient", "ListByService", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apitagdescription.ApiTagDescriptionClient", "ListByService", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListByService(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apitagdescription.ApiTagDescriptionClient", "ListByService", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListByService prepares the ListByService request. -func (c ApiTagDescriptionClient) preparerForListByService(ctx context.Context, id ApiId, options ListByServiceOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/tagDescriptions", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListByServiceWithNextLink prepares the ListByService request with the given nextLink token. -func (c ApiTagDescriptionClient) preparerForListByServiceWithNextLink(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)) -} - -// responderForListByService handles the response to the ListByService request. The method always -// closes the http.Response Body. -func (c ApiTagDescriptionClient) responderForListByService(resp *http.Response) (result ListByServiceOperationResponse, err error) { - type page struct { - Values []TagDescriptionContract `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 ListByServiceOperationResponse, err error) { - req, err := c.preparerForListByServiceWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "apitagdescription.ApiTagDescriptionClient", "ListByService", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apitagdescription.ApiTagDescriptionClient", "ListByService", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByService(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apitagdescription.ApiTagDescriptionClient", "ListByService", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListByServiceComplete retrieves all of the results into a single object -func (c ApiTagDescriptionClient) ListByServiceComplete(ctx context.Context, id ApiId, options ListByServiceOperationOptions) (ListByServiceCompleteResult, error) { - return c.ListByServiceCompleteMatchingPredicate(ctx, id, options, TagDescriptionContractOperationPredicate{}) -} - -// ListByServiceCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c ApiTagDescriptionClient) ListByServiceCompleteMatchingPredicate(ctx context.Context, id ApiId, options ListByServiceOperationOptions, predicate TagDescriptionContractOperationPredicate) (resp ListByServiceCompleteResult, err error) { - items := make([]TagDescriptionContract, 0) - - page, err := c.ListByService(ctx, id, options) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListByServiceCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/apimanagement/2022-08-01/apiversionset/client.go b/resource-manager/apimanagement/2022-08-01/apiversionset/client.go index 7fbe4fc8a0f..6be65936dfb 100644 --- a/resource-manager/apimanagement/2022-08-01/apiversionset/client.go +++ b/resource-manager/apimanagement/2022-08-01/apiversionset/client.go @@ -1,18 +1,26 @@ package apiversionset -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 ApiVersionSetClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewApiVersionSetClientWithBaseURI(endpoint string) ApiVersionSetClient { - return ApiVersionSetClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewApiVersionSetClientWithBaseURI(api environments.Api) (*ApiVersionSetClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "apiversionset", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ApiVersionSetClient: %+v", err) } + + return &ApiVersionSetClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2022-08-01/apiversionset/constants.go b/resource-manager/apimanagement/2022-08-01/apiversionset/constants.go index c13d5055144..4fb4d169fff 100644 --- a/resource-manager/apimanagement/2022-08-01/apiversionset/constants.go +++ b/resource-manager/apimanagement/2022-08-01/apiversionset/constants.go @@ -1,6 +1,10 @@ package apiversionset -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 PossibleValuesForVersioningScheme() []string { } } +func (s *VersioningScheme) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseVersioningScheme(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseVersioningScheme(input string) (*VersioningScheme, error) { vals := map[string]VersioningScheme{ "header": VersioningSchemeHeader, diff --git a/resource-manager/apimanagement/2022-08-01/apiversionset/method_createorupdate.go b/resource-manager/apimanagement/2022-08-01/apiversionset/method_createorupdate.go new file mode 100644 index 00000000000..69f9d46f502 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/apiversionset/method_createorupdate.go @@ -0,0 +1,85 @@ +package apiversionset + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ApiVersionSetContract +} + +type CreateOrUpdateOperationOptions struct { + IfMatch *string +} + +func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { + return CreateOrUpdateOperationOptions{} +} + +func (o CreateOrUpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o CreateOrUpdateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o CreateOrUpdateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// CreateOrUpdate ... +func (c ApiVersionSetClient) CreateOrUpdate(ctx context.Context, id ApiVersionSetId, input ApiVersionSetContract, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + OptionsObject: options, + } + + 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/apimanagement/2022-08-01/apiversionset/method_createorupdate_autorest.go b/resource-manager/apimanagement/2022-08-01/apiversionset/method_createorupdate_autorest.go deleted file mode 100644 index 5ec307cada5..00000000000 --- a/resource-manager/apimanagement/2022-08-01/apiversionset/method_createorupdate_autorest.go +++ /dev/null @@ -1,98 +0,0 @@ -package apiversionset - -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 *ApiVersionSetContract -} - -type CreateOrUpdateOperationOptions struct { - IfMatch *string -} - -func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { - return CreateOrUpdateOperationOptions{} -} - -func (o CreateOrUpdateOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o CreateOrUpdateOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// CreateOrUpdate ... -func (c ApiVersionSetClient) CreateOrUpdate(ctx context.Context, id ApiVersionSetId, input ApiVersionSetContract, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdate(ctx, id, input, options) - if err != nil { - err = autorest.NewErrorWithError(err, "apiversionset.ApiVersionSetClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apiversionset.ApiVersionSetClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCreateOrUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apiversionset.ApiVersionSetClient", "CreateOrUpdate", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCreateOrUpdate prepares the CreateOrUpdate request. -func (c ApiVersionSetClient) preparerForCreateOrUpdate(ctx context.Context, id ApiVersionSetId, input ApiVersionSetContract, options CreateOrUpdateOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - 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 ApiVersionSetClient) responderForCreateOrUpdate(resp *http.Response) (result CreateOrUpdateOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2022-08-01/apiversionset/method_get.go b/resource-manager/apimanagement/2022-08-01/apiversionset/method_get.go new file mode 100644 index 00000000000..910c5a90631 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/apiversionset/method_get.go @@ -0,0 +1,51 @@ +package apiversionset + +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 *ApiVersionSetContract +} + +// Get ... +func (c ApiVersionSetClient) Get(ctx context.Context, id ApiVersionSetId) (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/apimanagement/2022-08-01/apiversionset/method_get_autorest.go b/resource-manager/apimanagement/2022-08-01/apiversionset/method_get_autorest.go deleted file mode 100644 index 51f2f6edc1b..00000000000 --- a/resource-manager/apimanagement/2022-08-01/apiversionset/method_get_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package apiversionset - -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 *ApiVersionSetContract -} - -// Get ... -func (c ApiVersionSetClient) Get(ctx context.Context, id ApiVersionSetId) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "apiversionset.ApiVersionSetClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apiversionset.ApiVersionSetClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apiversionset.ApiVersionSetClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c ApiVersionSetClient) preparerForGet(ctx context.Context, id ApiVersionSetId) (*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 ApiVersionSetClient) 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/apimanagement/2022-08-01/apiversionset/method_getentitytag.go b/resource-manager/apimanagement/2022-08-01/apiversionset/method_getentitytag.go new file mode 100644 index 00000000000..9f95f1e557c --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/apiversionset/method_getentitytag.go @@ -0,0 +1,46 @@ +package apiversionset + +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 GetEntityTagOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// GetEntityTag ... +func (c ApiVersionSetClient) GetEntityTag(ctx context.Context, id ApiVersionSetId) (result GetEntityTagOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodHead, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2022-08-01/apiversionset/method_getentitytag_autorest.go b/resource-manager/apimanagement/2022-08-01/apiversionset/method_getentitytag_autorest.go deleted file mode 100644 index a0997df5dc8..00000000000 --- a/resource-manager/apimanagement/2022-08-01/apiversionset/method_getentitytag_autorest.go +++ /dev/null @@ -1,66 +0,0 @@ -package apiversionset - -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 GetEntityTagOperationResponse struct { - HttpResponse *http.Response -} - -// GetEntityTag ... -func (c ApiVersionSetClient) GetEntityTag(ctx context.Context, id ApiVersionSetId) (result GetEntityTagOperationResponse, err error) { - req, err := c.preparerForGetEntityTag(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "apiversionset.ApiVersionSetClient", "GetEntityTag", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apiversionset.ApiVersionSetClient", "GetEntityTag", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetEntityTag(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apiversionset.ApiVersionSetClient", "GetEntityTag", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetEntityTag prepares the GetEntityTag request. -func (c ApiVersionSetClient) preparerForGetEntityTag(ctx context.Context, id ApiVersionSetId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsHead(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetEntityTag handles the response to the GetEntityTag request. The method always -// closes the http.Response Body. -func (c ApiVersionSetClient) responderForGetEntityTag(resp *http.Response) (result GetEntityTagOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2022-08-01/apiversionset/method_listbyservice.go b/resource-manager/apimanagement/2022-08-01/apiversionset/method_listbyservice.go new file mode 100644 index 00000000000..c850c773f5e --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/apiversionset/method_listbyservice.go @@ -0,0 +1,125 @@ +package apiversionset + +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 ListByServiceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ApiVersionSetContract +} + +type ListByServiceCompleteResult struct { + Items []ApiVersionSetContract +} + +type ListByServiceOperationOptions struct { + Filter *string + Skip *int64 + Top *int64 +} + +func DefaultListByServiceOperationOptions() ListByServiceOperationOptions { + return ListByServiceOperationOptions{} +} + +func (o ListByServiceOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListByServiceOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListByServiceOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.Skip != nil { + out.Append("$skip", fmt.Sprintf("%v", *o.Skip)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +// ListByService ... +func (c ApiVersionSetClient) ListByService(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (result ListByServiceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/apiVersionSets", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ApiVersionSetContract `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByServiceComplete retrieves all the results into a single object +func (c ApiVersionSetClient) ListByServiceComplete(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (ListByServiceCompleteResult, error) { + return c.ListByServiceCompleteMatchingPredicate(ctx, id, options, ApiVersionSetContractOperationPredicate{}) +} + +// ListByServiceCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ApiVersionSetClient) ListByServiceCompleteMatchingPredicate(ctx context.Context, id ServiceId, options ListByServiceOperationOptions, predicate ApiVersionSetContractOperationPredicate) (result ListByServiceCompleteResult, err error) { + items := make([]ApiVersionSetContract, 0) + + resp, err := c.ListByService(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByServiceCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/apimanagement/2022-08-01/apiversionset/method_listbyservice_autorest.go b/resource-manager/apimanagement/2022-08-01/apiversionset/method_listbyservice_autorest.go deleted file mode 100644 index a724e716e3a..00000000000 --- a/resource-manager/apimanagement/2022-08-01/apiversionset/method_listbyservice_autorest.go +++ /dev/null @@ -1,225 +0,0 @@ -package apiversionset - -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 ListByServiceOperationResponse struct { - HttpResponse *http.Response - Model *[]ApiVersionSetContract - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListByServiceOperationResponse, error) -} - -type ListByServiceCompleteResult struct { - Items []ApiVersionSetContract -} - -func (r ListByServiceOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListByServiceOperationResponse) LoadMore(ctx context.Context) (resp ListByServiceOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -type ListByServiceOperationOptions struct { - Filter *string - Skip *int64 - Top *int64 -} - -func DefaultListByServiceOperationOptions() ListByServiceOperationOptions { - return ListByServiceOperationOptions{} -} - -func (o ListByServiceOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o ListByServiceOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Filter != nil { - out["$filter"] = *o.Filter - } - - if o.Skip != nil { - out["$skip"] = *o.Skip - } - - if o.Top != nil { - out["$top"] = *o.Top - } - - return out -} - -// ListByService ... -func (c ApiVersionSetClient) ListByService(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (resp ListByServiceOperationResponse, err error) { - req, err := c.preparerForListByService(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "apiversionset.ApiVersionSetClient", "ListByService", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apiversionset.ApiVersionSetClient", "ListByService", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListByService(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apiversionset.ApiVersionSetClient", "ListByService", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListByService prepares the ListByService request. -func (c ApiVersionSetClient) preparerForListByService(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/apiVersionSets", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListByServiceWithNextLink prepares the ListByService request with the given nextLink token. -func (c ApiVersionSetClient) preparerForListByServiceWithNextLink(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)) -} - -// responderForListByService handles the response to the ListByService request. The method always -// closes the http.Response Body. -func (c ApiVersionSetClient) responderForListByService(resp *http.Response) (result ListByServiceOperationResponse, err error) { - type page struct { - Values []ApiVersionSetContract `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 ListByServiceOperationResponse, err error) { - req, err := c.preparerForListByServiceWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "apiversionset.ApiVersionSetClient", "ListByService", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apiversionset.ApiVersionSetClient", "ListByService", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByService(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apiversionset.ApiVersionSetClient", "ListByService", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListByServiceComplete retrieves all of the results into a single object -func (c ApiVersionSetClient) ListByServiceComplete(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (ListByServiceCompleteResult, error) { - return c.ListByServiceCompleteMatchingPredicate(ctx, id, options, ApiVersionSetContractOperationPredicate{}) -} - -// ListByServiceCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c ApiVersionSetClient) ListByServiceCompleteMatchingPredicate(ctx context.Context, id ServiceId, options ListByServiceOperationOptions, predicate ApiVersionSetContractOperationPredicate) (resp ListByServiceCompleteResult, err error) { - items := make([]ApiVersionSetContract, 0) - - page, err := c.ListByService(ctx, id, options) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListByServiceCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/apimanagement/2022-08-01/apiversionset/method_update.go b/resource-manager/apimanagement/2022-08-01/apiversionset/method_update.go new file mode 100644 index 00000000000..a894808f20a --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/apiversionset/method_update.go @@ -0,0 +1,84 @@ +package apiversionset + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ApiVersionSetContract +} + +type UpdateOperationOptions struct { + IfMatch *string +} + +func DefaultUpdateOperationOptions() UpdateOperationOptions { + return UpdateOperationOptions{} +} + +func (o UpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o UpdateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o UpdateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// Update ... +func (c ApiVersionSetClient) Update(ctx context.Context, id ApiVersionSetId, input ApiVersionSetUpdateParameters, options UpdateOperationOptions) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + OptionsObject: options, + } + + 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/apimanagement/2022-08-01/apiversionset/method_update_autorest.go b/resource-manager/apimanagement/2022-08-01/apiversionset/method_update_autorest.go deleted file mode 100644 index c839759e328..00000000000 --- a/resource-manager/apimanagement/2022-08-01/apiversionset/method_update_autorest.go +++ /dev/null @@ -1,98 +0,0 @@ -package apiversionset - -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 *ApiVersionSetContract -} - -type UpdateOperationOptions struct { - IfMatch *string -} - -func DefaultUpdateOperationOptions() UpdateOperationOptions { - return UpdateOperationOptions{} -} - -func (o UpdateOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o UpdateOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// Update ... -func (c ApiVersionSetClient) Update(ctx context.Context, id ApiVersionSetId, input ApiVersionSetUpdateParameters, options UpdateOperationOptions) (result UpdateOperationResponse, err error) { - req, err := c.preparerForUpdate(ctx, id, input, options) - if err != nil { - err = autorest.NewErrorWithError(err, "apiversionset.ApiVersionSetClient", "Update", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apiversionset.ApiVersionSetClient", "Update", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apiversionset.ApiVersionSetClient", "Update", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForUpdate prepares the Update request. -func (c ApiVersionSetClient) preparerForUpdate(ctx context.Context, id ApiVersionSetId, input ApiVersionSetUpdateParameters, options UpdateOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPatch(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - 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 ApiVersionSetClient) 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/apimanagement/2022-08-01/apiversionsets/client.go b/resource-manager/apimanagement/2022-08-01/apiversionsets/client.go index d927796792e..c9a60a4c6a0 100644 --- a/resource-manager/apimanagement/2022-08-01/apiversionsets/client.go +++ b/resource-manager/apimanagement/2022-08-01/apiversionsets/client.go @@ -1,18 +1,26 @@ package apiversionsets -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 ApiVersionSetsClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewApiVersionSetsClientWithBaseURI(endpoint string) ApiVersionSetsClient { - return ApiVersionSetsClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewApiVersionSetsClientWithBaseURI(api environments.Api) (*ApiVersionSetsClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "apiversionsets", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ApiVersionSetsClient: %+v", err) } + + return &ApiVersionSetsClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2022-08-01/apiversionsets/method_apiversionsetdelete.go b/resource-manager/apimanagement/2022-08-01/apiversionsets/method_apiversionsetdelete.go new file mode 100644 index 00000000000..f50800347d8 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/apiversionsets/method_apiversionsetdelete.go @@ -0,0 +1,76 @@ +package apiversionsets + +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 ApiVersionSetDeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +type ApiVersionSetDeleteOperationOptions struct { + IfMatch *string +} + +func DefaultApiVersionSetDeleteOperationOptions() ApiVersionSetDeleteOperationOptions { + return ApiVersionSetDeleteOperationOptions{} +} + +func (o ApiVersionSetDeleteOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o ApiVersionSetDeleteOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ApiVersionSetDeleteOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// ApiVersionSetDelete ... +func (c ApiVersionSetsClient) ApiVersionSetDelete(ctx context.Context, id ApiVersionSetId, options ApiVersionSetDeleteOperationOptions) (result ApiVersionSetDeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2022-08-01/apiversionsets/method_apiversionsetdelete_autorest.go b/resource-manager/apimanagement/2022-08-01/apiversionsets/method_apiversionsetdelete_autorest.go deleted file mode 100644 index 72a19648666..00000000000 --- a/resource-manager/apimanagement/2022-08-01/apiversionsets/method_apiversionsetdelete_autorest.go +++ /dev/null @@ -1,95 +0,0 @@ -package apiversionsets - -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 ApiVersionSetDeleteOperationResponse struct { - HttpResponse *http.Response -} - -type ApiVersionSetDeleteOperationOptions struct { - IfMatch *string -} - -func DefaultApiVersionSetDeleteOperationOptions() ApiVersionSetDeleteOperationOptions { - return ApiVersionSetDeleteOperationOptions{} -} - -func (o ApiVersionSetDeleteOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o ApiVersionSetDeleteOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// ApiVersionSetDelete ... -func (c ApiVersionSetsClient) ApiVersionSetDelete(ctx context.Context, id ApiVersionSetId, options ApiVersionSetDeleteOperationOptions) (result ApiVersionSetDeleteOperationResponse, err error) { - req, err := c.preparerForApiVersionSetDelete(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "apiversionsets.ApiVersionSetsClient", "ApiVersionSetDelete", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apiversionsets.ApiVersionSetsClient", "ApiVersionSetDelete", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForApiVersionSetDelete(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apiversionsets.ApiVersionSetsClient", "ApiVersionSetDelete", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForApiVersionSetDelete prepares the ApiVersionSetDelete request. -func (c ApiVersionSetsClient) preparerForApiVersionSetDelete(ctx context.Context, id ApiVersionSetId, options ApiVersionSetDeleteOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForApiVersionSetDelete handles the response to the ApiVersionSetDelete request. The method always -// closes the http.Response Body. -func (c ApiVersionSetsClient) responderForApiVersionSetDelete(resp *http.Response) (result ApiVersionSetDeleteOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2022-08-01/apiwiki/client.go b/resource-manager/apimanagement/2022-08-01/apiwiki/client.go index a2693fc245c..27c1a7a1b48 100644 --- a/resource-manager/apimanagement/2022-08-01/apiwiki/client.go +++ b/resource-manager/apimanagement/2022-08-01/apiwiki/client.go @@ -1,18 +1,26 @@ package apiwiki -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 ApiWikiClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewApiWikiClientWithBaseURI(endpoint string) ApiWikiClient { - return ApiWikiClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewApiWikiClientWithBaseURI(api environments.Api) (*ApiWikiClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "apiwiki", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ApiWikiClient: %+v", err) } + + return &ApiWikiClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2022-08-01/apiwiki/method_createorupdate.go b/resource-manager/apimanagement/2022-08-01/apiwiki/method_createorupdate.go new file mode 100644 index 00000000000..12a18615207 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/apiwiki/method_createorupdate.go @@ -0,0 +1,85 @@ +package apiwiki + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *WikiContract +} + +type CreateOrUpdateOperationOptions struct { + IfMatch *string +} + +func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { + return CreateOrUpdateOperationOptions{} +} + +func (o CreateOrUpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o CreateOrUpdateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o CreateOrUpdateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// CreateOrUpdate ... +func (c ApiWikiClient) CreateOrUpdate(ctx context.Context, id ApiId, input WikiContract, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/wikis/default", id.ID()), + OptionsObject: options, + } + + 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/apimanagement/2022-08-01/apiwiki/method_createorupdate_autorest.go b/resource-manager/apimanagement/2022-08-01/apiwiki/method_createorupdate_autorest.go deleted file mode 100644 index 48fbed22b62..00000000000 --- a/resource-manager/apimanagement/2022-08-01/apiwiki/method_createorupdate_autorest.go +++ /dev/null @@ -1,99 +0,0 @@ -package apiwiki - -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 CreateOrUpdateOperationResponse struct { - HttpResponse *http.Response - Model *WikiContract -} - -type CreateOrUpdateOperationOptions struct { - IfMatch *string -} - -func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { - return CreateOrUpdateOperationOptions{} -} - -func (o CreateOrUpdateOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o CreateOrUpdateOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// CreateOrUpdate ... -func (c ApiWikiClient) CreateOrUpdate(ctx context.Context, id ApiId, input WikiContract, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdate(ctx, id, input, options) - if err != nil { - err = autorest.NewErrorWithError(err, "apiwiki.ApiWikiClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apiwiki.ApiWikiClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCreateOrUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apiwiki.ApiWikiClient", "CreateOrUpdate", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCreateOrUpdate prepares the CreateOrUpdate request. -func (c ApiWikiClient) preparerForCreateOrUpdate(ctx context.Context, id ApiId, input WikiContract, options CreateOrUpdateOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/wikis/default", 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 ApiWikiClient) responderForCreateOrUpdate(resp *http.Response) (result CreateOrUpdateOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2022-08-01/apiwiki/method_delete.go b/resource-manager/apimanagement/2022-08-01/apiwiki/method_delete.go new file mode 100644 index 00000000000..74d9f29868e --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/apiwiki/method_delete.go @@ -0,0 +1,76 @@ +package apiwiki + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +type DeleteOperationOptions struct { + IfMatch *string +} + +func DefaultDeleteOperationOptions() DeleteOperationOptions { + return DeleteOperationOptions{} +} + +func (o DeleteOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o DeleteOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o DeleteOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// Delete ... +func (c ApiWikiClient) Delete(ctx context.Context, id ApiId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: fmt.Sprintf("%s/wikis/default", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2022-08-01/apiwiki/method_delete_autorest.go b/resource-manager/apimanagement/2022-08-01/apiwiki/method_delete_autorest.go deleted file mode 100644 index 1da35240d25..00000000000 --- a/resource-manager/apimanagement/2022-08-01/apiwiki/method_delete_autorest.go +++ /dev/null @@ -1,96 +0,0 @@ -package apiwiki - -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 DeleteOperationResponse struct { - HttpResponse *http.Response -} - -type DeleteOperationOptions struct { - IfMatch *string -} - -func DefaultDeleteOperationOptions() DeleteOperationOptions { - return DeleteOperationOptions{} -} - -func (o DeleteOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o DeleteOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// Delete ... -func (c ApiWikiClient) Delete(ctx context.Context, id ApiId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { - req, err := c.preparerForDelete(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "apiwiki.ApiWikiClient", "Delete", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apiwiki.ApiWikiClient", "Delete", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForDelete(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apiwiki.ApiWikiClient", "Delete", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForDelete prepares the Delete request. -func (c ApiWikiClient) preparerForDelete(ctx context.Context, id ApiId, options DeleteOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/wikis/default", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForDelete handles the response to the Delete request. The method always -// closes the http.Response Body. -func (c ApiWikiClient) responderForDelete(resp *http.Response) (result DeleteOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2022-08-01/apiwiki/method_get.go b/resource-manager/apimanagement/2022-08-01/apiwiki/method_get.go new file mode 100644 index 00000000000..555c95fc6d5 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/apiwiki/method_get.go @@ -0,0 +1,52 @@ +package apiwiki + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *WikiContract +} + +// Get ... +func (c ApiWikiClient) Get(ctx context.Context, id ApiId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/wikis/default", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + if err = resp.Unmarshal(&result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2022-08-01/apiwiki/method_get_autorest.go b/resource-manager/apimanagement/2022-08-01/apiwiki/method_get_autorest.go deleted file mode 100644 index 0510f3eab68..00000000000 --- a/resource-manager/apimanagement/2022-08-01/apiwiki/method_get_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package apiwiki - -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 GetOperationResponse struct { - HttpResponse *http.Response - Model *WikiContract -} - -// Get ... -func (c ApiWikiClient) Get(ctx context.Context, id ApiId) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "apiwiki.ApiWikiClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apiwiki.ApiWikiClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apiwiki.ApiWikiClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c ApiWikiClient) preparerForGet(ctx context.Context, id ApiId) (*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/wikis/default", 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 ApiWikiClient) 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/apimanagement/2022-08-01/apiwiki/method_getentitytag.go b/resource-manager/apimanagement/2022-08-01/apiwiki/method_getentitytag.go new file mode 100644 index 00000000000..08294e831ff --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/apiwiki/method_getentitytag.go @@ -0,0 +1,47 @@ +package apiwiki + +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 GetEntityTagOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// GetEntityTag ... +func (c ApiWikiClient) GetEntityTag(ctx context.Context, id ApiId) (result GetEntityTagOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodHead, + Path: fmt.Sprintf("%s/wikis/default", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2022-08-01/apiwiki/method_getentitytag_autorest.go b/resource-manager/apimanagement/2022-08-01/apiwiki/method_getentitytag_autorest.go deleted file mode 100644 index cbab473a14a..00000000000 --- a/resource-manager/apimanagement/2022-08-01/apiwiki/method_getentitytag_autorest.go +++ /dev/null @@ -1,67 +0,0 @@ -package apiwiki - -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 GetEntityTagOperationResponse struct { - HttpResponse *http.Response -} - -// GetEntityTag ... -func (c ApiWikiClient) GetEntityTag(ctx context.Context, id ApiId) (result GetEntityTagOperationResponse, err error) { - req, err := c.preparerForGetEntityTag(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "apiwiki.ApiWikiClient", "GetEntityTag", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apiwiki.ApiWikiClient", "GetEntityTag", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetEntityTag(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apiwiki.ApiWikiClient", "GetEntityTag", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetEntityTag prepares the GetEntityTag request. -func (c ApiWikiClient) preparerForGetEntityTag(ctx context.Context, id ApiId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsHead(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/wikis/default", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetEntityTag handles the response to the GetEntityTag request. The method always -// closes the http.Response Body. -func (c ApiWikiClient) responderForGetEntityTag(resp *http.Response) (result GetEntityTagOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2022-08-01/apiwiki/method_list.go b/resource-manager/apimanagement/2022-08-01/apiwiki/method_list.go new file mode 100644 index 00000000000..b0302cf5d7e --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/apiwiki/method_list.go @@ -0,0 +1,125 @@ +package apiwiki + +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 *[]WikiContract +} + +type ListCompleteResult struct { + Items []WikiContract +} + +type ListOperationOptions struct { + Filter *string + Skip *int64 + Top *int64 +} + +func DefaultListOperationOptions() ListOperationOptions { + return ListOperationOptions{} +} + +func (o ListOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.Skip != nil { + out.Append("$skip", fmt.Sprintf("%v", *o.Skip)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +// List ... +func (c ApiWikiClient) List(ctx context.Context, id ApiId, options ListOperationOptions) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/wikis", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]WikiContract `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 ApiWikiClient) ListComplete(ctx context.Context, id ApiId, options ListOperationOptions) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, options, WikiContractOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ApiWikiClient) ListCompleteMatchingPredicate(ctx context.Context, id ApiId, options ListOperationOptions, predicate WikiContractOperationPredicate) (result ListCompleteResult, err error) { + items := make([]WikiContract, 0) + + resp, err := c.List(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/apimanagement/2022-08-01/apiwiki/method_list_autorest.go b/resource-manager/apimanagement/2022-08-01/apiwiki/method_list_autorest.go deleted file mode 100644 index ca20cecdb65..00000000000 --- a/resource-manager/apimanagement/2022-08-01/apiwiki/method_list_autorest.go +++ /dev/null @@ -1,225 +0,0 @@ -package apiwiki - -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 *[]WikiContract - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListOperationResponse, error) -} - -type ListCompleteResult struct { - Items []WikiContract -} - -func (r ListOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListOperationResponse) LoadMore(ctx context.Context) (resp ListOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -type ListOperationOptions struct { - Filter *string - Skip *int64 - Top *int64 -} - -func DefaultListOperationOptions() ListOperationOptions { - return ListOperationOptions{} -} - -func (o ListOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o ListOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Filter != nil { - out["$filter"] = *o.Filter - } - - if o.Skip != nil { - out["$skip"] = *o.Skip - } - - if o.Top != nil { - out["$top"] = *o.Top - } - - return out -} - -// List ... -func (c ApiWikiClient) List(ctx context.Context, id ApiId, options ListOperationOptions) (resp ListOperationResponse, err error) { - req, err := c.preparerForList(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "apiwiki.ApiWikiClient", "List", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apiwiki.ApiWikiClient", "List", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForList(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apiwiki.ApiWikiClient", "List", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForList prepares the List request. -func (c ApiWikiClient) preparerForList(ctx context.Context, id ApiId, options ListOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/wikis", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListWithNextLink prepares the List request with the given nextLink token. -func (c ApiWikiClient) 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 ApiWikiClient) responderForList(resp *http.Response) (result ListOperationResponse, err error) { - type page struct { - Values []WikiContract `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, "apiwiki.ApiWikiClient", "List", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apiwiki.ApiWikiClient", "List", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForList(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apiwiki.ApiWikiClient", "List", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListComplete retrieves all of the results into a single object -func (c ApiWikiClient) ListComplete(ctx context.Context, id ApiId, options ListOperationOptions) (ListCompleteResult, error) { - return c.ListCompleteMatchingPredicate(ctx, id, options, WikiContractOperationPredicate{}) -} - -// ListCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c ApiWikiClient) ListCompleteMatchingPredicate(ctx context.Context, id ApiId, options ListOperationOptions, predicate WikiContractOperationPredicate) (resp ListCompleteResult, err error) { - items := make([]WikiContract, 0) - - page, err := c.List(ctx, id, options) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/apimanagement/2022-08-01/apiwiki/method_update.go b/resource-manager/apimanagement/2022-08-01/apiwiki/method_update.go new file mode 100644 index 00000000000..523376050f6 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/apiwiki/method_update.go @@ -0,0 +1,84 @@ +package apiwiki + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *WikiContract +} + +type UpdateOperationOptions struct { + IfMatch *string +} + +func DefaultUpdateOperationOptions() UpdateOperationOptions { + return UpdateOperationOptions{} +} + +func (o UpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o UpdateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o UpdateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// Update ... +func (c ApiWikiClient) Update(ctx context.Context, id ApiId, input WikiUpdateContract, options UpdateOperationOptions) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: fmt.Sprintf("%s/wikis/default", id.ID()), + OptionsObject: options, + } + + 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/apimanagement/2022-08-01/apiwiki/method_update_autorest.go b/resource-manager/apimanagement/2022-08-01/apiwiki/method_update_autorest.go deleted file mode 100644 index 970a06ebc89..00000000000 --- a/resource-manager/apimanagement/2022-08-01/apiwiki/method_update_autorest.go +++ /dev/null @@ -1,99 +0,0 @@ -package apiwiki - -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 UpdateOperationResponse struct { - HttpResponse *http.Response - Model *WikiContract -} - -type UpdateOperationOptions struct { - IfMatch *string -} - -func DefaultUpdateOperationOptions() UpdateOperationOptions { - return UpdateOperationOptions{} -} - -func (o UpdateOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o UpdateOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// Update ... -func (c ApiWikiClient) Update(ctx context.Context, id ApiId, input WikiUpdateContract, options UpdateOperationOptions) (result UpdateOperationResponse, err error) { - req, err := c.preparerForUpdate(ctx, id, input, options) - if err != nil { - err = autorest.NewErrorWithError(err, "apiwiki.ApiWikiClient", "Update", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "apiwiki.ApiWikiClient", "Update", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "apiwiki.ApiWikiClient", "Update", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForUpdate prepares the Update request. -func (c ApiWikiClient) preparerForUpdate(ctx context.Context, id ApiId, input WikiUpdateContract, options UpdateOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPatch(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/wikis/default", 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 ApiWikiClient) 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/apimanagement/2022-08-01/authorization/client.go b/resource-manager/apimanagement/2022-08-01/authorization/client.go index b1a04f4e58a..be36f858239 100644 --- a/resource-manager/apimanagement/2022-08-01/authorization/client.go +++ b/resource-manager/apimanagement/2022-08-01/authorization/client.go @@ -1,18 +1,26 @@ package authorization -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 AuthorizationClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewAuthorizationClientWithBaseURI(endpoint string) AuthorizationClient { - return AuthorizationClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewAuthorizationClientWithBaseURI(api environments.Api) (*AuthorizationClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "authorization", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating AuthorizationClient: %+v", err) } + + return &AuthorizationClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2022-08-01/authorization/constants.go b/resource-manager/apimanagement/2022-08-01/authorization/constants.go index a6468636464..a28406af2a0 100644 --- a/resource-manager/apimanagement/2022-08-01/authorization/constants.go +++ b/resource-manager/apimanagement/2022-08-01/authorization/constants.go @@ -1,6 +1,10 @@ package authorization -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 PossibleValuesForAuthorizationType() []string { } } +func (s *AuthorizationType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAuthorizationType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseAuthorizationType(input string) (*AuthorizationType, error) { vals := map[string]AuthorizationType{ "oauth2": AuthorizationTypeOAuthTwo, @@ -44,6 +61,19 @@ func PossibleValuesForOAuth2GrantType() []string { } } +func (s *OAuth2GrantType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseOAuth2GrantType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseOAuth2GrantType(input string) (*OAuth2GrantType, error) { vals := map[string]OAuth2GrantType{ "authorizationcode": OAuth2GrantTypeAuthorizationCode, diff --git a/resource-manager/apimanagement/2022-08-01/authorization/method_createorupdate.go b/resource-manager/apimanagement/2022-08-01/authorization/method_createorupdate.go new file mode 100644 index 00000000000..9e86fac93c8 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/authorization/method_createorupdate.go @@ -0,0 +1,85 @@ +package authorization + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *AuthorizationContract +} + +type CreateOrUpdateOperationOptions struct { + IfMatch *string +} + +func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { + return CreateOrUpdateOperationOptions{} +} + +func (o CreateOrUpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o CreateOrUpdateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o CreateOrUpdateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// CreateOrUpdate ... +func (c AuthorizationClient) CreateOrUpdate(ctx context.Context, id AuthorizationId, input AuthorizationContract, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + OptionsObject: options, + } + + 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/apimanagement/2022-08-01/authorization/method_createorupdate_autorest.go b/resource-manager/apimanagement/2022-08-01/authorization/method_createorupdate_autorest.go deleted file mode 100644 index b8663aec7ef..00000000000 --- a/resource-manager/apimanagement/2022-08-01/authorization/method_createorupdate_autorest.go +++ /dev/null @@ -1,98 +0,0 @@ -package authorization - -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 *AuthorizationContract -} - -type CreateOrUpdateOperationOptions struct { - IfMatch *string -} - -func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { - return CreateOrUpdateOperationOptions{} -} - -func (o CreateOrUpdateOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o CreateOrUpdateOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// CreateOrUpdate ... -func (c AuthorizationClient) CreateOrUpdate(ctx context.Context, id AuthorizationId, input AuthorizationContract, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdate(ctx, id, input, options) - if err != nil { - err = autorest.NewErrorWithError(err, "authorization.AuthorizationClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "authorization.AuthorizationClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCreateOrUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "authorization.AuthorizationClient", "CreateOrUpdate", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCreateOrUpdate prepares the CreateOrUpdate request. -func (c AuthorizationClient) preparerForCreateOrUpdate(ctx context.Context, id AuthorizationId, input AuthorizationContract, options CreateOrUpdateOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - 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 AuthorizationClient) responderForCreateOrUpdate(resp *http.Response) (result CreateOrUpdateOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2022-08-01/authorization/method_delete.go b/resource-manager/apimanagement/2022-08-01/authorization/method_delete.go new file mode 100644 index 00000000000..4e593e93d69 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/authorization/method_delete.go @@ -0,0 +1,76 @@ +package authorization + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +type DeleteOperationOptions struct { + IfMatch *string +} + +func DefaultDeleteOperationOptions() DeleteOperationOptions { + return DeleteOperationOptions{} +} + +func (o DeleteOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o DeleteOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o DeleteOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// Delete ... +func (c AuthorizationClient) Delete(ctx context.Context, id AuthorizationId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2022-08-01/authorization/method_delete_autorest.go b/resource-manager/apimanagement/2022-08-01/authorization/method_delete_autorest.go deleted file mode 100644 index 1e653a427e5..00000000000 --- a/resource-manager/apimanagement/2022-08-01/authorization/method_delete_autorest.go +++ /dev/null @@ -1,95 +0,0 @@ -package authorization - -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 DeleteOperationResponse struct { - HttpResponse *http.Response -} - -type DeleteOperationOptions struct { - IfMatch *string -} - -func DefaultDeleteOperationOptions() DeleteOperationOptions { - return DeleteOperationOptions{} -} - -func (o DeleteOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o DeleteOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// Delete ... -func (c AuthorizationClient) Delete(ctx context.Context, id AuthorizationId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { - req, err := c.preparerForDelete(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "authorization.AuthorizationClient", "Delete", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "authorization.AuthorizationClient", "Delete", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForDelete(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "authorization.AuthorizationClient", "Delete", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForDelete prepares the Delete request. -func (c AuthorizationClient) preparerForDelete(ctx context.Context, id AuthorizationId, options DeleteOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForDelete handles the response to the Delete request. The method always -// closes the http.Response Body. -func (c AuthorizationClient) responderForDelete(resp *http.Response) (result DeleteOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2022-08-01/authorization/method_get.go b/resource-manager/apimanagement/2022-08-01/authorization/method_get.go new file mode 100644 index 00000000000..23fe8ece2c5 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/authorization/method_get.go @@ -0,0 +1,51 @@ +package authorization + +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 *AuthorizationContract +} + +// Get ... +func (c AuthorizationClient) Get(ctx context.Context, id AuthorizationId) (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/apimanagement/2022-08-01/authorization/method_get_autorest.go b/resource-manager/apimanagement/2022-08-01/authorization/method_get_autorest.go deleted file mode 100644 index f286797ed33..00000000000 --- a/resource-manager/apimanagement/2022-08-01/authorization/method_get_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package authorization - -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 *AuthorizationContract -} - -// Get ... -func (c AuthorizationClient) Get(ctx context.Context, id AuthorizationId) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "authorization.AuthorizationClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "authorization.AuthorizationClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "authorization.AuthorizationClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c AuthorizationClient) preparerForGet(ctx context.Context, id AuthorizationId) (*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 AuthorizationClient) 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/apimanagement/2022-08-01/authorizationaccesspolicy/client.go b/resource-manager/apimanagement/2022-08-01/authorizationaccesspolicy/client.go index 85ee086ae68..b3083d3009f 100644 --- a/resource-manager/apimanagement/2022-08-01/authorizationaccesspolicy/client.go +++ b/resource-manager/apimanagement/2022-08-01/authorizationaccesspolicy/client.go @@ -1,18 +1,26 @@ package authorizationaccesspolicy -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 AuthorizationAccessPolicyClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewAuthorizationAccessPolicyClientWithBaseURI(endpoint string) AuthorizationAccessPolicyClient { - return AuthorizationAccessPolicyClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewAuthorizationAccessPolicyClientWithBaseURI(api environments.Api) (*AuthorizationAccessPolicyClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "authorizationaccesspolicy", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating AuthorizationAccessPolicyClient: %+v", err) } + + return &AuthorizationAccessPolicyClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2022-08-01/authorizationaccesspolicy/method_createorupdate.go b/resource-manager/apimanagement/2022-08-01/authorizationaccesspolicy/method_createorupdate.go new file mode 100644 index 00000000000..4a28c30dc4e --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/authorizationaccesspolicy/method_createorupdate.go @@ -0,0 +1,85 @@ +package authorizationaccesspolicy + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *AuthorizationAccessPolicyContract +} + +type CreateOrUpdateOperationOptions struct { + IfMatch *string +} + +func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { + return CreateOrUpdateOperationOptions{} +} + +func (o CreateOrUpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o CreateOrUpdateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o CreateOrUpdateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// CreateOrUpdate ... +func (c AuthorizationAccessPolicyClient) CreateOrUpdate(ctx context.Context, id AccessPolicyId, input AuthorizationAccessPolicyContract, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + OptionsObject: options, + } + + 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/apimanagement/2022-08-01/authorizationaccesspolicy/method_createorupdate_autorest.go b/resource-manager/apimanagement/2022-08-01/authorizationaccesspolicy/method_createorupdate_autorest.go deleted file mode 100644 index f249234bb7e..00000000000 --- a/resource-manager/apimanagement/2022-08-01/authorizationaccesspolicy/method_createorupdate_autorest.go +++ /dev/null @@ -1,98 +0,0 @@ -package authorizationaccesspolicy - -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 *AuthorizationAccessPolicyContract -} - -type CreateOrUpdateOperationOptions struct { - IfMatch *string -} - -func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { - return CreateOrUpdateOperationOptions{} -} - -func (o CreateOrUpdateOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o CreateOrUpdateOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// CreateOrUpdate ... -func (c AuthorizationAccessPolicyClient) CreateOrUpdate(ctx context.Context, id AccessPolicyId, input AuthorizationAccessPolicyContract, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdate(ctx, id, input, options) - if err != nil { - err = autorest.NewErrorWithError(err, "authorizationaccesspolicy.AuthorizationAccessPolicyClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "authorizationaccesspolicy.AuthorizationAccessPolicyClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCreateOrUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "authorizationaccesspolicy.AuthorizationAccessPolicyClient", "CreateOrUpdate", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCreateOrUpdate prepares the CreateOrUpdate request. -func (c AuthorizationAccessPolicyClient) preparerForCreateOrUpdate(ctx context.Context, id AccessPolicyId, input AuthorizationAccessPolicyContract, options CreateOrUpdateOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - 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 AuthorizationAccessPolicyClient) responderForCreateOrUpdate(resp *http.Response) (result CreateOrUpdateOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2022-08-01/authorizationaccesspolicy/method_delete.go b/resource-manager/apimanagement/2022-08-01/authorizationaccesspolicy/method_delete.go new file mode 100644 index 00000000000..59c5782e01d --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/authorizationaccesspolicy/method_delete.go @@ -0,0 +1,76 @@ +package authorizationaccesspolicy + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +type DeleteOperationOptions struct { + IfMatch *string +} + +func DefaultDeleteOperationOptions() DeleteOperationOptions { + return DeleteOperationOptions{} +} + +func (o DeleteOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o DeleteOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o DeleteOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// Delete ... +func (c AuthorizationAccessPolicyClient) Delete(ctx context.Context, id AccessPolicyId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2022-08-01/authorizationaccesspolicy/method_delete_autorest.go b/resource-manager/apimanagement/2022-08-01/authorizationaccesspolicy/method_delete_autorest.go deleted file mode 100644 index 28713cc763b..00000000000 --- a/resource-manager/apimanagement/2022-08-01/authorizationaccesspolicy/method_delete_autorest.go +++ /dev/null @@ -1,95 +0,0 @@ -package authorizationaccesspolicy - -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 DeleteOperationResponse struct { - HttpResponse *http.Response -} - -type DeleteOperationOptions struct { - IfMatch *string -} - -func DefaultDeleteOperationOptions() DeleteOperationOptions { - return DeleteOperationOptions{} -} - -func (o DeleteOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o DeleteOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// Delete ... -func (c AuthorizationAccessPolicyClient) Delete(ctx context.Context, id AccessPolicyId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { - req, err := c.preparerForDelete(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "authorizationaccesspolicy.AuthorizationAccessPolicyClient", "Delete", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "authorizationaccesspolicy.AuthorizationAccessPolicyClient", "Delete", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForDelete(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "authorizationaccesspolicy.AuthorizationAccessPolicyClient", "Delete", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForDelete prepares the Delete request. -func (c AuthorizationAccessPolicyClient) preparerForDelete(ctx context.Context, id AccessPolicyId, options DeleteOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForDelete handles the response to the Delete request. The method always -// closes the http.Response Body. -func (c AuthorizationAccessPolicyClient) responderForDelete(resp *http.Response) (result DeleteOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2022-08-01/authorizationaccesspolicy/method_get.go b/resource-manager/apimanagement/2022-08-01/authorizationaccesspolicy/method_get.go new file mode 100644 index 00000000000..c4688e592e7 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/authorizationaccesspolicy/method_get.go @@ -0,0 +1,51 @@ +package authorizationaccesspolicy + +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 *AuthorizationAccessPolicyContract +} + +// Get ... +func (c AuthorizationAccessPolicyClient) Get(ctx context.Context, id AccessPolicyId) (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/apimanagement/2022-08-01/authorizationaccesspolicy/method_get_autorest.go b/resource-manager/apimanagement/2022-08-01/authorizationaccesspolicy/method_get_autorest.go deleted file mode 100644 index af3bfad6c16..00000000000 --- a/resource-manager/apimanagement/2022-08-01/authorizationaccesspolicy/method_get_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package authorizationaccesspolicy - -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 *AuthorizationAccessPolicyContract -} - -// Get ... -func (c AuthorizationAccessPolicyClient) Get(ctx context.Context, id AccessPolicyId) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "authorizationaccesspolicy.AuthorizationAccessPolicyClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "authorizationaccesspolicy.AuthorizationAccessPolicyClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "authorizationaccesspolicy.AuthorizationAccessPolicyClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c AuthorizationAccessPolicyClient) preparerForGet(ctx context.Context, id AccessPolicyId) (*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 AuthorizationAccessPolicyClient) 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/apimanagement/2022-08-01/authorizationaccesspolicy/method_listbyauthorization.go b/resource-manager/apimanagement/2022-08-01/authorizationaccesspolicy/method_listbyauthorization.go new file mode 100644 index 00000000000..de07ed50f81 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/authorizationaccesspolicy/method_listbyauthorization.go @@ -0,0 +1,125 @@ +package authorizationaccesspolicy + +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 ListByAuthorizationOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]AuthorizationAccessPolicyContract +} + +type ListByAuthorizationCompleteResult struct { + Items []AuthorizationAccessPolicyContract +} + +type ListByAuthorizationOperationOptions struct { + Filter *string + Skip *int64 + Top *int64 +} + +func DefaultListByAuthorizationOperationOptions() ListByAuthorizationOperationOptions { + return ListByAuthorizationOperationOptions{} +} + +func (o ListByAuthorizationOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListByAuthorizationOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListByAuthorizationOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.Skip != nil { + out.Append("$skip", fmt.Sprintf("%v", *o.Skip)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +// ListByAuthorization ... +func (c AuthorizationAccessPolicyClient) ListByAuthorization(ctx context.Context, id AuthorizationId, options ListByAuthorizationOperationOptions) (result ListByAuthorizationOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/accessPolicies", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]AuthorizationAccessPolicyContract `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByAuthorizationComplete retrieves all the results into a single object +func (c AuthorizationAccessPolicyClient) ListByAuthorizationComplete(ctx context.Context, id AuthorizationId, options ListByAuthorizationOperationOptions) (ListByAuthorizationCompleteResult, error) { + return c.ListByAuthorizationCompleteMatchingPredicate(ctx, id, options, AuthorizationAccessPolicyContractOperationPredicate{}) +} + +// ListByAuthorizationCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AuthorizationAccessPolicyClient) ListByAuthorizationCompleteMatchingPredicate(ctx context.Context, id AuthorizationId, options ListByAuthorizationOperationOptions, predicate AuthorizationAccessPolicyContractOperationPredicate) (result ListByAuthorizationCompleteResult, err error) { + items := make([]AuthorizationAccessPolicyContract, 0) + + resp, err := c.ListByAuthorization(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByAuthorizationCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/apimanagement/2022-08-01/authorizationaccesspolicy/method_listbyauthorization_autorest.go b/resource-manager/apimanagement/2022-08-01/authorizationaccesspolicy/method_listbyauthorization_autorest.go deleted file mode 100644 index 5ff2aaacc88..00000000000 --- a/resource-manager/apimanagement/2022-08-01/authorizationaccesspolicy/method_listbyauthorization_autorest.go +++ /dev/null @@ -1,225 +0,0 @@ -package authorizationaccesspolicy - -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 ListByAuthorizationOperationResponse struct { - HttpResponse *http.Response - Model *[]AuthorizationAccessPolicyContract - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListByAuthorizationOperationResponse, error) -} - -type ListByAuthorizationCompleteResult struct { - Items []AuthorizationAccessPolicyContract -} - -func (r ListByAuthorizationOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListByAuthorizationOperationResponse) LoadMore(ctx context.Context) (resp ListByAuthorizationOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -type ListByAuthorizationOperationOptions struct { - Filter *string - Skip *int64 - Top *int64 -} - -func DefaultListByAuthorizationOperationOptions() ListByAuthorizationOperationOptions { - return ListByAuthorizationOperationOptions{} -} - -func (o ListByAuthorizationOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o ListByAuthorizationOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Filter != nil { - out["$filter"] = *o.Filter - } - - if o.Skip != nil { - out["$skip"] = *o.Skip - } - - if o.Top != nil { - out["$top"] = *o.Top - } - - return out -} - -// ListByAuthorization ... -func (c AuthorizationAccessPolicyClient) ListByAuthorization(ctx context.Context, id AuthorizationId, options ListByAuthorizationOperationOptions) (resp ListByAuthorizationOperationResponse, err error) { - req, err := c.preparerForListByAuthorization(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "authorizationaccesspolicy.AuthorizationAccessPolicyClient", "ListByAuthorization", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "authorizationaccesspolicy.AuthorizationAccessPolicyClient", "ListByAuthorization", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListByAuthorization(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "authorizationaccesspolicy.AuthorizationAccessPolicyClient", "ListByAuthorization", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListByAuthorization prepares the ListByAuthorization request. -func (c AuthorizationAccessPolicyClient) preparerForListByAuthorization(ctx context.Context, id AuthorizationId, options ListByAuthorizationOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/accessPolicies", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListByAuthorizationWithNextLink prepares the ListByAuthorization request with the given nextLink token. -func (c AuthorizationAccessPolicyClient) preparerForListByAuthorizationWithNextLink(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)) -} - -// responderForListByAuthorization handles the response to the ListByAuthorization request. The method always -// closes the http.Response Body. -func (c AuthorizationAccessPolicyClient) responderForListByAuthorization(resp *http.Response) (result ListByAuthorizationOperationResponse, err error) { - type page struct { - Values []AuthorizationAccessPolicyContract `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 ListByAuthorizationOperationResponse, err error) { - req, err := c.preparerForListByAuthorizationWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "authorizationaccesspolicy.AuthorizationAccessPolicyClient", "ListByAuthorization", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "authorizationaccesspolicy.AuthorizationAccessPolicyClient", "ListByAuthorization", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByAuthorization(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "authorizationaccesspolicy.AuthorizationAccessPolicyClient", "ListByAuthorization", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListByAuthorizationComplete retrieves all of the results into a single object -func (c AuthorizationAccessPolicyClient) ListByAuthorizationComplete(ctx context.Context, id AuthorizationId, options ListByAuthorizationOperationOptions) (ListByAuthorizationCompleteResult, error) { - return c.ListByAuthorizationCompleteMatchingPredicate(ctx, id, options, AuthorizationAccessPolicyContractOperationPredicate{}) -} - -// ListByAuthorizationCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c AuthorizationAccessPolicyClient) ListByAuthorizationCompleteMatchingPredicate(ctx context.Context, id AuthorizationId, options ListByAuthorizationOperationOptions, predicate AuthorizationAccessPolicyContractOperationPredicate) (resp ListByAuthorizationCompleteResult, err error) { - items := make([]AuthorizationAccessPolicyContract, 0) - - page, err := c.ListByAuthorization(ctx, id, options) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListByAuthorizationCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/apimanagement/2022-08-01/authorizationconfirmconsentcode/client.go b/resource-manager/apimanagement/2022-08-01/authorizationconfirmconsentcode/client.go index 83719e6c00f..87b3601e05d 100644 --- a/resource-manager/apimanagement/2022-08-01/authorizationconfirmconsentcode/client.go +++ b/resource-manager/apimanagement/2022-08-01/authorizationconfirmconsentcode/client.go @@ -1,18 +1,26 @@ package authorizationconfirmconsentcode -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 AuthorizationConfirmConsentCodeClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewAuthorizationConfirmConsentCodeClientWithBaseURI(endpoint string) AuthorizationConfirmConsentCodeClient { - return AuthorizationConfirmConsentCodeClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewAuthorizationConfirmConsentCodeClientWithBaseURI(api environments.Api) (*AuthorizationConfirmConsentCodeClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "authorizationconfirmconsentcode", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating AuthorizationConfirmConsentCodeClient: %+v", err) } + + return &AuthorizationConfirmConsentCodeClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2022-08-01/authorizationconfirmconsentcode/method_authorizationconfirmconsentcode.go b/resource-manager/apimanagement/2022-08-01/authorizationconfirmconsentcode/method_authorizationconfirmconsentcode.go new file mode 100644 index 00000000000..ae681f6debd --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/authorizationconfirmconsentcode/method_authorizationconfirmconsentcode.go @@ -0,0 +1,51 @@ +package authorizationconfirmconsentcode + +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 AuthorizationConfirmConsentCodeOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// AuthorizationConfirmConsentCode ... +func (c AuthorizationConfirmConsentCodeClient) AuthorizationConfirmConsentCode(ctx context.Context, id AuthorizationId, input AuthorizationConfirmConsentCodeRequestContract) (result AuthorizationConfirmConsentCodeOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/confirmConsentCode", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2022-08-01/authorizationconfirmconsentcode/method_authorizationconfirmconsentcode_autorest.go b/resource-manager/apimanagement/2022-08-01/authorizationconfirmconsentcode/method_authorizationconfirmconsentcode_autorest.go deleted file mode 100644 index d4913b9cb7f..00000000000 --- a/resource-manager/apimanagement/2022-08-01/authorizationconfirmconsentcode/method_authorizationconfirmconsentcode_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package authorizationconfirmconsentcode - -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 AuthorizationConfirmConsentCodeOperationResponse struct { - HttpResponse *http.Response -} - -// AuthorizationConfirmConsentCode ... -func (c AuthorizationConfirmConsentCodeClient) AuthorizationConfirmConsentCode(ctx context.Context, id AuthorizationId, input AuthorizationConfirmConsentCodeRequestContract) (result AuthorizationConfirmConsentCodeOperationResponse, err error) { - req, err := c.preparerForAuthorizationConfirmConsentCode(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "authorizationconfirmconsentcode.AuthorizationConfirmConsentCodeClient", "AuthorizationConfirmConsentCode", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "authorizationconfirmconsentcode.AuthorizationConfirmConsentCodeClient", "AuthorizationConfirmConsentCode", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForAuthorizationConfirmConsentCode(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "authorizationconfirmconsentcode.AuthorizationConfirmConsentCodeClient", "AuthorizationConfirmConsentCode", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForAuthorizationConfirmConsentCode prepares the AuthorizationConfirmConsentCode request. -func (c AuthorizationConfirmConsentCodeClient) preparerForAuthorizationConfirmConsentCode(ctx context.Context, id AuthorizationId, input AuthorizationConfirmConsentCodeRequestContract) (*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/confirmConsentCode", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForAuthorizationConfirmConsentCode handles the response to the AuthorizationConfirmConsentCode request. The method always -// closes the http.Response Body. -func (c AuthorizationConfirmConsentCodeClient) responderForAuthorizationConfirmConsentCode(resp *http.Response) (result AuthorizationConfirmConsentCodeOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2022-08-01/authorizationloginlinks/client.go b/resource-manager/apimanagement/2022-08-01/authorizationloginlinks/client.go index 5a583bf36e8..b2e199fe380 100644 --- a/resource-manager/apimanagement/2022-08-01/authorizationloginlinks/client.go +++ b/resource-manager/apimanagement/2022-08-01/authorizationloginlinks/client.go @@ -1,18 +1,26 @@ package authorizationloginlinks -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 AuthorizationLoginLinksClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewAuthorizationLoginLinksClientWithBaseURI(endpoint string) AuthorizationLoginLinksClient { - return AuthorizationLoginLinksClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewAuthorizationLoginLinksClientWithBaseURI(api environments.Api) (*AuthorizationLoginLinksClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "authorizationloginlinks", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating AuthorizationLoginLinksClient: %+v", err) } + + return &AuthorizationLoginLinksClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2022-08-01/authorizationloginlinks/method_post.go b/resource-manager/apimanagement/2022-08-01/authorizationloginlinks/method_post.go new file mode 100644 index 00000000000..720ce277db0 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/authorizationloginlinks/method_post.go @@ -0,0 +1,56 @@ +package authorizationloginlinks + +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 PostOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *AuthorizationLoginResponseContract +} + +// Post ... +func (c AuthorizationLoginLinksClient) Post(ctx context.Context, id AuthorizationId, input AuthorizationLoginRequestContract) (result PostOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/getLoginLinks", 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/apimanagement/2022-08-01/authorizationloginlinks/method_post_autorest.go b/resource-manager/apimanagement/2022-08-01/authorizationloginlinks/method_post_autorest.go deleted file mode 100644 index a5159de4711..00000000000 --- a/resource-manager/apimanagement/2022-08-01/authorizationloginlinks/method_post_autorest.go +++ /dev/null @@ -1,70 +0,0 @@ -package authorizationloginlinks - -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 PostOperationResponse struct { - HttpResponse *http.Response - Model *AuthorizationLoginResponseContract -} - -// Post ... -func (c AuthorizationLoginLinksClient) Post(ctx context.Context, id AuthorizationId, input AuthorizationLoginRequestContract) (result PostOperationResponse, err error) { - req, err := c.preparerForPost(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "authorizationloginlinks.AuthorizationLoginLinksClient", "Post", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "authorizationloginlinks.AuthorizationLoginLinksClient", "Post", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForPost(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "authorizationloginlinks.AuthorizationLoginLinksClient", "Post", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForPost prepares the Post request. -func (c AuthorizationLoginLinksClient) preparerForPost(ctx context.Context, id AuthorizationId, input AuthorizationLoginRequestContract) (*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/getLoginLinks", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForPost handles the response to the Post request. The method always -// closes the http.Response Body. -func (c AuthorizationLoginLinksClient) responderForPost(resp *http.Response) (result PostOperationResponse, 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/apimanagement/2022-08-01/authorizationprovider/client.go b/resource-manager/apimanagement/2022-08-01/authorizationprovider/client.go index 5b0b63f58a1..c5fcce2060d 100644 --- a/resource-manager/apimanagement/2022-08-01/authorizationprovider/client.go +++ b/resource-manager/apimanagement/2022-08-01/authorizationprovider/client.go @@ -1,18 +1,26 @@ package authorizationprovider -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 AuthorizationProviderClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewAuthorizationProviderClientWithBaseURI(endpoint string) AuthorizationProviderClient { - return AuthorizationProviderClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewAuthorizationProviderClientWithBaseURI(api environments.Api) (*AuthorizationProviderClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "authorizationprovider", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating AuthorizationProviderClient: %+v", err) } + + return &AuthorizationProviderClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2022-08-01/authorizationprovider/method_createorupdate.go b/resource-manager/apimanagement/2022-08-01/authorizationprovider/method_createorupdate.go new file mode 100644 index 00000000000..ad20802b2c8 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/authorizationprovider/method_createorupdate.go @@ -0,0 +1,85 @@ +package authorizationprovider + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *AuthorizationProviderContract +} + +type CreateOrUpdateOperationOptions struct { + IfMatch *string +} + +func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { + return CreateOrUpdateOperationOptions{} +} + +func (o CreateOrUpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o CreateOrUpdateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o CreateOrUpdateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// CreateOrUpdate ... +func (c AuthorizationProviderClient) CreateOrUpdate(ctx context.Context, id AuthorizationProviderId, input AuthorizationProviderContract, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + OptionsObject: options, + } + + 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/apimanagement/2022-08-01/authorizationprovider/method_createorupdate_autorest.go b/resource-manager/apimanagement/2022-08-01/authorizationprovider/method_createorupdate_autorest.go deleted file mode 100644 index 5100240bc06..00000000000 --- a/resource-manager/apimanagement/2022-08-01/authorizationprovider/method_createorupdate_autorest.go +++ /dev/null @@ -1,98 +0,0 @@ -package authorizationprovider - -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 *AuthorizationProviderContract -} - -type CreateOrUpdateOperationOptions struct { - IfMatch *string -} - -func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { - return CreateOrUpdateOperationOptions{} -} - -func (o CreateOrUpdateOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o CreateOrUpdateOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// CreateOrUpdate ... -func (c AuthorizationProviderClient) CreateOrUpdate(ctx context.Context, id AuthorizationProviderId, input AuthorizationProviderContract, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdate(ctx, id, input, options) - if err != nil { - err = autorest.NewErrorWithError(err, "authorizationprovider.AuthorizationProviderClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "authorizationprovider.AuthorizationProviderClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCreateOrUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "authorizationprovider.AuthorizationProviderClient", "CreateOrUpdate", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCreateOrUpdate prepares the CreateOrUpdate request. -func (c AuthorizationProviderClient) preparerForCreateOrUpdate(ctx context.Context, id AuthorizationProviderId, input AuthorizationProviderContract, options CreateOrUpdateOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - 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 AuthorizationProviderClient) responderForCreateOrUpdate(resp *http.Response) (result CreateOrUpdateOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2022-08-01/authorizationprovider/method_delete.go b/resource-manager/apimanagement/2022-08-01/authorizationprovider/method_delete.go new file mode 100644 index 00000000000..29ff97189f8 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/authorizationprovider/method_delete.go @@ -0,0 +1,76 @@ +package authorizationprovider + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +type DeleteOperationOptions struct { + IfMatch *string +} + +func DefaultDeleteOperationOptions() DeleteOperationOptions { + return DeleteOperationOptions{} +} + +func (o DeleteOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o DeleteOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o DeleteOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// Delete ... +func (c AuthorizationProviderClient) Delete(ctx context.Context, id AuthorizationProviderId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2022-08-01/authorizationprovider/method_delete_autorest.go b/resource-manager/apimanagement/2022-08-01/authorizationprovider/method_delete_autorest.go deleted file mode 100644 index 28c7fb69f5b..00000000000 --- a/resource-manager/apimanagement/2022-08-01/authorizationprovider/method_delete_autorest.go +++ /dev/null @@ -1,95 +0,0 @@ -package authorizationprovider - -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 DeleteOperationResponse struct { - HttpResponse *http.Response -} - -type DeleteOperationOptions struct { - IfMatch *string -} - -func DefaultDeleteOperationOptions() DeleteOperationOptions { - return DeleteOperationOptions{} -} - -func (o DeleteOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o DeleteOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// Delete ... -func (c AuthorizationProviderClient) Delete(ctx context.Context, id AuthorizationProviderId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { - req, err := c.preparerForDelete(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "authorizationprovider.AuthorizationProviderClient", "Delete", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "authorizationprovider.AuthorizationProviderClient", "Delete", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForDelete(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "authorizationprovider.AuthorizationProviderClient", "Delete", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForDelete prepares the Delete request. -func (c AuthorizationProviderClient) preparerForDelete(ctx context.Context, id AuthorizationProviderId, options DeleteOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForDelete handles the response to the Delete request. The method always -// closes the http.Response Body. -func (c AuthorizationProviderClient) responderForDelete(resp *http.Response) (result DeleteOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2022-08-01/authorizationprovider/method_get.go b/resource-manager/apimanagement/2022-08-01/authorizationprovider/method_get.go new file mode 100644 index 00000000000..36245d9d14b --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/authorizationprovider/method_get.go @@ -0,0 +1,51 @@ +package authorizationprovider + +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 *AuthorizationProviderContract +} + +// Get ... +func (c AuthorizationProviderClient) Get(ctx context.Context, id AuthorizationProviderId) (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/apimanagement/2022-08-01/authorizationprovider/method_get_autorest.go b/resource-manager/apimanagement/2022-08-01/authorizationprovider/method_get_autorest.go deleted file mode 100644 index a69df7dc9b0..00000000000 --- a/resource-manager/apimanagement/2022-08-01/authorizationprovider/method_get_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package authorizationprovider - -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 *AuthorizationProviderContract -} - -// Get ... -func (c AuthorizationProviderClient) Get(ctx context.Context, id AuthorizationProviderId) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "authorizationprovider.AuthorizationProviderClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "authorizationprovider.AuthorizationProviderClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "authorizationprovider.AuthorizationProviderClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c AuthorizationProviderClient) preparerForGet(ctx context.Context, id AuthorizationProviderId) (*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 AuthorizationProviderClient) 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/apimanagement/2022-08-01/authorizationprovider/method_listbyservice.go b/resource-manager/apimanagement/2022-08-01/authorizationprovider/method_listbyservice.go new file mode 100644 index 00000000000..f0982bf9950 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/authorizationprovider/method_listbyservice.go @@ -0,0 +1,125 @@ +package authorizationprovider + +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 ListByServiceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]AuthorizationProviderContract +} + +type ListByServiceCompleteResult struct { + Items []AuthorizationProviderContract +} + +type ListByServiceOperationOptions struct { + Filter *string + Skip *int64 + Top *int64 +} + +func DefaultListByServiceOperationOptions() ListByServiceOperationOptions { + return ListByServiceOperationOptions{} +} + +func (o ListByServiceOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListByServiceOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListByServiceOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.Skip != nil { + out.Append("$skip", fmt.Sprintf("%v", *o.Skip)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +// ListByService ... +func (c AuthorizationProviderClient) ListByService(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (result ListByServiceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/authorizationProviders", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]AuthorizationProviderContract `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByServiceComplete retrieves all the results into a single object +func (c AuthorizationProviderClient) ListByServiceComplete(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (ListByServiceCompleteResult, error) { + return c.ListByServiceCompleteMatchingPredicate(ctx, id, options, AuthorizationProviderContractOperationPredicate{}) +} + +// ListByServiceCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AuthorizationProviderClient) ListByServiceCompleteMatchingPredicate(ctx context.Context, id ServiceId, options ListByServiceOperationOptions, predicate AuthorizationProviderContractOperationPredicate) (result ListByServiceCompleteResult, err error) { + items := make([]AuthorizationProviderContract, 0) + + resp, err := c.ListByService(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByServiceCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/apimanagement/2022-08-01/authorizationprovider/method_listbyservice_autorest.go b/resource-manager/apimanagement/2022-08-01/authorizationprovider/method_listbyservice_autorest.go deleted file mode 100644 index 1c01d2af2fe..00000000000 --- a/resource-manager/apimanagement/2022-08-01/authorizationprovider/method_listbyservice_autorest.go +++ /dev/null @@ -1,225 +0,0 @@ -package authorizationprovider - -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 ListByServiceOperationResponse struct { - HttpResponse *http.Response - Model *[]AuthorizationProviderContract - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListByServiceOperationResponse, error) -} - -type ListByServiceCompleteResult struct { - Items []AuthorizationProviderContract -} - -func (r ListByServiceOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListByServiceOperationResponse) LoadMore(ctx context.Context) (resp ListByServiceOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -type ListByServiceOperationOptions struct { - Filter *string - Skip *int64 - Top *int64 -} - -func DefaultListByServiceOperationOptions() ListByServiceOperationOptions { - return ListByServiceOperationOptions{} -} - -func (o ListByServiceOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o ListByServiceOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Filter != nil { - out["$filter"] = *o.Filter - } - - if o.Skip != nil { - out["$skip"] = *o.Skip - } - - if o.Top != nil { - out["$top"] = *o.Top - } - - return out -} - -// ListByService ... -func (c AuthorizationProviderClient) ListByService(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (resp ListByServiceOperationResponse, err error) { - req, err := c.preparerForListByService(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "authorizationprovider.AuthorizationProviderClient", "ListByService", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "authorizationprovider.AuthorizationProviderClient", "ListByService", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListByService(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "authorizationprovider.AuthorizationProviderClient", "ListByService", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListByService prepares the ListByService request. -func (c AuthorizationProviderClient) preparerForListByService(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/authorizationProviders", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListByServiceWithNextLink prepares the ListByService request with the given nextLink token. -func (c AuthorizationProviderClient) preparerForListByServiceWithNextLink(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)) -} - -// responderForListByService handles the response to the ListByService request. The method always -// closes the http.Response Body. -func (c AuthorizationProviderClient) responderForListByService(resp *http.Response) (result ListByServiceOperationResponse, err error) { - type page struct { - Values []AuthorizationProviderContract `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 ListByServiceOperationResponse, err error) { - req, err := c.preparerForListByServiceWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "authorizationprovider.AuthorizationProviderClient", "ListByService", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "authorizationprovider.AuthorizationProviderClient", "ListByService", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByService(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "authorizationprovider.AuthorizationProviderClient", "ListByService", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListByServiceComplete retrieves all of the results into a single object -func (c AuthorizationProviderClient) ListByServiceComplete(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (ListByServiceCompleteResult, error) { - return c.ListByServiceCompleteMatchingPredicate(ctx, id, options, AuthorizationProviderContractOperationPredicate{}) -} - -// ListByServiceCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c AuthorizationProviderClient) ListByServiceCompleteMatchingPredicate(ctx context.Context, id ServiceId, options ListByServiceOperationOptions, predicate AuthorizationProviderContractOperationPredicate) (resp ListByServiceCompleteResult, err error) { - items := make([]AuthorizationProviderContract, 0) - - page, err := c.ListByService(ctx, id, options) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListByServiceCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/apimanagement/2022-08-01/authorizations/client.go b/resource-manager/apimanagement/2022-08-01/authorizations/client.go index b7da5521b01..20162719da1 100644 --- a/resource-manager/apimanagement/2022-08-01/authorizations/client.go +++ b/resource-manager/apimanagement/2022-08-01/authorizations/client.go @@ -1,18 +1,26 @@ package authorizations -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 AuthorizationsClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewAuthorizationsClientWithBaseURI(endpoint string) AuthorizationsClient { - return AuthorizationsClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewAuthorizationsClientWithBaseURI(api environments.Api) (*AuthorizationsClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "authorizations", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating AuthorizationsClient: %+v", err) } + + return &AuthorizationsClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2022-08-01/authorizations/constants.go b/resource-manager/apimanagement/2022-08-01/authorizations/constants.go index e5a273d4574..9e2147e81f9 100644 --- a/resource-manager/apimanagement/2022-08-01/authorizations/constants.go +++ b/resource-manager/apimanagement/2022-08-01/authorizations/constants.go @@ -1,6 +1,10 @@ package authorizations -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 PossibleValuesForAuthorizationType() []string { } } +func (s *AuthorizationType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAuthorizationType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseAuthorizationType(input string) (*AuthorizationType, error) { vals := map[string]AuthorizationType{ "oauth2": AuthorizationTypeOAuthTwo, @@ -44,6 +61,19 @@ func PossibleValuesForOAuth2GrantType() []string { } } +func (s *OAuth2GrantType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseOAuth2GrantType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseOAuth2GrantType(input string) (*OAuth2GrantType, error) { vals := map[string]OAuth2GrantType{ "authorizationcode": OAuth2GrantTypeAuthorizationCode, diff --git a/resource-manager/apimanagement/2022-08-01/authorizations/method_authorizationlistbyauthorizationprovider.go b/resource-manager/apimanagement/2022-08-01/authorizations/method_authorizationlistbyauthorizationprovider.go new file mode 100644 index 00000000000..bf4ad8f66d7 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/authorizations/method_authorizationlistbyauthorizationprovider.go @@ -0,0 +1,125 @@ +package authorizations + +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 AuthorizationListByAuthorizationProviderOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]AuthorizationContract +} + +type AuthorizationListByAuthorizationProviderCompleteResult struct { + Items []AuthorizationContract +} + +type AuthorizationListByAuthorizationProviderOperationOptions struct { + Filter *string + Skip *int64 + Top *int64 +} + +func DefaultAuthorizationListByAuthorizationProviderOperationOptions() AuthorizationListByAuthorizationProviderOperationOptions { + return AuthorizationListByAuthorizationProviderOperationOptions{} +} + +func (o AuthorizationListByAuthorizationProviderOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o AuthorizationListByAuthorizationProviderOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o AuthorizationListByAuthorizationProviderOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.Skip != nil { + out.Append("$skip", fmt.Sprintf("%v", *o.Skip)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +// AuthorizationListByAuthorizationProvider ... +func (c AuthorizationsClient) AuthorizationListByAuthorizationProvider(ctx context.Context, id AuthorizationProviderId, options AuthorizationListByAuthorizationProviderOperationOptions) (result AuthorizationListByAuthorizationProviderOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/authorizations", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]AuthorizationContract `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// AuthorizationListByAuthorizationProviderComplete retrieves all the results into a single object +func (c AuthorizationsClient) AuthorizationListByAuthorizationProviderComplete(ctx context.Context, id AuthorizationProviderId, options AuthorizationListByAuthorizationProviderOperationOptions) (AuthorizationListByAuthorizationProviderCompleteResult, error) { + return c.AuthorizationListByAuthorizationProviderCompleteMatchingPredicate(ctx, id, options, AuthorizationContractOperationPredicate{}) +} + +// AuthorizationListByAuthorizationProviderCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AuthorizationsClient) AuthorizationListByAuthorizationProviderCompleteMatchingPredicate(ctx context.Context, id AuthorizationProviderId, options AuthorizationListByAuthorizationProviderOperationOptions, predicate AuthorizationContractOperationPredicate) (result AuthorizationListByAuthorizationProviderCompleteResult, err error) { + items := make([]AuthorizationContract, 0) + + resp, err := c.AuthorizationListByAuthorizationProvider(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = AuthorizationListByAuthorizationProviderCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/apimanagement/2022-08-01/authorizations/method_authorizationlistbyauthorizationprovider_autorest.go b/resource-manager/apimanagement/2022-08-01/authorizations/method_authorizationlistbyauthorizationprovider_autorest.go deleted file mode 100644 index cbb34bd8d01..00000000000 --- a/resource-manager/apimanagement/2022-08-01/authorizations/method_authorizationlistbyauthorizationprovider_autorest.go +++ /dev/null @@ -1,225 +0,0 @@ -package authorizations - -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 AuthorizationListByAuthorizationProviderOperationResponse struct { - HttpResponse *http.Response - Model *[]AuthorizationContract - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (AuthorizationListByAuthorizationProviderOperationResponse, error) -} - -type AuthorizationListByAuthorizationProviderCompleteResult struct { - Items []AuthorizationContract -} - -func (r AuthorizationListByAuthorizationProviderOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r AuthorizationListByAuthorizationProviderOperationResponse) LoadMore(ctx context.Context) (resp AuthorizationListByAuthorizationProviderOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -type AuthorizationListByAuthorizationProviderOperationOptions struct { - Filter *string - Skip *int64 - Top *int64 -} - -func DefaultAuthorizationListByAuthorizationProviderOperationOptions() AuthorizationListByAuthorizationProviderOperationOptions { - return AuthorizationListByAuthorizationProviderOperationOptions{} -} - -func (o AuthorizationListByAuthorizationProviderOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o AuthorizationListByAuthorizationProviderOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Filter != nil { - out["$filter"] = *o.Filter - } - - if o.Skip != nil { - out["$skip"] = *o.Skip - } - - if o.Top != nil { - out["$top"] = *o.Top - } - - return out -} - -// AuthorizationListByAuthorizationProvider ... -func (c AuthorizationsClient) AuthorizationListByAuthorizationProvider(ctx context.Context, id AuthorizationProviderId, options AuthorizationListByAuthorizationProviderOperationOptions) (resp AuthorizationListByAuthorizationProviderOperationResponse, err error) { - req, err := c.preparerForAuthorizationListByAuthorizationProvider(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "authorizations.AuthorizationsClient", "AuthorizationListByAuthorizationProvider", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "authorizations.AuthorizationsClient", "AuthorizationListByAuthorizationProvider", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForAuthorizationListByAuthorizationProvider(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "authorizations.AuthorizationsClient", "AuthorizationListByAuthorizationProvider", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForAuthorizationListByAuthorizationProvider prepares the AuthorizationListByAuthorizationProvider request. -func (c AuthorizationsClient) preparerForAuthorizationListByAuthorizationProvider(ctx context.Context, id AuthorizationProviderId, options AuthorizationListByAuthorizationProviderOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/authorizations", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForAuthorizationListByAuthorizationProviderWithNextLink prepares the AuthorizationListByAuthorizationProvider request with the given nextLink token. -func (c AuthorizationsClient) preparerForAuthorizationListByAuthorizationProviderWithNextLink(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)) -} - -// responderForAuthorizationListByAuthorizationProvider handles the response to the AuthorizationListByAuthorizationProvider request. The method always -// closes the http.Response Body. -func (c AuthorizationsClient) responderForAuthorizationListByAuthorizationProvider(resp *http.Response) (result AuthorizationListByAuthorizationProviderOperationResponse, err error) { - type page struct { - Values []AuthorizationContract `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 AuthorizationListByAuthorizationProviderOperationResponse, err error) { - req, err := c.preparerForAuthorizationListByAuthorizationProviderWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "authorizations.AuthorizationsClient", "AuthorizationListByAuthorizationProvider", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "authorizations.AuthorizationsClient", "AuthorizationListByAuthorizationProvider", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForAuthorizationListByAuthorizationProvider(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "authorizations.AuthorizationsClient", "AuthorizationListByAuthorizationProvider", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// AuthorizationListByAuthorizationProviderComplete retrieves all of the results into a single object -func (c AuthorizationsClient) AuthorizationListByAuthorizationProviderComplete(ctx context.Context, id AuthorizationProviderId, options AuthorizationListByAuthorizationProviderOperationOptions) (AuthorizationListByAuthorizationProviderCompleteResult, error) { - return c.AuthorizationListByAuthorizationProviderCompleteMatchingPredicate(ctx, id, options, AuthorizationContractOperationPredicate{}) -} - -// AuthorizationListByAuthorizationProviderCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c AuthorizationsClient) AuthorizationListByAuthorizationProviderCompleteMatchingPredicate(ctx context.Context, id AuthorizationProviderId, options AuthorizationListByAuthorizationProviderOperationOptions, predicate AuthorizationContractOperationPredicate) (resp AuthorizationListByAuthorizationProviderCompleteResult, err error) { - items := make([]AuthorizationContract, 0) - - page, err := c.AuthorizationListByAuthorizationProvider(ctx, id, options) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := AuthorizationListByAuthorizationProviderCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/apimanagement/2022-08-01/authorizationserver/client.go b/resource-manager/apimanagement/2022-08-01/authorizationserver/client.go index a0b4979583f..8467f21fe14 100644 --- a/resource-manager/apimanagement/2022-08-01/authorizationserver/client.go +++ b/resource-manager/apimanagement/2022-08-01/authorizationserver/client.go @@ -1,18 +1,26 @@ package authorizationserver -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 AuthorizationServerClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewAuthorizationServerClientWithBaseURI(endpoint string) AuthorizationServerClient { - return AuthorizationServerClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewAuthorizationServerClientWithBaseURI(api environments.Api) (*AuthorizationServerClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "authorizationserver", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating AuthorizationServerClient: %+v", err) } + + return &AuthorizationServerClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2022-08-01/authorizationserver/constants.go b/resource-manager/apimanagement/2022-08-01/authorizationserver/constants.go index e04f6ee15bd..135527703de 100644 --- a/resource-manager/apimanagement/2022-08-01/authorizationserver/constants.go +++ b/resource-manager/apimanagement/2022-08-01/authorizationserver/constants.go @@ -1,6 +1,10 @@ package authorizationserver -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. @@ -31,6 +35,19 @@ func PossibleValuesForAuthorizationMethod() []string { } } +func (s *AuthorizationMethod) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAuthorizationMethod(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseAuthorizationMethod(input string) (*AuthorizationMethod, error) { vals := map[string]AuthorizationMethod{ "delete": AuthorizationMethodDELETE, @@ -65,6 +82,19 @@ func PossibleValuesForBearerTokenSendingMethod() []string { } } +func (s *BearerTokenSendingMethod) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseBearerTokenSendingMethod(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseBearerTokenSendingMethod(input string) (*BearerTokenSendingMethod, error) { vals := map[string]BearerTokenSendingMethod{ "authorizationheader": BearerTokenSendingMethodAuthorizationHeader, @@ -93,6 +123,19 @@ func PossibleValuesForClientAuthenticationMethod() []string { } } +func (s *ClientAuthenticationMethod) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseClientAuthenticationMethod(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseClientAuthenticationMethod(input string) (*ClientAuthenticationMethod, error) { vals := map[string]ClientAuthenticationMethod{ "basic": ClientAuthenticationMethodBasic, @@ -125,6 +168,19 @@ func PossibleValuesForGrantType() []string { } } +func (s *GrantType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseGrantType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseGrantType(input string) (*GrantType, error) { vals := map[string]GrantType{ "authorizationcode": GrantTypeAuthorizationCode, diff --git a/resource-manager/apimanagement/2022-08-01/authorizationserver/method_createorupdate.go b/resource-manager/apimanagement/2022-08-01/authorizationserver/method_createorupdate.go new file mode 100644 index 00000000000..9c56c38cce1 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/authorizationserver/method_createorupdate.go @@ -0,0 +1,85 @@ +package authorizationserver + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *AuthorizationServerContract +} + +type CreateOrUpdateOperationOptions struct { + IfMatch *string +} + +func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { + return CreateOrUpdateOperationOptions{} +} + +func (o CreateOrUpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o CreateOrUpdateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o CreateOrUpdateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// CreateOrUpdate ... +func (c AuthorizationServerClient) CreateOrUpdate(ctx context.Context, id AuthorizationServerId, input AuthorizationServerContract, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + OptionsObject: options, + } + + 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/apimanagement/2022-08-01/authorizationserver/method_createorupdate_autorest.go b/resource-manager/apimanagement/2022-08-01/authorizationserver/method_createorupdate_autorest.go deleted file mode 100644 index 60a97c7646d..00000000000 --- a/resource-manager/apimanagement/2022-08-01/authorizationserver/method_createorupdate_autorest.go +++ /dev/null @@ -1,98 +0,0 @@ -package authorizationserver - -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 *AuthorizationServerContract -} - -type CreateOrUpdateOperationOptions struct { - IfMatch *string -} - -func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { - return CreateOrUpdateOperationOptions{} -} - -func (o CreateOrUpdateOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o CreateOrUpdateOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// CreateOrUpdate ... -func (c AuthorizationServerClient) CreateOrUpdate(ctx context.Context, id AuthorizationServerId, input AuthorizationServerContract, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdate(ctx, id, input, options) - if err != nil { - err = autorest.NewErrorWithError(err, "authorizationserver.AuthorizationServerClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "authorizationserver.AuthorizationServerClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCreateOrUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "authorizationserver.AuthorizationServerClient", "CreateOrUpdate", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCreateOrUpdate prepares the CreateOrUpdate request. -func (c AuthorizationServerClient) preparerForCreateOrUpdate(ctx context.Context, id AuthorizationServerId, input AuthorizationServerContract, options CreateOrUpdateOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - 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 AuthorizationServerClient) responderForCreateOrUpdate(resp *http.Response) (result CreateOrUpdateOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2022-08-01/authorizationserver/method_delete.go b/resource-manager/apimanagement/2022-08-01/authorizationserver/method_delete.go new file mode 100644 index 00000000000..ad1674315f1 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/authorizationserver/method_delete.go @@ -0,0 +1,76 @@ +package authorizationserver + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +type DeleteOperationOptions struct { + IfMatch *string +} + +func DefaultDeleteOperationOptions() DeleteOperationOptions { + return DeleteOperationOptions{} +} + +func (o DeleteOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o DeleteOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o DeleteOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// Delete ... +func (c AuthorizationServerClient) Delete(ctx context.Context, id AuthorizationServerId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2022-08-01/authorizationserver/method_delete_autorest.go b/resource-manager/apimanagement/2022-08-01/authorizationserver/method_delete_autorest.go deleted file mode 100644 index d7cc9dff660..00000000000 --- a/resource-manager/apimanagement/2022-08-01/authorizationserver/method_delete_autorest.go +++ /dev/null @@ -1,95 +0,0 @@ -package authorizationserver - -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 DeleteOperationResponse struct { - HttpResponse *http.Response -} - -type DeleteOperationOptions struct { - IfMatch *string -} - -func DefaultDeleteOperationOptions() DeleteOperationOptions { - return DeleteOperationOptions{} -} - -func (o DeleteOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o DeleteOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// Delete ... -func (c AuthorizationServerClient) Delete(ctx context.Context, id AuthorizationServerId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { - req, err := c.preparerForDelete(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "authorizationserver.AuthorizationServerClient", "Delete", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "authorizationserver.AuthorizationServerClient", "Delete", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForDelete(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "authorizationserver.AuthorizationServerClient", "Delete", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForDelete prepares the Delete request. -func (c AuthorizationServerClient) preparerForDelete(ctx context.Context, id AuthorizationServerId, options DeleteOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForDelete handles the response to the Delete request. The method always -// closes the http.Response Body. -func (c AuthorizationServerClient) responderForDelete(resp *http.Response) (result DeleteOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2022-08-01/authorizationserver/method_get.go b/resource-manager/apimanagement/2022-08-01/authorizationserver/method_get.go new file mode 100644 index 00000000000..35bc15341b9 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/authorizationserver/method_get.go @@ -0,0 +1,51 @@ +package authorizationserver + +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 *AuthorizationServerContract +} + +// Get ... +func (c AuthorizationServerClient) Get(ctx context.Context, id AuthorizationServerId) (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/apimanagement/2022-08-01/authorizationserver/method_get_autorest.go b/resource-manager/apimanagement/2022-08-01/authorizationserver/method_get_autorest.go deleted file mode 100644 index 4f6ec3d9ba4..00000000000 --- a/resource-manager/apimanagement/2022-08-01/authorizationserver/method_get_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package authorizationserver - -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 *AuthorizationServerContract -} - -// Get ... -func (c AuthorizationServerClient) Get(ctx context.Context, id AuthorizationServerId) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "authorizationserver.AuthorizationServerClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "authorizationserver.AuthorizationServerClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "authorizationserver.AuthorizationServerClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c AuthorizationServerClient) preparerForGet(ctx context.Context, id AuthorizationServerId) (*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 AuthorizationServerClient) 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/apimanagement/2022-08-01/authorizationserver/method_getentitytag.go b/resource-manager/apimanagement/2022-08-01/authorizationserver/method_getentitytag.go new file mode 100644 index 00000000000..4eb7f0abe34 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/authorizationserver/method_getentitytag.go @@ -0,0 +1,46 @@ +package authorizationserver + +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 GetEntityTagOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// GetEntityTag ... +func (c AuthorizationServerClient) GetEntityTag(ctx context.Context, id AuthorizationServerId) (result GetEntityTagOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodHead, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2022-08-01/authorizationserver/method_getentitytag_autorest.go b/resource-manager/apimanagement/2022-08-01/authorizationserver/method_getentitytag_autorest.go deleted file mode 100644 index 6ca77e2c3d7..00000000000 --- a/resource-manager/apimanagement/2022-08-01/authorizationserver/method_getentitytag_autorest.go +++ /dev/null @@ -1,66 +0,0 @@ -package authorizationserver - -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 GetEntityTagOperationResponse struct { - HttpResponse *http.Response -} - -// GetEntityTag ... -func (c AuthorizationServerClient) GetEntityTag(ctx context.Context, id AuthorizationServerId) (result GetEntityTagOperationResponse, err error) { - req, err := c.preparerForGetEntityTag(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "authorizationserver.AuthorizationServerClient", "GetEntityTag", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "authorizationserver.AuthorizationServerClient", "GetEntityTag", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetEntityTag(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "authorizationserver.AuthorizationServerClient", "GetEntityTag", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetEntityTag prepares the GetEntityTag request. -func (c AuthorizationServerClient) preparerForGetEntityTag(ctx context.Context, id AuthorizationServerId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsHead(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetEntityTag handles the response to the GetEntityTag request. The method always -// closes the http.Response Body. -func (c AuthorizationServerClient) responderForGetEntityTag(resp *http.Response) (result GetEntityTagOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2022-08-01/authorizationserver/method_listbyservice.go b/resource-manager/apimanagement/2022-08-01/authorizationserver/method_listbyservice.go new file mode 100644 index 00000000000..17a21580a93 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/authorizationserver/method_listbyservice.go @@ -0,0 +1,125 @@ +package authorizationserver + +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 ListByServiceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]AuthorizationServerContract +} + +type ListByServiceCompleteResult struct { + Items []AuthorizationServerContract +} + +type ListByServiceOperationOptions struct { + Filter *string + Skip *int64 + Top *int64 +} + +func DefaultListByServiceOperationOptions() ListByServiceOperationOptions { + return ListByServiceOperationOptions{} +} + +func (o ListByServiceOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListByServiceOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListByServiceOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.Skip != nil { + out.Append("$skip", fmt.Sprintf("%v", *o.Skip)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +// ListByService ... +func (c AuthorizationServerClient) ListByService(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (result ListByServiceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/authorizationServers", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]AuthorizationServerContract `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByServiceComplete retrieves all the results into a single object +func (c AuthorizationServerClient) ListByServiceComplete(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (ListByServiceCompleteResult, error) { + return c.ListByServiceCompleteMatchingPredicate(ctx, id, options, AuthorizationServerContractOperationPredicate{}) +} + +// ListByServiceCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AuthorizationServerClient) ListByServiceCompleteMatchingPredicate(ctx context.Context, id ServiceId, options ListByServiceOperationOptions, predicate AuthorizationServerContractOperationPredicate) (result ListByServiceCompleteResult, err error) { + items := make([]AuthorizationServerContract, 0) + + resp, err := c.ListByService(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByServiceCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/apimanagement/2022-08-01/authorizationserver/method_listbyservice_autorest.go b/resource-manager/apimanagement/2022-08-01/authorizationserver/method_listbyservice_autorest.go deleted file mode 100644 index 7d3c48d2ad9..00000000000 --- a/resource-manager/apimanagement/2022-08-01/authorizationserver/method_listbyservice_autorest.go +++ /dev/null @@ -1,225 +0,0 @@ -package authorizationserver - -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 ListByServiceOperationResponse struct { - HttpResponse *http.Response - Model *[]AuthorizationServerContract - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListByServiceOperationResponse, error) -} - -type ListByServiceCompleteResult struct { - Items []AuthorizationServerContract -} - -func (r ListByServiceOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListByServiceOperationResponse) LoadMore(ctx context.Context) (resp ListByServiceOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -type ListByServiceOperationOptions struct { - Filter *string - Skip *int64 - Top *int64 -} - -func DefaultListByServiceOperationOptions() ListByServiceOperationOptions { - return ListByServiceOperationOptions{} -} - -func (o ListByServiceOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o ListByServiceOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Filter != nil { - out["$filter"] = *o.Filter - } - - if o.Skip != nil { - out["$skip"] = *o.Skip - } - - if o.Top != nil { - out["$top"] = *o.Top - } - - return out -} - -// ListByService ... -func (c AuthorizationServerClient) ListByService(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (resp ListByServiceOperationResponse, err error) { - req, err := c.preparerForListByService(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "authorizationserver.AuthorizationServerClient", "ListByService", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "authorizationserver.AuthorizationServerClient", "ListByService", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListByService(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "authorizationserver.AuthorizationServerClient", "ListByService", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListByService prepares the ListByService request. -func (c AuthorizationServerClient) preparerForListByService(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/authorizationServers", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListByServiceWithNextLink prepares the ListByService request with the given nextLink token. -func (c AuthorizationServerClient) preparerForListByServiceWithNextLink(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)) -} - -// responderForListByService handles the response to the ListByService request. The method always -// closes the http.Response Body. -func (c AuthorizationServerClient) responderForListByService(resp *http.Response) (result ListByServiceOperationResponse, err error) { - type page struct { - Values []AuthorizationServerContract `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 ListByServiceOperationResponse, err error) { - req, err := c.preparerForListByServiceWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "authorizationserver.AuthorizationServerClient", "ListByService", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "authorizationserver.AuthorizationServerClient", "ListByService", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByService(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "authorizationserver.AuthorizationServerClient", "ListByService", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListByServiceComplete retrieves all of the results into a single object -func (c AuthorizationServerClient) ListByServiceComplete(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (ListByServiceCompleteResult, error) { - return c.ListByServiceCompleteMatchingPredicate(ctx, id, options, AuthorizationServerContractOperationPredicate{}) -} - -// ListByServiceCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c AuthorizationServerClient) ListByServiceCompleteMatchingPredicate(ctx context.Context, id ServiceId, options ListByServiceOperationOptions, predicate AuthorizationServerContractOperationPredicate) (resp ListByServiceCompleteResult, err error) { - items := make([]AuthorizationServerContract, 0) - - page, err := c.ListByService(ctx, id, options) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListByServiceCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/apimanagement/2022-08-01/authorizationserver/method_listsecrets.go b/resource-manager/apimanagement/2022-08-01/authorizationserver/method_listsecrets.go new file mode 100644 index 00000000000..e65f9582795 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/authorizationserver/method_listsecrets.go @@ -0,0 +1,52 @@ +package authorizationserver + +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 ListSecretsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *AuthorizationServerSecretsContract +} + +// ListSecrets ... +func (c AuthorizationServerClient) ListSecrets(ctx context.Context, id AuthorizationServerId) (result ListSecretsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/listSecrets", 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/apimanagement/2022-08-01/authorizationserver/method_listsecrets_autorest.go b/resource-manager/apimanagement/2022-08-01/authorizationserver/method_listsecrets_autorest.go deleted file mode 100644 index 246b21f3eb2..00000000000 --- a/resource-manager/apimanagement/2022-08-01/authorizationserver/method_listsecrets_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package authorizationserver - -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 ListSecretsOperationResponse struct { - HttpResponse *http.Response - Model *AuthorizationServerSecretsContract -} - -// ListSecrets ... -func (c AuthorizationServerClient) ListSecrets(ctx context.Context, id AuthorizationServerId) (result ListSecretsOperationResponse, err error) { - req, err := c.preparerForListSecrets(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "authorizationserver.AuthorizationServerClient", "ListSecrets", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "authorizationserver.AuthorizationServerClient", "ListSecrets", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListSecrets(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "authorizationserver.AuthorizationServerClient", "ListSecrets", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForListSecrets prepares the ListSecrets request. -func (c AuthorizationServerClient) preparerForListSecrets(ctx context.Context, id AuthorizationServerId) (*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/listSecrets", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListSecrets handles the response to the ListSecrets request. The method always -// closes the http.Response Body. -func (c AuthorizationServerClient) responderForListSecrets(resp *http.Response) (result ListSecretsOperationResponse, 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/apimanagement/2022-08-01/authorizationserver/method_update.go b/resource-manager/apimanagement/2022-08-01/authorizationserver/method_update.go new file mode 100644 index 00000000000..d92ea160b6f --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/authorizationserver/method_update.go @@ -0,0 +1,84 @@ +package authorizationserver + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *AuthorizationServerContract +} + +type UpdateOperationOptions struct { + IfMatch *string +} + +func DefaultUpdateOperationOptions() UpdateOperationOptions { + return UpdateOperationOptions{} +} + +func (o UpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o UpdateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o UpdateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// Update ... +func (c AuthorizationServerClient) Update(ctx context.Context, id AuthorizationServerId, input AuthorizationServerUpdateContract, options UpdateOperationOptions) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + OptionsObject: options, + } + + 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/apimanagement/2022-08-01/authorizationserver/method_update_autorest.go b/resource-manager/apimanagement/2022-08-01/authorizationserver/method_update_autorest.go deleted file mode 100644 index 7bb82b54e5f..00000000000 --- a/resource-manager/apimanagement/2022-08-01/authorizationserver/method_update_autorest.go +++ /dev/null @@ -1,98 +0,0 @@ -package authorizationserver - -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 *AuthorizationServerContract -} - -type UpdateOperationOptions struct { - IfMatch *string -} - -func DefaultUpdateOperationOptions() UpdateOperationOptions { - return UpdateOperationOptions{} -} - -func (o UpdateOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o UpdateOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// Update ... -func (c AuthorizationServerClient) Update(ctx context.Context, id AuthorizationServerId, input AuthorizationServerUpdateContract, options UpdateOperationOptions) (result UpdateOperationResponse, err error) { - req, err := c.preparerForUpdate(ctx, id, input, options) - if err != nil { - err = autorest.NewErrorWithError(err, "authorizationserver.AuthorizationServerClient", "Update", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "authorizationserver.AuthorizationServerClient", "Update", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "authorizationserver.AuthorizationServerClient", "Update", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForUpdate prepares the Update request. -func (c AuthorizationServerClient) preparerForUpdate(ctx context.Context, id AuthorizationServerId, input AuthorizationServerUpdateContract, options UpdateOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPatch(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - 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 AuthorizationServerClient) 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/apimanagement/2022-08-01/backend/client.go b/resource-manager/apimanagement/2022-08-01/backend/client.go index 6bfb57d9510..b942440b60a 100644 --- a/resource-manager/apimanagement/2022-08-01/backend/client.go +++ b/resource-manager/apimanagement/2022-08-01/backend/client.go @@ -1,18 +1,26 @@ package backend -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 BackendClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewBackendClientWithBaseURI(endpoint string) BackendClient { - return BackendClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewBackendClientWithBaseURI(api environments.Api) (*BackendClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "backend", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating BackendClient: %+v", err) } + + return &BackendClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2022-08-01/backend/constants.go b/resource-manager/apimanagement/2022-08-01/backend/constants.go index ea964ece6fb..fe71e64cb91 100644 --- a/resource-manager/apimanagement/2022-08-01/backend/constants.go +++ b/resource-manager/apimanagement/2022-08-01/backend/constants.go @@ -1,6 +1,10 @@ package backend -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 PossibleValuesForBackendProtocol() []string { } } +func (s *BackendProtocol) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseBackendProtocol(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseBackendProtocol(input string) (*BackendProtocol, error) { vals := map[string]BackendProtocol{ "http": BackendProtocolHTTP, diff --git a/resource-manager/apimanagement/2022-08-01/backend/method_createorupdate.go b/resource-manager/apimanagement/2022-08-01/backend/method_createorupdate.go new file mode 100644 index 00000000000..c999d10c186 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/backend/method_createorupdate.go @@ -0,0 +1,85 @@ +package backend + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *BackendContract +} + +type CreateOrUpdateOperationOptions struct { + IfMatch *string +} + +func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { + return CreateOrUpdateOperationOptions{} +} + +func (o CreateOrUpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o CreateOrUpdateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o CreateOrUpdateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// CreateOrUpdate ... +func (c BackendClient) CreateOrUpdate(ctx context.Context, id BackendId, input BackendContract, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + OptionsObject: options, + } + + 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/apimanagement/2022-08-01/backend/method_createorupdate_autorest.go b/resource-manager/apimanagement/2022-08-01/backend/method_createorupdate_autorest.go deleted file mode 100644 index 75dec17d56d..00000000000 --- a/resource-manager/apimanagement/2022-08-01/backend/method_createorupdate_autorest.go +++ /dev/null @@ -1,98 +0,0 @@ -package backend - -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 *BackendContract -} - -type CreateOrUpdateOperationOptions struct { - IfMatch *string -} - -func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { - return CreateOrUpdateOperationOptions{} -} - -func (o CreateOrUpdateOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o CreateOrUpdateOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// CreateOrUpdate ... -func (c BackendClient) CreateOrUpdate(ctx context.Context, id BackendId, input BackendContract, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdate(ctx, id, input, options) - if err != nil { - err = autorest.NewErrorWithError(err, "backend.BackendClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "backend.BackendClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCreateOrUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "backend.BackendClient", "CreateOrUpdate", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCreateOrUpdate prepares the CreateOrUpdate request. -func (c BackendClient) preparerForCreateOrUpdate(ctx context.Context, id BackendId, input BackendContract, options CreateOrUpdateOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - 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 BackendClient) responderForCreateOrUpdate(resp *http.Response) (result CreateOrUpdateOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2022-08-01/backend/method_delete.go b/resource-manager/apimanagement/2022-08-01/backend/method_delete.go new file mode 100644 index 00000000000..a8e6a5ab37b --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/backend/method_delete.go @@ -0,0 +1,76 @@ +package backend + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +type DeleteOperationOptions struct { + IfMatch *string +} + +func DefaultDeleteOperationOptions() DeleteOperationOptions { + return DeleteOperationOptions{} +} + +func (o DeleteOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o DeleteOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o DeleteOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// Delete ... +func (c BackendClient) Delete(ctx context.Context, id BackendId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2022-08-01/backend/method_delete_autorest.go b/resource-manager/apimanagement/2022-08-01/backend/method_delete_autorest.go deleted file mode 100644 index c1c6dc95ec7..00000000000 --- a/resource-manager/apimanagement/2022-08-01/backend/method_delete_autorest.go +++ /dev/null @@ -1,95 +0,0 @@ -package backend - -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 DeleteOperationResponse struct { - HttpResponse *http.Response -} - -type DeleteOperationOptions struct { - IfMatch *string -} - -func DefaultDeleteOperationOptions() DeleteOperationOptions { - return DeleteOperationOptions{} -} - -func (o DeleteOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o DeleteOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// Delete ... -func (c BackendClient) Delete(ctx context.Context, id BackendId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { - req, err := c.preparerForDelete(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "backend.BackendClient", "Delete", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "backend.BackendClient", "Delete", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForDelete(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "backend.BackendClient", "Delete", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForDelete prepares the Delete request. -func (c BackendClient) preparerForDelete(ctx context.Context, id BackendId, options DeleteOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForDelete handles the response to the Delete request. The method always -// closes the http.Response Body. -func (c BackendClient) responderForDelete(resp *http.Response) (result DeleteOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2022-08-01/backend/method_get.go b/resource-manager/apimanagement/2022-08-01/backend/method_get.go new file mode 100644 index 00000000000..2af01eaec6f --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/backend/method_get.go @@ -0,0 +1,51 @@ +package backend + +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 *BackendContract +} + +// Get ... +func (c BackendClient) Get(ctx context.Context, id BackendId) (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/apimanagement/2022-08-01/backend/method_get_autorest.go b/resource-manager/apimanagement/2022-08-01/backend/method_get_autorest.go deleted file mode 100644 index ad57ec2ac1f..00000000000 --- a/resource-manager/apimanagement/2022-08-01/backend/method_get_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package backend - -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 *BackendContract -} - -// Get ... -func (c BackendClient) Get(ctx context.Context, id BackendId) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "backend.BackendClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "backend.BackendClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "backend.BackendClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c BackendClient) preparerForGet(ctx context.Context, id BackendId) (*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 BackendClient) 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/apimanagement/2022-08-01/backend/method_getentitytag.go b/resource-manager/apimanagement/2022-08-01/backend/method_getentitytag.go new file mode 100644 index 00000000000..6bff18fa57d --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/backend/method_getentitytag.go @@ -0,0 +1,46 @@ +package backend + +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 GetEntityTagOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// GetEntityTag ... +func (c BackendClient) GetEntityTag(ctx context.Context, id BackendId) (result GetEntityTagOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodHead, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2022-08-01/backend/method_getentitytag_autorest.go b/resource-manager/apimanagement/2022-08-01/backend/method_getentitytag_autorest.go deleted file mode 100644 index 9d500b6b320..00000000000 --- a/resource-manager/apimanagement/2022-08-01/backend/method_getentitytag_autorest.go +++ /dev/null @@ -1,66 +0,0 @@ -package backend - -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 GetEntityTagOperationResponse struct { - HttpResponse *http.Response -} - -// GetEntityTag ... -func (c BackendClient) GetEntityTag(ctx context.Context, id BackendId) (result GetEntityTagOperationResponse, err error) { - req, err := c.preparerForGetEntityTag(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "backend.BackendClient", "GetEntityTag", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "backend.BackendClient", "GetEntityTag", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetEntityTag(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "backend.BackendClient", "GetEntityTag", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetEntityTag prepares the GetEntityTag request. -func (c BackendClient) preparerForGetEntityTag(ctx context.Context, id BackendId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsHead(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetEntityTag handles the response to the GetEntityTag request. The method always -// closes the http.Response Body. -func (c BackendClient) responderForGetEntityTag(resp *http.Response) (result GetEntityTagOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2022-08-01/backend/method_listbyservice.go b/resource-manager/apimanagement/2022-08-01/backend/method_listbyservice.go new file mode 100644 index 00000000000..1c0cb8aab20 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/backend/method_listbyservice.go @@ -0,0 +1,125 @@ +package backend + +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 ListByServiceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]BackendContract +} + +type ListByServiceCompleteResult struct { + Items []BackendContract +} + +type ListByServiceOperationOptions struct { + Filter *string + Skip *int64 + Top *int64 +} + +func DefaultListByServiceOperationOptions() ListByServiceOperationOptions { + return ListByServiceOperationOptions{} +} + +func (o ListByServiceOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListByServiceOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListByServiceOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.Skip != nil { + out.Append("$skip", fmt.Sprintf("%v", *o.Skip)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +// ListByService ... +func (c BackendClient) ListByService(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (result ListByServiceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/backends", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]BackendContract `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByServiceComplete retrieves all the results into a single object +func (c BackendClient) ListByServiceComplete(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (ListByServiceCompleteResult, error) { + return c.ListByServiceCompleteMatchingPredicate(ctx, id, options, BackendContractOperationPredicate{}) +} + +// ListByServiceCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c BackendClient) ListByServiceCompleteMatchingPredicate(ctx context.Context, id ServiceId, options ListByServiceOperationOptions, predicate BackendContractOperationPredicate) (result ListByServiceCompleteResult, err error) { + items := make([]BackendContract, 0) + + resp, err := c.ListByService(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByServiceCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/apimanagement/2022-08-01/backend/method_listbyservice_autorest.go b/resource-manager/apimanagement/2022-08-01/backend/method_listbyservice_autorest.go deleted file mode 100644 index d2c7a50b168..00000000000 --- a/resource-manager/apimanagement/2022-08-01/backend/method_listbyservice_autorest.go +++ /dev/null @@ -1,225 +0,0 @@ -package backend - -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 ListByServiceOperationResponse struct { - HttpResponse *http.Response - Model *[]BackendContract - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListByServiceOperationResponse, error) -} - -type ListByServiceCompleteResult struct { - Items []BackendContract -} - -func (r ListByServiceOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListByServiceOperationResponse) LoadMore(ctx context.Context) (resp ListByServiceOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -type ListByServiceOperationOptions struct { - Filter *string - Skip *int64 - Top *int64 -} - -func DefaultListByServiceOperationOptions() ListByServiceOperationOptions { - return ListByServiceOperationOptions{} -} - -func (o ListByServiceOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o ListByServiceOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Filter != nil { - out["$filter"] = *o.Filter - } - - if o.Skip != nil { - out["$skip"] = *o.Skip - } - - if o.Top != nil { - out["$top"] = *o.Top - } - - return out -} - -// ListByService ... -func (c BackendClient) ListByService(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (resp ListByServiceOperationResponse, err error) { - req, err := c.preparerForListByService(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "backend.BackendClient", "ListByService", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "backend.BackendClient", "ListByService", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListByService(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "backend.BackendClient", "ListByService", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListByService prepares the ListByService request. -func (c BackendClient) preparerForListByService(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/backends", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListByServiceWithNextLink prepares the ListByService request with the given nextLink token. -func (c BackendClient) preparerForListByServiceWithNextLink(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)) -} - -// responderForListByService handles the response to the ListByService request. The method always -// closes the http.Response Body. -func (c BackendClient) responderForListByService(resp *http.Response) (result ListByServiceOperationResponse, err error) { - type page struct { - Values []BackendContract `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 ListByServiceOperationResponse, err error) { - req, err := c.preparerForListByServiceWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "backend.BackendClient", "ListByService", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "backend.BackendClient", "ListByService", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByService(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "backend.BackendClient", "ListByService", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListByServiceComplete retrieves all of the results into a single object -func (c BackendClient) ListByServiceComplete(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (ListByServiceCompleteResult, error) { - return c.ListByServiceCompleteMatchingPredicate(ctx, id, options, BackendContractOperationPredicate{}) -} - -// ListByServiceCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c BackendClient) ListByServiceCompleteMatchingPredicate(ctx context.Context, id ServiceId, options ListByServiceOperationOptions, predicate BackendContractOperationPredicate) (resp ListByServiceCompleteResult, err error) { - items := make([]BackendContract, 0) - - page, err := c.ListByService(ctx, id, options) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListByServiceCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/apimanagement/2022-08-01/backend/method_update.go b/resource-manager/apimanagement/2022-08-01/backend/method_update.go new file mode 100644 index 00000000000..16ad3a5f0f9 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/backend/method_update.go @@ -0,0 +1,84 @@ +package backend + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *BackendContract +} + +type UpdateOperationOptions struct { + IfMatch *string +} + +func DefaultUpdateOperationOptions() UpdateOperationOptions { + return UpdateOperationOptions{} +} + +func (o UpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o UpdateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o UpdateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// Update ... +func (c BackendClient) Update(ctx context.Context, id BackendId, input BackendUpdateParameters, options UpdateOperationOptions) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + OptionsObject: options, + } + + 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/apimanagement/2022-08-01/backend/method_update_autorest.go b/resource-manager/apimanagement/2022-08-01/backend/method_update_autorest.go deleted file mode 100644 index 072e94d0e27..00000000000 --- a/resource-manager/apimanagement/2022-08-01/backend/method_update_autorest.go +++ /dev/null @@ -1,98 +0,0 @@ -package backend - -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 *BackendContract -} - -type UpdateOperationOptions struct { - IfMatch *string -} - -func DefaultUpdateOperationOptions() UpdateOperationOptions { - return UpdateOperationOptions{} -} - -func (o UpdateOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o UpdateOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// Update ... -func (c BackendClient) Update(ctx context.Context, id BackendId, input BackendUpdateParameters, options UpdateOperationOptions) (result UpdateOperationResponse, err error) { - req, err := c.preparerForUpdate(ctx, id, input, options) - if err != nil { - err = autorest.NewErrorWithError(err, "backend.BackendClient", "Update", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "backend.BackendClient", "Update", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "backend.BackendClient", "Update", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForUpdate prepares the Update request. -func (c BackendClient) preparerForUpdate(ctx context.Context, id BackendId, input BackendUpdateParameters, options UpdateOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPatch(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - 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 BackendClient) 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/apimanagement/2022-08-01/backendreconnect/client.go b/resource-manager/apimanagement/2022-08-01/backendreconnect/client.go index f4fd38d283c..c2932f63cad 100644 --- a/resource-manager/apimanagement/2022-08-01/backendreconnect/client.go +++ b/resource-manager/apimanagement/2022-08-01/backendreconnect/client.go @@ -1,18 +1,26 @@ package backendreconnect -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 BackendReconnectClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewBackendReconnectClientWithBaseURI(endpoint string) BackendReconnectClient { - return BackendReconnectClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewBackendReconnectClientWithBaseURI(api environments.Api) (*BackendReconnectClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "backendreconnect", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating BackendReconnectClient: %+v", err) } + + return &BackendReconnectClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2022-08-01/backendreconnect/method_backendreconnect.go b/resource-manager/apimanagement/2022-08-01/backendreconnect/method_backendreconnect.go new file mode 100644 index 00000000000..d75c5992fac --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/backendreconnect/method_backendreconnect.go @@ -0,0 +1,51 @@ +package backendreconnect + +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 BackendReconnectOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// BackendReconnect ... +func (c BackendReconnectClient) BackendReconnect(ctx context.Context, id BackendId, input BackendReconnectContract) (result BackendReconnectOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/reconnect", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2022-08-01/backendreconnect/method_backendreconnect_autorest.go b/resource-manager/apimanagement/2022-08-01/backendreconnect/method_backendreconnect_autorest.go deleted file mode 100644 index ae533c15f31..00000000000 --- a/resource-manager/apimanagement/2022-08-01/backendreconnect/method_backendreconnect_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package backendreconnect - -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 BackendReconnectOperationResponse struct { - HttpResponse *http.Response -} - -// BackendReconnect ... -func (c BackendReconnectClient) BackendReconnect(ctx context.Context, id BackendId, input BackendReconnectContract) (result BackendReconnectOperationResponse, err error) { - req, err := c.preparerForBackendReconnect(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "backendreconnect.BackendReconnectClient", "BackendReconnect", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "backendreconnect.BackendReconnectClient", "BackendReconnect", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForBackendReconnect(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "backendreconnect.BackendReconnectClient", "BackendReconnect", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForBackendReconnect prepares the BackendReconnect request. -func (c BackendReconnectClient) preparerForBackendReconnect(ctx context.Context, id BackendId, input BackendReconnectContract) (*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/reconnect", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForBackendReconnect handles the response to the BackendReconnect request. The method always -// closes the http.Response Body. -func (c BackendReconnectClient) responderForBackendReconnect(resp *http.Response) (result BackendReconnectOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusAccepted), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2022-08-01/cache/client.go b/resource-manager/apimanagement/2022-08-01/cache/client.go index 1d9fa5007ce..35d771e3d15 100644 --- a/resource-manager/apimanagement/2022-08-01/cache/client.go +++ b/resource-manager/apimanagement/2022-08-01/cache/client.go @@ -1,18 +1,26 @@ package cache -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 CacheClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewCacheClientWithBaseURI(endpoint string) CacheClient { - return CacheClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewCacheClientWithBaseURI(api environments.Api) (*CacheClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "cache", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating CacheClient: %+v", err) } + + return &CacheClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2022-08-01/cache/method_createorupdate.go b/resource-manager/apimanagement/2022-08-01/cache/method_createorupdate.go new file mode 100644 index 00000000000..ae370ba6bb9 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/cache/method_createorupdate.go @@ -0,0 +1,85 @@ +package cache + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *CacheContract +} + +type CreateOrUpdateOperationOptions struct { + IfMatch *string +} + +func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { + return CreateOrUpdateOperationOptions{} +} + +func (o CreateOrUpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o CreateOrUpdateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o CreateOrUpdateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// CreateOrUpdate ... +func (c CacheClient) CreateOrUpdate(ctx context.Context, id CacheId, input CacheContract, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + OptionsObject: options, + } + + 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/apimanagement/2022-08-01/cache/method_createorupdate_autorest.go b/resource-manager/apimanagement/2022-08-01/cache/method_createorupdate_autorest.go deleted file mode 100644 index 157b734abcf..00000000000 --- a/resource-manager/apimanagement/2022-08-01/cache/method_createorupdate_autorest.go +++ /dev/null @@ -1,98 +0,0 @@ -package cache - -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 *CacheContract -} - -type CreateOrUpdateOperationOptions struct { - IfMatch *string -} - -func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { - return CreateOrUpdateOperationOptions{} -} - -func (o CreateOrUpdateOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o CreateOrUpdateOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// CreateOrUpdate ... -func (c CacheClient) CreateOrUpdate(ctx context.Context, id CacheId, input CacheContract, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdate(ctx, id, input, options) - if err != nil { - err = autorest.NewErrorWithError(err, "cache.CacheClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "cache.CacheClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCreateOrUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "cache.CacheClient", "CreateOrUpdate", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCreateOrUpdate prepares the CreateOrUpdate request. -func (c CacheClient) preparerForCreateOrUpdate(ctx context.Context, id CacheId, input CacheContract, options CreateOrUpdateOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - 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 CacheClient) responderForCreateOrUpdate(resp *http.Response) (result CreateOrUpdateOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2022-08-01/cache/method_delete.go b/resource-manager/apimanagement/2022-08-01/cache/method_delete.go new file mode 100644 index 00000000000..4409902bb76 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/cache/method_delete.go @@ -0,0 +1,76 @@ +package cache + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +type DeleteOperationOptions struct { + IfMatch *string +} + +func DefaultDeleteOperationOptions() DeleteOperationOptions { + return DeleteOperationOptions{} +} + +func (o DeleteOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o DeleteOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o DeleteOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// Delete ... +func (c CacheClient) Delete(ctx context.Context, id CacheId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2022-08-01/cache/method_delete_autorest.go b/resource-manager/apimanagement/2022-08-01/cache/method_delete_autorest.go deleted file mode 100644 index d31981601b3..00000000000 --- a/resource-manager/apimanagement/2022-08-01/cache/method_delete_autorest.go +++ /dev/null @@ -1,95 +0,0 @@ -package cache - -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 DeleteOperationResponse struct { - HttpResponse *http.Response -} - -type DeleteOperationOptions struct { - IfMatch *string -} - -func DefaultDeleteOperationOptions() DeleteOperationOptions { - return DeleteOperationOptions{} -} - -func (o DeleteOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o DeleteOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// Delete ... -func (c CacheClient) Delete(ctx context.Context, id CacheId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { - req, err := c.preparerForDelete(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "cache.CacheClient", "Delete", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "cache.CacheClient", "Delete", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForDelete(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "cache.CacheClient", "Delete", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForDelete prepares the Delete request. -func (c CacheClient) preparerForDelete(ctx context.Context, id CacheId, options DeleteOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForDelete handles the response to the Delete request. The method always -// closes the http.Response Body. -func (c CacheClient) responderForDelete(resp *http.Response) (result DeleteOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2022-08-01/cache/method_get.go b/resource-manager/apimanagement/2022-08-01/cache/method_get.go new file mode 100644 index 00000000000..8108214f781 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/cache/method_get.go @@ -0,0 +1,51 @@ +package cache + +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 *CacheContract +} + +// Get ... +func (c CacheClient) Get(ctx context.Context, id CacheId) (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/apimanagement/2022-08-01/cache/method_get_autorest.go b/resource-manager/apimanagement/2022-08-01/cache/method_get_autorest.go deleted file mode 100644 index 3e001237bb8..00000000000 --- a/resource-manager/apimanagement/2022-08-01/cache/method_get_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package cache - -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 *CacheContract -} - -// Get ... -func (c CacheClient) Get(ctx context.Context, id CacheId) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "cache.CacheClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "cache.CacheClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "cache.CacheClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c CacheClient) preparerForGet(ctx context.Context, id CacheId) (*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 CacheClient) 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/apimanagement/2022-08-01/cache/method_getentitytag.go b/resource-manager/apimanagement/2022-08-01/cache/method_getentitytag.go new file mode 100644 index 00000000000..a221bde18d1 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/cache/method_getentitytag.go @@ -0,0 +1,46 @@ +package cache + +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 GetEntityTagOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// GetEntityTag ... +func (c CacheClient) GetEntityTag(ctx context.Context, id CacheId) (result GetEntityTagOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodHead, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2022-08-01/cache/method_getentitytag_autorest.go b/resource-manager/apimanagement/2022-08-01/cache/method_getentitytag_autorest.go deleted file mode 100644 index 5ac7d004001..00000000000 --- a/resource-manager/apimanagement/2022-08-01/cache/method_getentitytag_autorest.go +++ /dev/null @@ -1,66 +0,0 @@ -package cache - -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 GetEntityTagOperationResponse struct { - HttpResponse *http.Response -} - -// GetEntityTag ... -func (c CacheClient) GetEntityTag(ctx context.Context, id CacheId) (result GetEntityTagOperationResponse, err error) { - req, err := c.preparerForGetEntityTag(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "cache.CacheClient", "GetEntityTag", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "cache.CacheClient", "GetEntityTag", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetEntityTag(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "cache.CacheClient", "GetEntityTag", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetEntityTag prepares the GetEntityTag request. -func (c CacheClient) preparerForGetEntityTag(ctx context.Context, id CacheId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsHead(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetEntityTag handles the response to the GetEntityTag request. The method always -// closes the http.Response Body. -func (c CacheClient) responderForGetEntityTag(resp *http.Response) (result GetEntityTagOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2022-08-01/cache/method_listbyservice.go b/resource-manager/apimanagement/2022-08-01/cache/method_listbyservice.go new file mode 100644 index 00000000000..748d4374751 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/cache/method_listbyservice.go @@ -0,0 +1,121 @@ +package cache + +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 ListByServiceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]CacheContract +} + +type ListByServiceCompleteResult struct { + Items []CacheContract +} + +type ListByServiceOperationOptions struct { + Skip *int64 + Top *int64 +} + +func DefaultListByServiceOperationOptions() ListByServiceOperationOptions { + return ListByServiceOperationOptions{} +} + +func (o ListByServiceOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListByServiceOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListByServiceOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Skip != nil { + out.Append("$skip", fmt.Sprintf("%v", *o.Skip)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +// ListByService ... +func (c CacheClient) ListByService(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (result ListByServiceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/caches", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]CacheContract `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByServiceComplete retrieves all the results into a single object +func (c CacheClient) ListByServiceComplete(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (ListByServiceCompleteResult, error) { + return c.ListByServiceCompleteMatchingPredicate(ctx, id, options, CacheContractOperationPredicate{}) +} + +// ListByServiceCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c CacheClient) ListByServiceCompleteMatchingPredicate(ctx context.Context, id ServiceId, options ListByServiceOperationOptions, predicate CacheContractOperationPredicate) (result ListByServiceCompleteResult, err error) { + items := make([]CacheContract, 0) + + resp, err := c.ListByService(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByServiceCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/apimanagement/2022-08-01/cache/method_listbyservice_autorest.go b/resource-manager/apimanagement/2022-08-01/cache/method_listbyservice_autorest.go deleted file mode 100644 index 0bf37f6599c..00000000000 --- a/resource-manager/apimanagement/2022-08-01/cache/method_listbyservice_autorest.go +++ /dev/null @@ -1,220 +0,0 @@ -package cache - -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 ListByServiceOperationResponse struct { - HttpResponse *http.Response - Model *[]CacheContract - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListByServiceOperationResponse, error) -} - -type ListByServiceCompleteResult struct { - Items []CacheContract -} - -func (r ListByServiceOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListByServiceOperationResponse) LoadMore(ctx context.Context) (resp ListByServiceOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -type ListByServiceOperationOptions struct { - Skip *int64 - Top *int64 -} - -func DefaultListByServiceOperationOptions() ListByServiceOperationOptions { - return ListByServiceOperationOptions{} -} - -func (o ListByServiceOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o ListByServiceOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Skip != nil { - out["$skip"] = *o.Skip - } - - if o.Top != nil { - out["$top"] = *o.Top - } - - return out -} - -// ListByService ... -func (c CacheClient) ListByService(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (resp ListByServiceOperationResponse, err error) { - req, err := c.preparerForListByService(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "cache.CacheClient", "ListByService", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "cache.CacheClient", "ListByService", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListByService(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "cache.CacheClient", "ListByService", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListByService prepares the ListByService request. -func (c CacheClient) preparerForListByService(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/caches", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListByServiceWithNextLink prepares the ListByService request with the given nextLink token. -func (c CacheClient) preparerForListByServiceWithNextLink(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)) -} - -// responderForListByService handles the response to the ListByService request. The method always -// closes the http.Response Body. -func (c CacheClient) responderForListByService(resp *http.Response) (result ListByServiceOperationResponse, err error) { - type page struct { - Values []CacheContract `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 ListByServiceOperationResponse, err error) { - req, err := c.preparerForListByServiceWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "cache.CacheClient", "ListByService", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "cache.CacheClient", "ListByService", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByService(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "cache.CacheClient", "ListByService", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListByServiceComplete retrieves all of the results into a single object -func (c CacheClient) ListByServiceComplete(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (ListByServiceCompleteResult, error) { - return c.ListByServiceCompleteMatchingPredicate(ctx, id, options, CacheContractOperationPredicate{}) -} - -// ListByServiceCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c CacheClient) ListByServiceCompleteMatchingPredicate(ctx context.Context, id ServiceId, options ListByServiceOperationOptions, predicate CacheContractOperationPredicate) (resp ListByServiceCompleteResult, err error) { - items := make([]CacheContract, 0) - - page, err := c.ListByService(ctx, id, options) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListByServiceCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/apimanagement/2022-08-01/cache/method_update.go b/resource-manager/apimanagement/2022-08-01/cache/method_update.go new file mode 100644 index 00000000000..3aca9c35b36 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/cache/method_update.go @@ -0,0 +1,84 @@ +package cache + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *CacheContract +} + +type UpdateOperationOptions struct { + IfMatch *string +} + +func DefaultUpdateOperationOptions() UpdateOperationOptions { + return UpdateOperationOptions{} +} + +func (o UpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o UpdateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o UpdateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// Update ... +func (c CacheClient) Update(ctx context.Context, id CacheId, input CacheUpdateParameters, options UpdateOperationOptions) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + OptionsObject: options, + } + + 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/apimanagement/2022-08-01/cache/method_update_autorest.go b/resource-manager/apimanagement/2022-08-01/cache/method_update_autorest.go deleted file mode 100644 index 77f9a54c40b..00000000000 --- a/resource-manager/apimanagement/2022-08-01/cache/method_update_autorest.go +++ /dev/null @@ -1,98 +0,0 @@ -package cache - -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 *CacheContract -} - -type UpdateOperationOptions struct { - IfMatch *string -} - -func DefaultUpdateOperationOptions() UpdateOperationOptions { - return UpdateOperationOptions{} -} - -func (o UpdateOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o UpdateOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// Update ... -func (c CacheClient) Update(ctx context.Context, id CacheId, input CacheUpdateParameters, options UpdateOperationOptions) (result UpdateOperationResponse, err error) { - req, err := c.preparerForUpdate(ctx, id, input, options) - if err != nil { - err = autorest.NewErrorWithError(err, "cache.CacheClient", "Update", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "cache.CacheClient", "Update", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "cache.CacheClient", "Update", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForUpdate prepares the Update request. -func (c CacheClient) preparerForUpdate(ctx context.Context, id CacheId, input CacheUpdateParameters, options UpdateOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPatch(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - 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 CacheClient) 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/apimanagement/2022-08-01/certificate/client.go b/resource-manager/apimanagement/2022-08-01/certificate/client.go index f304bfc665d..d850a6c7fd7 100644 --- a/resource-manager/apimanagement/2022-08-01/certificate/client.go +++ b/resource-manager/apimanagement/2022-08-01/certificate/client.go @@ -1,18 +1,26 @@ package certificate -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 CertificateClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewCertificateClientWithBaseURI(endpoint string) CertificateClient { - return CertificateClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewCertificateClientWithBaseURI(api environments.Api) (*CertificateClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "certificate", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating CertificateClient: %+v", err) } + + return &CertificateClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2022-08-01/certificate/method_createorupdate.go b/resource-manager/apimanagement/2022-08-01/certificate/method_createorupdate.go new file mode 100644 index 00000000000..93fbccd7109 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/certificate/method_createorupdate.go @@ -0,0 +1,85 @@ +package certificate + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *CertificateContract +} + +type CreateOrUpdateOperationOptions struct { + IfMatch *string +} + +func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { + return CreateOrUpdateOperationOptions{} +} + +func (o CreateOrUpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o CreateOrUpdateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o CreateOrUpdateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// CreateOrUpdate ... +func (c CertificateClient) CreateOrUpdate(ctx context.Context, id CertificateId, input CertificateCreateOrUpdateParameters, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + OptionsObject: options, + } + + 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/apimanagement/2022-08-01/certificate/method_createorupdate_autorest.go b/resource-manager/apimanagement/2022-08-01/certificate/method_createorupdate_autorest.go deleted file mode 100644 index 3f9fa70c148..00000000000 --- a/resource-manager/apimanagement/2022-08-01/certificate/method_createorupdate_autorest.go +++ /dev/null @@ -1,98 +0,0 @@ -package certificate - -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 *CertificateContract -} - -type CreateOrUpdateOperationOptions struct { - IfMatch *string -} - -func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { - return CreateOrUpdateOperationOptions{} -} - -func (o CreateOrUpdateOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o CreateOrUpdateOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// CreateOrUpdate ... -func (c CertificateClient) CreateOrUpdate(ctx context.Context, id CertificateId, input CertificateCreateOrUpdateParameters, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdate(ctx, id, input, options) - if err != nil { - err = autorest.NewErrorWithError(err, "certificate.CertificateClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "certificate.CertificateClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCreateOrUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "certificate.CertificateClient", "CreateOrUpdate", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCreateOrUpdate prepares the CreateOrUpdate request. -func (c CertificateClient) preparerForCreateOrUpdate(ctx context.Context, id CertificateId, input CertificateCreateOrUpdateParameters, options CreateOrUpdateOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - 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 CertificateClient) responderForCreateOrUpdate(resp *http.Response) (result CreateOrUpdateOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2022-08-01/certificate/method_delete.go b/resource-manager/apimanagement/2022-08-01/certificate/method_delete.go new file mode 100644 index 00000000000..18be0e732de --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/certificate/method_delete.go @@ -0,0 +1,76 @@ +package certificate + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +type DeleteOperationOptions struct { + IfMatch *string +} + +func DefaultDeleteOperationOptions() DeleteOperationOptions { + return DeleteOperationOptions{} +} + +func (o DeleteOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o DeleteOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o DeleteOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// Delete ... +func (c CertificateClient) Delete(ctx context.Context, id CertificateId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2022-08-01/certificate/method_delete_autorest.go b/resource-manager/apimanagement/2022-08-01/certificate/method_delete_autorest.go deleted file mode 100644 index c5682ce3425..00000000000 --- a/resource-manager/apimanagement/2022-08-01/certificate/method_delete_autorest.go +++ /dev/null @@ -1,95 +0,0 @@ -package certificate - -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 DeleteOperationResponse struct { - HttpResponse *http.Response -} - -type DeleteOperationOptions struct { - IfMatch *string -} - -func DefaultDeleteOperationOptions() DeleteOperationOptions { - return DeleteOperationOptions{} -} - -func (o DeleteOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o DeleteOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// Delete ... -func (c CertificateClient) Delete(ctx context.Context, id CertificateId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { - req, err := c.preparerForDelete(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "certificate.CertificateClient", "Delete", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "certificate.CertificateClient", "Delete", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForDelete(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "certificate.CertificateClient", "Delete", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForDelete prepares the Delete request. -func (c CertificateClient) preparerForDelete(ctx context.Context, id CertificateId, options DeleteOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForDelete handles the response to the Delete request. The method always -// closes the http.Response Body. -func (c CertificateClient) responderForDelete(resp *http.Response) (result DeleteOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2022-08-01/certificate/method_get.go b/resource-manager/apimanagement/2022-08-01/certificate/method_get.go new file mode 100644 index 00000000000..27e5fbafdfa --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/certificate/method_get.go @@ -0,0 +1,51 @@ +package certificate + +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 *CertificateContract +} + +// Get ... +func (c CertificateClient) Get(ctx context.Context, id CertificateId) (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/apimanagement/2022-08-01/certificate/method_get_autorest.go b/resource-manager/apimanagement/2022-08-01/certificate/method_get_autorest.go deleted file mode 100644 index 9e737922fb6..00000000000 --- a/resource-manager/apimanagement/2022-08-01/certificate/method_get_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package certificate - -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 *CertificateContract -} - -// Get ... -func (c CertificateClient) Get(ctx context.Context, id CertificateId) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "certificate.CertificateClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "certificate.CertificateClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "certificate.CertificateClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c CertificateClient) preparerForGet(ctx context.Context, id CertificateId) (*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 CertificateClient) 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/apimanagement/2022-08-01/certificate/method_getentitytag.go b/resource-manager/apimanagement/2022-08-01/certificate/method_getentitytag.go new file mode 100644 index 00000000000..bcbd65b8f9b --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/certificate/method_getentitytag.go @@ -0,0 +1,46 @@ +package certificate + +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 GetEntityTagOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// GetEntityTag ... +func (c CertificateClient) GetEntityTag(ctx context.Context, id CertificateId) (result GetEntityTagOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodHead, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2022-08-01/certificate/method_getentitytag_autorest.go b/resource-manager/apimanagement/2022-08-01/certificate/method_getentitytag_autorest.go deleted file mode 100644 index 767706d23d9..00000000000 --- a/resource-manager/apimanagement/2022-08-01/certificate/method_getentitytag_autorest.go +++ /dev/null @@ -1,66 +0,0 @@ -package certificate - -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 GetEntityTagOperationResponse struct { - HttpResponse *http.Response -} - -// GetEntityTag ... -func (c CertificateClient) GetEntityTag(ctx context.Context, id CertificateId) (result GetEntityTagOperationResponse, err error) { - req, err := c.preparerForGetEntityTag(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "certificate.CertificateClient", "GetEntityTag", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "certificate.CertificateClient", "GetEntityTag", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetEntityTag(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "certificate.CertificateClient", "GetEntityTag", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetEntityTag prepares the GetEntityTag request. -func (c CertificateClient) preparerForGetEntityTag(ctx context.Context, id CertificateId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsHead(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetEntityTag handles the response to the GetEntityTag request. The method always -// closes the http.Response Body. -func (c CertificateClient) responderForGetEntityTag(resp *http.Response) (result GetEntityTagOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2022-08-01/certificate/method_listbyservice.go b/resource-manager/apimanagement/2022-08-01/certificate/method_listbyservice.go new file mode 100644 index 00000000000..cf5649185fc --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/certificate/method_listbyservice.go @@ -0,0 +1,129 @@ +package certificate + +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 ListByServiceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]CertificateContract +} + +type ListByServiceCompleteResult struct { + Items []CertificateContract +} + +type ListByServiceOperationOptions struct { + Filter *string + IsKeyVaultRefreshFailed *bool + Skip *int64 + Top *int64 +} + +func DefaultListByServiceOperationOptions() ListByServiceOperationOptions { + return ListByServiceOperationOptions{} +} + +func (o ListByServiceOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListByServiceOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListByServiceOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.IsKeyVaultRefreshFailed != nil { + out.Append("isKeyVaultRefreshFailed", fmt.Sprintf("%v", *o.IsKeyVaultRefreshFailed)) + } + if o.Skip != nil { + out.Append("$skip", fmt.Sprintf("%v", *o.Skip)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +// ListByService ... +func (c CertificateClient) ListByService(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (result ListByServiceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/certificates", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]CertificateContract `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByServiceComplete retrieves all the results into a single object +func (c CertificateClient) ListByServiceComplete(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (ListByServiceCompleteResult, error) { + return c.ListByServiceCompleteMatchingPredicate(ctx, id, options, CertificateContractOperationPredicate{}) +} + +// ListByServiceCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c CertificateClient) ListByServiceCompleteMatchingPredicate(ctx context.Context, id ServiceId, options ListByServiceOperationOptions, predicate CertificateContractOperationPredicate) (result ListByServiceCompleteResult, err error) { + items := make([]CertificateContract, 0) + + resp, err := c.ListByService(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByServiceCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/apimanagement/2022-08-01/certificate/method_listbyservice_autorest.go b/resource-manager/apimanagement/2022-08-01/certificate/method_listbyservice_autorest.go deleted file mode 100644 index b7ec6fe5728..00000000000 --- a/resource-manager/apimanagement/2022-08-01/certificate/method_listbyservice_autorest.go +++ /dev/null @@ -1,230 +0,0 @@ -package certificate - -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 ListByServiceOperationResponse struct { - HttpResponse *http.Response - Model *[]CertificateContract - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListByServiceOperationResponse, error) -} - -type ListByServiceCompleteResult struct { - Items []CertificateContract -} - -func (r ListByServiceOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListByServiceOperationResponse) LoadMore(ctx context.Context) (resp ListByServiceOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -type ListByServiceOperationOptions struct { - Filter *string - IsKeyVaultRefreshFailed *bool - Skip *int64 - Top *int64 -} - -func DefaultListByServiceOperationOptions() ListByServiceOperationOptions { - return ListByServiceOperationOptions{} -} - -func (o ListByServiceOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o ListByServiceOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Filter != nil { - out["$filter"] = *o.Filter - } - - if o.IsKeyVaultRefreshFailed != nil { - out["isKeyVaultRefreshFailed"] = *o.IsKeyVaultRefreshFailed - } - - if o.Skip != nil { - out["$skip"] = *o.Skip - } - - if o.Top != nil { - out["$top"] = *o.Top - } - - return out -} - -// ListByService ... -func (c CertificateClient) ListByService(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (resp ListByServiceOperationResponse, err error) { - req, err := c.preparerForListByService(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "certificate.CertificateClient", "ListByService", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "certificate.CertificateClient", "ListByService", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListByService(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "certificate.CertificateClient", "ListByService", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListByService prepares the ListByService request. -func (c CertificateClient) preparerForListByService(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/certificates", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListByServiceWithNextLink prepares the ListByService request with the given nextLink token. -func (c CertificateClient) preparerForListByServiceWithNextLink(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)) -} - -// responderForListByService handles the response to the ListByService request. The method always -// closes the http.Response Body. -func (c CertificateClient) responderForListByService(resp *http.Response) (result ListByServiceOperationResponse, err error) { - type page struct { - Values []CertificateContract `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 ListByServiceOperationResponse, err error) { - req, err := c.preparerForListByServiceWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "certificate.CertificateClient", "ListByService", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "certificate.CertificateClient", "ListByService", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByService(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "certificate.CertificateClient", "ListByService", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListByServiceComplete retrieves all of the results into a single object -func (c CertificateClient) ListByServiceComplete(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (ListByServiceCompleteResult, error) { - return c.ListByServiceCompleteMatchingPredicate(ctx, id, options, CertificateContractOperationPredicate{}) -} - -// ListByServiceCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c CertificateClient) ListByServiceCompleteMatchingPredicate(ctx context.Context, id ServiceId, options ListByServiceOperationOptions, predicate CertificateContractOperationPredicate) (resp ListByServiceCompleteResult, err error) { - items := make([]CertificateContract, 0) - - page, err := c.ListByService(ctx, id, options) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListByServiceCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/apimanagement/2022-08-01/certificate/method_refreshsecret.go b/resource-manager/apimanagement/2022-08-01/certificate/method_refreshsecret.go new file mode 100644 index 00000000000..8c7aaf79162 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/certificate/method_refreshsecret.go @@ -0,0 +1,52 @@ +package certificate + +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 RefreshSecretOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *CertificateContract +} + +// RefreshSecret ... +func (c CertificateClient) RefreshSecret(ctx context.Context, id CertificateId) (result RefreshSecretOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/refreshSecret", 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/apimanagement/2022-08-01/certificate/method_refreshsecret_autorest.go b/resource-manager/apimanagement/2022-08-01/certificate/method_refreshsecret_autorest.go deleted file mode 100644 index 8202c39a9c5..00000000000 --- a/resource-manager/apimanagement/2022-08-01/certificate/method_refreshsecret_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package certificate - -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 RefreshSecretOperationResponse struct { - HttpResponse *http.Response - Model *CertificateContract -} - -// RefreshSecret ... -func (c CertificateClient) RefreshSecret(ctx context.Context, id CertificateId) (result RefreshSecretOperationResponse, err error) { - req, err := c.preparerForRefreshSecret(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "certificate.CertificateClient", "RefreshSecret", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "certificate.CertificateClient", "RefreshSecret", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForRefreshSecret(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "certificate.CertificateClient", "RefreshSecret", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForRefreshSecret prepares the RefreshSecret request. -func (c CertificateClient) preparerForRefreshSecret(ctx context.Context, id CertificateId) (*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/refreshSecret", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForRefreshSecret handles the response to the RefreshSecret request. The method always -// closes the http.Response Body. -func (c CertificateClient) responderForRefreshSecret(resp *http.Response) (result RefreshSecretOperationResponse, 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/apimanagement/2022-08-01/client.go b/resource-manager/apimanagement/2022-08-01/client.go index ac7d3b35acd..03481dcd001 100644 --- a/resource-manager/apimanagement/2022-08-01/client.go +++ b/resource-manager/apimanagement/2022-08-01/client.go @@ -4,7 +4,8 @@ package v2022_08_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/apimanagement/2022-08-01/api" "github.com/hashicorp/go-azure-sdk/resource-manager/apimanagement/2022-08-01/apidiagnostic" "github.com/hashicorp/go-azure-sdk/resource-manager/apimanagement/2022-08-01/apiissue" @@ -106,6 +107,8 @@ import ( "github.com/hashicorp/go-azure-sdk/resource-manager/apimanagement/2022-08-01/users" "github.com/hashicorp/go-azure-sdk/resource-manager/apimanagement/2022-08-01/usersubscription" "github.com/hashicorp/go-azure-sdk/resource-manager/apimanagement/2022-08-01/usertoken" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/environments" ) type Client struct { @@ -212,412 +215,714 @@ type Client struct { Users *users.UsersClient } -func NewClientWithBaseURI(endpoint string, configureAuthFunc func(c *autorest.Client)) Client { +func NewClientWithBaseURI(api environments.Api, configureFunc func(c *resourcemanager.Client)) (*Client, error) { + apiClient, err := api.NewApiClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building Api client: %+v", err) + } + configureFunc(apiClient.Client) - apiClient := api.NewApiClientWithBaseURI(endpoint) - configureAuthFunc(&apiClient.Client) + apiDiagnosticClient, err := apidiagnostic.NewApiDiagnosticClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building ApiDiagnostic client: %+v", err) + } + configureFunc(apiDiagnosticClient.Client) - apiDiagnosticClient := apidiagnostic.NewApiDiagnosticClientWithBaseURI(endpoint) - configureAuthFunc(&apiDiagnosticClient.Client) + apiIssueAttachmentClient, err := apiissueattachment.NewApiIssueAttachmentClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building ApiIssueAttachment client: %+v", err) + } + configureFunc(apiIssueAttachmentClient.Client) - apiIssueAttachmentClient := apiissueattachment.NewApiIssueAttachmentClientWithBaseURI(endpoint) - configureAuthFunc(&apiIssueAttachmentClient.Client) + apiIssueClient, err := apiissue.NewApiIssueClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building ApiIssue client: %+v", err) + } + configureFunc(apiIssueClient.Client) - apiIssueClient := apiissue.NewApiIssueClientWithBaseURI(endpoint) - configureAuthFunc(&apiIssueClient.Client) + apiIssueCommentClient, err := apiissuecomment.NewApiIssueCommentClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building ApiIssueComment client: %+v", err) + } + configureFunc(apiIssueCommentClient.Client) - apiIssueCommentClient := apiissuecomment.NewApiIssueCommentClientWithBaseURI(endpoint) - configureAuthFunc(&apiIssueCommentClient.Client) + apiManagementServiceClient, err := apimanagementservice.NewApiManagementServiceClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building ApiManagementService client: %+v", err) + } + configureFunc(apiManagementServiceClient.Client) - apiManagementServiceClient := apimanagementservice.NewApiManagementServiceClientWithBaseURI(endpoint) - configureAuthFunc(&apiManagementServiceClient.Client) + apiManagementServiceSkusClient, err := apimanagementserviceskus.NewApiManagementServiceSkusClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building ApiManagementServiceSkus client: %+v", err) + } + configureFunc(apiManagementServiceSkusClient.Client) - apiManagementServiceSkusClient := apimanagementserviceskus.NewApiManagementServiceSkusClientWithBaseURI(endpoint) - configureAuthFunc(&apiManagementServiceSkusClient.Client) + apiOperationClient, err := apioperation.NewApiOperationClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building ApiOperation client: %+v", err) + } + configureFunc(apiOperationClient.Client) - apiOperationClient := apioperation.NewApiOperationClientWithBaseURI(endpoint) - configureAuthFunc(&apiOperationClient.Client) + apiOperationPolicyClient, err := apioperationpolicy.NewApiOperationPolicyClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building ApiOperationPolicy client: %+v", err) + } + configureFunc(apiOperationPolicyClient.Client) - apiOperationPolicyClient := apioperationpolicy.NewApiOperationPolicyClientWithBaseURI(endpoint) - configureAuthFunc(&apiOperationPolicyClient.Client) + apiOperationTagClient, err := apioperationtag.NewApiOperationTagClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building ApiOperationTag client: %+v", err) + } + configureFunc(apiOperationTagClient.Client) - apiOperationTagClient := apioperationtag.NewApiOperationTagClientWithBaseURI(endpoint) - configureAuthFunc(&apiOperationTagClient.Client) + apiOperationsByTagClient, err := apioperationsbytag.NewApiOperationsByTagClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building ApiOperationsByTag client: %+v", err) + } + configureFunc(apiOperationsByTagClient.Client) - apiOperationsByTagClient := apioperationsbytag.NewApiOperationsByTagClientWithBaseURI(endpoint) - configureAuthFunc(&apiOperationsByTagClient.Client) + apiPolicyClient, err := apipolicy.NewApiPolicyClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building ApiPolicy client: %+v", err) + } + configureFunc(apiPolicyClient.Client) - apiPolicyClient := apipolicy.NewApiPolicyClientWithBaseURI(endpoint) - configureAuthFunc(&apiPolicyClient.Client) + apiProductClient, err := apiproduct.NewApiProductClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building ApiProduct client: %+v", err) + } + configureFunc(apiProductClient.Client) - apiProductClient := apiproduct.NewApiProductClientWithBaseURI(endpoint) - configureAuthFunc(&apiProductClient.Client) + apiReleaseClient, err := apirelease.NewApiReleaseClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building ApiRelease client: %+v", err) + } + configureFunc(apiReleaseClient.Client) - apiReleaseClient := apirelease.NewApiReleaseClientWithBaseURI(endpoint) - configureAuthFunc(&apiReleaseClient.Client) + apiRevisionClient, err := apirevision.NewApiRevisionClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building ApiRevision client: %+v", err) + } + configureFunc(apiRevisionClient.Client) - apiRevisionClient := apirevision.NewApiRevisionClientWithBaseURI(endpoint) - configureAuthFunc(&apiRevisionClient.Client) + apiSchemaClient, err := apischema.NewApiSchemaClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building ApiSchema client: %+v", err) + } + configureFunc(apiSchemaClient.Client) - apiSchemaClient := apischema.NewApiSchemaClientWithBaseURI(endpoint) - configureAuthFunc(&apiSchemaClient.Client) + apiTagClient, err := apitag.NewApiTagClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building ApiTag client: %+v", err) + } + configureFunc(apiTagClient.Client) - apiTagClient := apitag.NewApiTagClientWithBaseURI(endpoint) - configureAuthFunc(&apiTagClient.Client) + apiTagDescriptionClient, err := apitagdescription.NewApiTagDescriptionClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building ApiTagDescription client: %+v", err) + } + configureFunc(apiTagDescriptionClient.Client) - apiTagDescriptionClient := apitagdescription.NewApiTagDescriptionClientWithBaseURI(endpoint) - configureAuthFunc(&apiTagDescriptionClient.Client) + apiVersionSetClient, err := apiversionset.NewApiVersionSetClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building ApiVersionSet client: %+v", err) + } + configureFunc(apiVersionSetClient.Client) - apiVersionSetClient := apiversionset.NewApiVersionSetClientWithBaseURI(endpoint) - configureAuthFunc(&apiVersionSetClient.Client) + apiVersionSetsClient, err := apiversionsets.NewApiVersionSetsClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building ApiVersionSets client: %+v", err) + } + configureFunc(apiVersionSetsClient.Client) - apiVersionSetsClient := apiversionsets.NewApiVersionSetsClientWithBaseURI(endpoint) - configureAuthFunc(&apiVersionSetsClient.Client) + apiWikiClient, err := apiwiki.NewApiWikiClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building ApiWiki client: %+v", err) + } + configureFunc(apiWikiClient.Client) - apiWikiClient := apiwiki.NewApiWikiClientWithBaseURI(endpoint) - configureAuthFunc(&apiWikiClient.Client) + apisByTagClient, err := apisbytag.NewApisByTagClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building ApisByTag client: %+v", err) + } + configureFunc(apisByTagClient.Client) - apisByTagClient := apisbytag.NewApisByTagClientWithBaseURI(endpoint) - configureAuthFunc(&apisByTagClient.Client) + authorizationAccessPolicyClient, err := authorizationaccesspolicy.NewAuthorizationAccessPolicyClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building AuthorizationAccessPolicy client: %+v", err) + } + configureFunc(authorizationAccessPolicyClient.Client) - authorizationAccessPolicyClient := authorizationaccesspolicy.NewAuthorizationAccessPolicyClientWithBaseURI(endpoint) - configureAuthFunc(&authorizationAccessPolicyClient.Client) + authorizationClient, err := authorization.NewAuthorizationClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building Authorization client: %+v", err) + } + configureFunc(authorizationClient.Client) - authorizationClient := authorization.NewAuthorizationClientWithBaseURI(endpoint) - configureAuthFunc(&authorizationClient.Client) + authorizationConfirmConsentCodeClient, err := authorizationconfirmconsentcode.NewAuthorizationConfirmConsentCodeClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building AuthorizationConfirmConsentCode client: %+v", err) + } + configureFunc(authorizationConfirmConsentCodeClient.Client) - authorizationConfirmConsentCodeClient := authorizationconfirmconsentcode.NewAuthorizationConfirmConsentCodeClientWithBaseURI(endpoint) - configureAuthFunc(&authorizationConfirmConsentCodeClient.Client) + authorizationLoginLinksClient, err := authorizationloginlinks.NewAuthorizationLoginLinksClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building AuthorizationLoginLinks client: %+v", err) + } + configureFunc(authorizationLoginLinksClient.Client) - authorizationLoginLinksClient := authorizationloginlinks.NewAuthorizationLoginLinksClientWithBaseURI(endpoint) - configureAuthFunc(&authorizationLoginLinksClient.Client) + authorizationProviderClient, err := authorizationprovider.NewAuthorizationProviderClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building AuthorizationProvider client: %+v", err) + } + configureFunc(authorizationProviderClient.Client) - authorizationProviderClient := authorizationprovider.NewAuthorizationProviderClientWithBaseURI(endpoint) - configureAuthFunc(&authorizationProviderClient.Client) + authorizationServerClient, err := authorizationserver.NewAuthorizationServerClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building AuthorizationServer client: %+v", err) + } + configureFunc(authorizationServerClient.Client) - authorizationServerClient := authorizationserver.NewAuthorizationServerClientWithBaseURI(endpoint) - configureAuthFunc(&authorizationServerClient.Client) + authorizationsClient, err := authorizations.NewAuthorizationsClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building Authorizations client: %+v", err) + } + configureFunc(authorizationsClient.Client) - authorizationsClient := authorizations.NewAuthorizationsClientWithBaseURI(endpoint) - configureAuthFunc(&authorizationsClient.Client) + backendClient, err := backend.NewBackendClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building Backend client: %+v", err) + } + configureFunc(backendClient.Client) - backendClient := backend.NewBackendClientWithBaseURI(endpoint) - configureAuthFunc(&backendClient.Client) + backendReconnectClient, err := backendreconnect.NewBackendReconnectClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building BackendReconnect client: %+v", err) + } + configureFunc(backendReconnectClient.Client) - backendReconnectClient := backendreconnect.NewBackendReconnectClientWithBaseURI(endpoint) - configureAuthFunc(&backendReconnectClient.Client) + cacheClient, err := cache.NewCacheClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building Cache client: %+v", err) + } + configureFunc(cacheClient.Client) - cacheClient := cache.NewCacheClientWithBaseURI(endpoint) - configureAuthFunc(&cacheClient.Client) + certificateClient, err := certificate.NewCertificateClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building Certificate client: %+v", err) + } + configureFunc(certificateClient.Client) - certificateClient := certificate.NewCertificateClientWithBaseURI(endpoint) - configureAuthFunc(&certificateClient.Client) + contentTypeClient, err := contenttype.NewContentTypeClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building ContentType client: %+v", err) + } + configureFunc(contentTypeClient.Client) - contentTypeClient := contenttype.NewContentTypeClientWithBaseURI(endpoint) - configureAuthFunc(&contentTypeClient.Client) + contentTypeContentItemClient, err := contenttypecontentitem.NewContentTypeContentItemClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building ContentTypeContentItem client: %+v", err) + } + configureFunc(contentTypeContentItemClient.Client) - contentTypeContentItemClient := contenttypecontentitem.NewContentTypeContentItemClientWithBaseURI(endpoint) - configureAuthFunc(&contentTypeContentItemClient.Client) + delegationSettingsClient, err := delegationsettings.NewDelegationSettingsClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building DelegationSettings client: %+v", err) + } + configureFunc(delegationSettingsClient.Client) - delegationSettingsClient := delegationsettings.NewDelegationSettingsClientWithBaseURI(endpoint) - configureAuthFunc(&delegationSettingsClient.Client) + deletedServiceClient, err := deletedservice.NewDeletedServiceClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building DeletedService client: %+v", err) + } + configureFunc(deletedServiceClient.Client) - deletedServiceClient := deletedservice.NewDeletedServiceClientWithBaseURI(endpoint) - configureAuthFunc(&deletedServiceClient.Client) + diagnosticClient, err := diagnostic.NewDiagnosticClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building Diagnostic client: %+v", err) + } + configureFunc(diagnosticClient.Client) - diagnosticClient := diagnostic.NewDiagnosticClientWithBaseURI(endpoint) - configureAuthFunc(&diagnosticClient.Client) + documentationResourceClient, err := documentationresource.NewDocumentationResourceClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building DocumentationResource client: %+v", err) + } + configureFunc(documentationResourceClient.Client) - documentationResourceClient := documentationresource.NewDocumentationResourceClientWithBaseURI(endpoint) - configureAuthFunc(&documentationResourceClient.Client) + emailTemplateClient, err := emailtemplate.NewEmailTemplateClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building EmailTemplate client: %+v", err) + } + configureFunc(emailTemplateClient.Client) - emailTemplateClient := emailtemplate.NewEmailTemplateClientWithBaseURI(endpoint) - configureAuthFunc(&emailTemplateClient.Client) + emailTemplatesClient, err := emailtemplates.NewEmailTemplatesClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building EmailTemplates client: %+v", err) + } + configureFunc(emailTemplatesClient.Client) - emailTemplatesClient := emailtemplates.NewEmailTemplatesClientWithBaseURI(endpoint) - configureAuthFunc(&emailTemplatesClient.Client) + gatewayApiClient, err := gatewayapi.NewGatewayApiClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building GatewayApi client: %+v", err) + } + configureFunc(gatewayApiClient.Client) - gatewayApiClient := gatewayapi.NewGatewayApiClientWithBaseURI(endpoint) - configureAuthFunc(&gatewayApiClient.Client) + gatewayCertificateAuthorityClient, err := gatewaycertificateauthority.NewGatewayCertificateAuthorityClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building GatewayCertificateAuthority client: %+v", err) + } + configureFunc(gatewayCertificateAuthorityClient.Client) - gatewayCertificateAuthorityClient := gatewaycertificateauthority.NewGatewayCertificateAuthorityClientWithBaseURI(endpoint) - configureAuthFunc(&gatewayCertificateAuthorityClient.Client) + gatewayClient, err := gateway.NewGatewayClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building Gateway client: %+v", err) + } + configureFunc(gatewayClient.Client) - gatewayClient := gateway.NewGatewayClientWithBaseURI(endpoint) - configureAuthFunc(&gatewayClient.Client) + gatewayGenerateTokenClient, err := gatewaygeneratetoken.NewGatewayGenerateTokenClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building GatewayGenerateToken client: %+v", err) + } + configureFunc(gatewayGenerateTokenClient.Client) - gatewayGenerateTokenClient := gatewaygeneratetoken.NewGatewayGenerateTokenClientWithBaseURI(endpoint) - configureAuthFunc(&gatewayGenerateTokenClient.Client) + gatewayHostnameConfigurationClient, err := gatewayhostnameconfiguration.NewGatewayHostnameConfigurationClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building GatewayHostnameConfiguration client: %+v", err) + } + configureFunc(gatewayHostnameConfigurationClient.Client) - gatewayHostnameConfigurationClient := gatewayhostnameconfiguration.NewGatewayHostnameConfigurationClientWithBaseURI(endpoint) - configureAuthFunc(&gatewayHostnameConfigurationClient.Client) + gatewayListKeysClient, err := gatewaylistkeys.NewGatewayListKeysClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building GatewayListKeys client: %+v", err) + } + configureFunc(gatewayListKeysClient.Client) - gatewayListKeysClient := gatewaylistkeys.NewGatewayListKeysClientWithBaseURI(endpoint) - configureAuthFunc(&gatewayListKeysClient.Client) + gatewayRegenerateKeyClient, err := gatewayregeneratekey.NewGatewayRegenerateKeyClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building GatewayRegenerateKey client: %+v", err) + } + configureFunc(gatewayRegenerateKeyClient.Client) - gatewayRegenerateKeyClient := gatewayregeneratekey.NewGatewayRegenerateKeyClientWithBaseURI(endpoint) - configureAuthFunc(&gatewayRegenerateKeyClient.Client) + graphQLApiResolverClient, err := graphqlapiresolver.NewGraphQLApiResolverClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building GraphQLApiResolver client: %+v", err) + } + configureFunc(graphQLApiResolverClient.Client) - graphQLApiResolverClient := graphqlapiresolver.NewGraphQLApiResolverClientWithBaseURI(endpoint) - configureAuthFunc(&graphQLApiResolverClient.Client) + graphQLApiResolverPolicyClient, err := graphqlapiresolverpolicy.NewGraphQLApiResolverPolicyClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building GraphQLApiResolverPolicy client: %+v", err) + } + configureFunc(graphQLApiResolverPolicyClient.Client) - graphQLApiResolverPolicyClient := graphqlapiresolverpolicy.NewGraphQLApiResolverPolicyClientWithBaseURI(endpoint) - configureAuthFunc(&graphQLApiResolverPolicyClient.Client) + groupClient, err := group.NewGroupClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building Group client: %+v", err) + } + configureFunc(groupClient.Client) - groupClient := group.NewGroupClientWithBaseURI(endpoint) - configureAuthFunc(&groupClient.Client) + groupUserClient, err := groupuser.NewGroupUserClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building GroupUser client: %+v", err) + } + configureFunc(groupUserClient.Client) - groupUserClient := groupuser.NewGroupUserClientWithBaseURI(endpoint) - configureAuthFunc(&groupUserClient.Client) + identityProviderClient, err := identityprovider.NewIdentityProviderClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building IdentityProvider client: %+v", err) + } + configureFunc(identityProviderClient.Client) - identityProviderClient := identityprovider.NewIdentityProviderClientWithBaseURI(endpoint) - configureAuthFunc(&identityProviderClient.Client) + issueClient, err := issue.NewIssueClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building Issue client: %+v", err) + } + configureFunc(issueClient.Client) - issueClient := issue.NewIssueClientWithBaseURI(endpoint) - configureAuthFunc(&issueClient.Client) + loggerClient, err := logger.NewLoggerClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building Logger client: %+v", err) + } + configureFunc(loggerClient.Client) - loggerClient := logger.NewLoggerClientWithBaseURI(endpoint) - configureAuthFunc(&loggerClient.Client) + namedValueClient, err := namedvalue.NewNamedValueClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building NamedValue client: %+v", err) + } + configureFunc(namedValueClient.Client) - namedValueClient := namedvalue.NewNamedValueClientWithBaseURI(endpoint) - configureAuthFunc(&namedValueClient.Client) + networkStatusClient, err := networkstatus.NewNetworkStatusClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building NetworkStatus client: %+v", err) + } + configureFunc(networkStatusClient.Client) - networkStatusClient := networkstatus.NewNetworkStatusClientWithBaseURI(endpoint) - configureAuthFunc(&networkStatusClient.Client) + notificationClient, err := notification.NewNotificationClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building Notification client: %+v", err) + } + configureFunc(notificationClient.Client) - notificationClient := notification.NewNotificationClientWithBaseURI(endpoint) - configureAuthFunc(¬ificationClient.Client) + notificationRecipientEmailClient, err := notificationrecipientemail.NewNotificationRecipientEmailClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building NotificationRecipientEmail client: %+v", err) + } + configureFunc(notificationRecipientEmailClient.Client) - notificationRecipientEmailClient := notificationrecipientemail.NewNotificationRecipientEmailClientWithBaseURI(endpoint) - configureAuthFunc(¬ificationRecipientEmailClient.Client) + notificationRecipientUserClient, err := notificationrecipientuser.NewNotificationRecipientUserClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building NotificationRecipientUser client: %+v", err) + } + configureFunc(notificationRecipientUserClient.Client) - notificationRecipientUserClient := notificationrecipientuser.NewNotificationRecipientUserClientWithBaseURI(endpoint) - configureAuthFunc(¬ificationRecipientUserClient.Client) + openidConnectProviderClient, err := openidconnectprovider.NewOpenidConnectProviderClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building OpenidConnectProvider client: %+v", err) + } + configureFunc(openidConnectProviderClient.Client) - openidConnectProviderClient := openidconnectprovider.NewOpenidConnectProviderClientWithBaseURI(endpoint) - configureAuthFunc(&openidConnectProviderClient.Client) + outboundNetworkDependenciesEndpointsClient, err := outboundnetworkdependenciesendpoints.NewOutboundNetworkDependenciesEndpointsClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building OutboundNetworkDependenciesEndpoints client: %+v", err) + } + configureFunc(outboundNetworkDependenciesEndpointsClient.Client) - outboundNetworkDependenciesEndpointsClient := outboundnetworkdependenciesendpoints.NewOutboundNetworkDependenciesEndpointsClientWithBaseURI(endpoint) - configureAuthFunc(&outboundNetworkDependenciesEndpointsClient.Client) + performConnectivityCheckClient, err := performconnectivitycheck.NewPerformConnectivityCheckClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building PerformConnectivityCheck client: %+v", err) + } + configureFunc(performConnectivityCheckClient.Client) - performConnectivityCheckClient := performconnectivitycheck.NewPerformConnectivityCheckClientWithBaseURI(endpoint) - configureAuthFunc(&performConnectivityCheckClient.Client) + policyClient, err := policy.NewPolicyClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building Policy client: %+v", err) + } + configureFunc(policyClient.Client) - policyClient := policy.NewPolicyClientWithBaseURI(endpoint) - configureAuthFunc(&policyClient.Client) + policyDescriptionClient, err := policydescription.NewPolicyDescriptionClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building PolicyDescription client: %+v", err) + } + configureFunc(policyDescriptionClient.Client) - policyDescriptionClient := policydescription.NewPolicyDescriptionClientWithBaseURI(endpoint) - configureAuthFunc(&policyDescriptionClient.Client) + policyFragmentClient, err := policyfragment.NewPolicyFragmentClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building PolicyFragment client: %+v", err) + } + configureFunc(policyFragmentClient.Client) - policyFragmentClient := policyfragment.NewPolicyFragmentClientWithBaseURI(endpoint) - configureAuthFunc(&policyFragmentClient.Client) + portalConfigClient, err := portalconfig.NewPortalConfigClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building PortalConfig client: %+v", err) + } + configureFunc(portalConfigClient.Client) - portalConfigClient := portalconfig.NewPortalConfigClientWithBaseURI(endpoint) - configureAuthFunc(&portalConfigClient.Client) + portalRevisionClient, err := portalrevision.NewPortalRevisionClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building PortalRevision client: %+v", err) + } + configureFunc(portalRevisionClient.Client) - portalRevisionClient := portalrevision.NewPortalRevisionClientWithBaseURI(endpoint) - configureAuthFunc(&portalRevisionClient.Client) + portalSettingsClient, err := portalsettings.NewPortalSettingsClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building PortalSettings client: %+v", err) + } + configureFunc(portalSettingsClient.Client) - portalSettingsClient := portalsettings.NewPortalSettingsClientWithBaseURI(endpoint) - configureAuthFunc(&portalSettingsClient.Client) + privateEndpointConnectionsClient, err := privateendpointconnections.NewPrivateEndpointConnectionsClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building PrivateEndpointConnections client: %+v", err) + } + configureFunc(privateEndpointConnectionsClient.Client) - privateEndpointConnectionsClient := privateendpointconnections.NewPrivateEndpointConnectionsClientWithBaseURI(endpoint) - configureAuthFunc(&privateEndpointConnectionsClient.Client) + productApiClient, err := productapi.NewProductApiClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building ProductApi client: %+v", err) + } + configureFunc(productApiClient.Client) - productApiClient := productapi.NewProductApiClientWithBaseURI(endpoint) - configureAuthFunc(&productApiClient.Client) + productClient, err := product.NewProductClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building Product client: %+v", err) + } + configureFunc(productClient.Client) - productClient := product.NewProductClientWithBaseURI(endpoint) - configureAuthFunc(&productClient.Client) + productGroupClient, err := productgroup.NewProductGroupClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building ProductGroup client: %+v", err) + } + configureFunc(productGroupClient.Client) - productGroupClient := productgroup.NewProductGroupClientWithBaseURI(endpoint) - configureAuthFunc(&productGroupClient.Client) + productPolicyClient, err := productpolicy.NewProductPolicyClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building ProductPolicy client: %+v", err) + } + configureFunc(productPolicyClient.Client) - productPolicyClient := productpolicy.NewProductPolicyClientWithBaseURI(endpoint) - configureAuthFunc(&productPolicyClient.Client) + productSubscriptionClient, err := productsubscription.NewProductSubscriptionClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building ProductSubscription client: %+v", err) + } + configureFunc(productSubscriptionClient.Client) - productSubscriptionClient := productsubscription.NewProductSubscriptionClientWithBaseURI(endpoint) - configureAuthFunc(&productSubscriptionClient.Client) + productTagClient, err := producttag.NewProductTagClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building ProductTag client: %+v", err) + } + configureFunc(productTagClient.Client) - productTagClient := producttag.NewProductTagClientWithBaseURI(endpoint) - configureAuthFunc(&productTagClient.Client) + productWikiClient, err := productwiki.NewProductWikiClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building ProductWiki client: %+v", err) + } + configureFunc(productWikiClient.Client) - productWikiClient := productwiki.NewProductWikiClientWithBaseURI(endpoint) - configureAuthFunc(&productWikiClient.Client) + productsByTagClient, err := productsbytag.NewProductsByTagClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building ProductsByTag client: %+v", err) + } + configureFunc(productsByTagClient.Client) - productsByTagClient := productsbytag.NewProductsByTagClientWithBaseURI(endpoint) - configureAuthFunc(&productsByTagClient.Client) + quotaByCounterKeysClient, err := quotabycounterkeys.NewQuotaByCounterKeysClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building QuotaByCounterKeys client: %+v", err) + } + configureFunc(quotaByCounterKeysClient.Client) - quotaByCounterKeysClient := quotabycounterkeys.NewQuotaByCounterKeysClientWithBaseURI(endpoint) - configureAuthFunc("aByCounterKeysClient.Client) + quotaByPeriodKeysClient, err := quotabyperiodkeys.NewQuotaByPeriodKeysClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building QuotaByPeriodKeys client: %+v", err) + } + configureFunc(quotaByPeriodKeysClient.Client) - quotaByPeriodKeysClient := quotabyperiodkeys.NewQuotaByPeriodKeysClientWithBaseURI(endpoint) - configureAuthFunc("aByPeriodKeysClient.Client) + regionClient, err := region.NewRegionClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building Region client: %+v", err) + } + configureFunc(regionClient.Client) - regionClient := region.NewRegionClientWithBaseURI(endpoint) - configureAuthFunc(®ionClient.Client) + reportsClient, err := reports.NewReportsClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building Reports client: %+v", err) + } + configureFunc(reportsClient.Client) - reportsClient := reports.NewReportsClientWithBaseURI(endpoint) - configureAuthFunc(&reportsClient.Client) + schemaClient, err := schema.NewSchemaClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building Schema client: %+v", err) + } + configureFunc(schemaClient.Client) - schemaClient := schema.NewSchemaClientWithBaseURI(endpoint) - configureAuthFunc(&schemaClient.Client) + signInSettingsClient, err := signinsettings.NewSignInSettingsClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building SignInSettings client: %+v", err) + } + configureFunc(signInSettingsClient.Client) - signInSettingsClient := signinsettings.NewSignInSettingsClientWithBaseURI(endpoint) - configureAuthFunc(&signInSettingsClient.Client) + signUpSettingsClient, err := signupsettings.NewSignUpSettingsClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building SignUpSettings client: %+v", err) + } + configureFunc(signUpSettingsClient.Client) - signUpSettingsClient := signupsettings.NewSignUpSettingsClientWithBaseURI(endpoint) - configureAuthFunc(&signUpSettingsClient.Client) + skusClient, err := skus.NewSkusClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building Skus client: %+v", err) + } + configureFunc(skusClient.Client) + + subscriptionClient, err := subscription.NewSubscriptionClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building Subscription client: %+v", err) + } + configureFunc(subscriptionClient.Client) + + tagClient, err := tag.NewTagClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building Tag client: %+v", err) + } + configureFunc(tagClient.Client) + + tagResourceClient, err := tagresource.NewTagResourceClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building TagResource client: %+v", err) + } + configureFunc(tagResourceClient.Client) + + tenantAccessClient, err := tenantaccess.NewTenantAccessClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building TenantAccess client: %+v", err) + } + configureFunc(tenantAccessClient.Client) + + tenantAccessGitClient, err := tenantaccessgit.NewTenantAccessGitClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building TenantAccessGit client: %+v", err) + } + configureFunc(tenantAccessGitClient.Client) + + tenantConfigurationClient, err := tenantconfiguration.NewTenantConfigurationClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building TenantConfiguration client: %+v", err) + } + configureFunc(tenantConfigurationClient.Client) + + tenantConfigurationSyncStateClient, err := tenantconfigurationsyncstate.NewTenantConfigurationSyncStateClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building TenantConfigurationSyncState client: %+v", err) + } + configureFunc(tenantConfigurationSyncStateClient.Client) + + tenantSettingsClient, err := tenantsettings.NewTenantSettingsClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building TenantSettings client: %+v", err) + } + configureFunc(tenantSettingsClient.Client) + + userClient, err := user.NewUserClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building User client: %+v", err) + } + configureFunc(userClient.Client) + + userConfirmationPasswordSendClient, err := userconfirmationpasswordsend.NewUserConfirmationPasswordSendClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building UserConfirmationPasswordSend client: %+v", err) + } + configureFunc(userConfirmationPasswordSendClient.Client) + + userGroupClient, err := usergroup.NewUserGroupClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building UserGroup client: %+v", err) + } + configureFunc(userGroupClient.Client) + + userIdentityClient, err := useridentity.NewUserIdentityClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building UserIdentity client: %+v", err) + } + configureFunc(userIdentityClient.Client) + + userSubscriptionClient, err := usersubscription.NewUserSubscriptionClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building UserSubscription client: %+v", err) + } + configureFunc(userSubscriptionClient.Client) + + userTokenClient, err := usertoken.NewUserTokenClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building UserToken client: %+v", err) + } + configureFunc(userTokenClient.Client) - skusClient := skus.NewSkusClientWithBaseURI(endpoint) - configureAuthFunc(&skusClient.Client) - - subscriptionClient := subscription.NewSubscriptionClientWithBaseURI(endpoint) - configureAuthFunc(&subscriptionClient.Client) - - tagClient := tag.NewTagClientWithBaseURI(endpoint) - configureAuthFunc(&tagClient.Client) - - tagResourceClient := tagresource.NewTagResourceClientWithBaseURI(endpoint) - configureAuthFunc(&tagResourceClient.Client) - - tenantAccessClient := tenantaccess.NewTenantAccessClientWithBaseURI(endpoint) - configureAuthFunc(&tenantAccessClient.Client) - - tenantAccessGitClient := tenantaccessgit.NewTenantAccessGitClientWithBaseURI(endpoint) - configureAuthFunc(&tenantAccessGitClient.Client) - - tenantConfigurationClient := tenantconfiguration.NewTenantConfigurationClientWithBaseURI(endpoint) - configureAuthFunc(&tenantConfigurationClient.Client) - - tenantConfigurationSyncStateClient := tenantconfigurationsyncstate.NewTenantConfigurationSyncStateClientWithBaseURI(endpoint) - configureAuthFunc(&tenantConfigurationSyncStateClient.Client) - - tenantSettingsClient := tenantsettings.NewTenantSettingsClientWithBaseURI(endpoint) - configureAuthFunc(&tenantSettingsClient.Client) - - userClient := user.NewUserClientWithBaseURI(endpoint) - configureAuthFunc(&userClient.Client) - - userConfirmationPasswordSendClient := userconfirmationpasswordsend.NewUserConfirmationPasswordSendClientWithBaseURI(endpoint) - configureAuthFunc(&userConfirmationPasswordSendClient.Client) - - userGroupClient := usergroup.NewUserGroupClientWithBaseURI(endpoint) - configureAuthFunc(&userGroupClient.Client) - - userIdentityClient := useridentity.NewUserIdentityClientWithBaseURI(endpoint) - configureAuthFunc(&userIdentityClient.Client) - - userSubscriptionClient := usersubscription.NewUserSubscriptionClientWithBaseURI(endpoint) - configureAuthFunc(&userSubscriptionClient.Client) - - userTokenClient := usertoken.NewUserTokenClientWithBaseURI(endpoint) - configureAuthFunc(&userTokenClient.Client) - - usersClient := users.NewUsersClientWithBaseURI(endpoint) - configureAuthFunc(&usersClient.Client) - - return Client{ - Api: &apiClient, - ApiDiagnostic: &apiDiagnosticClient, - ApiIssue: &apiIssueClient, - ApiIssueAttachment: &apiIssueAttachmentClient, - ApiIssueComment: &apiIssueCommentClient, - ApiManagementService: &apiManagementServiceClient, - ApiManagementServiceSkus: &apiManagementServiceSkusClient, - ApiOperation: &apiOperationClient, - ApiOperationPolicy: &apiOperationPolicyClient, - ApiOperationTag: &apiOperationTagClient, - ApiOperationsByTag: &apiOperationsByTagClient, - ApiPolicy: &apiPolicyClient, - ApiProduct: &apiProductClient, - ApiRelease: &apiReleaseClient, - ApiRevision: &apiRevisionClient, - ApiSchema: &apiSchemaClient, - ApiTag: &apiTagClient, - ApiTagDescription: &apiTagDescriptionClient, - ApiVersionSet: &apiVersionSetClient, - ApiVersionSets: &apiVersionSetsClient, - ApiWiki: &apiWikiClient, - ApisByTag: &apisByTagClient, - Authorization: &authorizationClient, - AuthorizationAccessPolicy: &authorizationAccessPolicyClient, - AuthorizationConfirmConsentCode: &authorizationConfirmConsentCodeClient, - AuthorizationLoginLinks: &authorizationLoginLinksClient, - AuthorizationProvider: &authorizationProviderClient, - AuthorizationServer: &authorizationServerClient, - Authorizations: &authorizationsClient, - Backend: &backendClient, - BackendReconnect: &backendReconnectClient, - Cache: &cacheClient, - Certificate: &certificateClient, - ContentType: &contentTypeClient, - ContentTypeContentItem: &contentTypeContentItemClient, - DelegationSettings: &delegationSettingsClient, - DeletedService: &deletedServiceClient, - Diagnostic: &diagnosticClient, - DocumentationResource: &documentationResourceClient, - EmailTemplate: &emailTemplateClient, - EmailTemplates: &emailTemplatesClient, - Gateway: &gatewayClient, - GatewayApi: &gatewayApiClient, - GatewayCertificateAuthority: &gatewayCertificateAuthorityClient, - GatewayGenerateToken: &gatewayGenerateTokenClient, - GatewayHostnameConfiguration: &gatewayHostnameConfigurationClient, - GatewayListKeys: &gatewayListKeysClient, - GatewayRegenerateKey: &gatewayRegenerateKeyClient, - GraphQLApiResolver: &graphQLApiResolverClient, - GraphQLApiResolverPolicy: &graphQLApiResolverPolicyClient, - Group: &groupClient, - GroupUser: &groupUserClient, - IdentityProvider: &identityProviderClient, - Issue: &issueClient, - Logger: &loggerClient, - NamedValue: &namedValueClient, - NetworkStatus: &networkStatusClient, - Notification: ¬ificationClient, - NotificationRecipientEmail: ¬ificationRecipientEmailClient, - NotificationRecipientUser: ¬ificationRecipientUserClient, - OpenidConnectProvider: &openidConnectProviderClient, - OutboundNetworkDependenciesEndpoints: &outboundNetworkDependenciesEndpointsClient, - PerformConnectivityCheck: &performConnectivityCheckClient, - Policy: &policyClient, - PolicyDescription: &policyDescriptionClient, - PolicyFragment: &policyFragmentClient, - PortalConfig: &portalConfigClient, - PortalRevision: &portalRevisionClient, - PortalSettings: &portalSettingsClient, - PrivateEndpointConnections: &privateEndpointConnectionsClient, - Product: &productClient, - ProductApi: &productApiClient, - ProductGroup: &productGroupClient, - ProductPolicy: &productPolicyClient, - ProductSubscription: &productSubscriptionClient, - ProductTag: &productTagClient, - ProductWiki: &productWikiClient, - ProductsByTag: &productsByTagClient, - QuotaByCounterKeys: "aByCounterKeysClient, - QuotaByPeriodKeys: "aByPeriodKeysClient, - Region: ®ionClient, - Reports: &reportsClient, - Schema: &schemaClient, - SignInSettings: &signInSettingsClient, - SignUpSettings: &signUpSettingsClient, - Skus: &skusClient, - Subscription: &subscriptionClient, - Tag: &tagClient, - TagResource: &tagResourceClient, - TenantAccess: &tenantAccessClient, - TenantAccessGit: &tenantAccessGitClient, - TenantConfiguration: &tenantConfigurationClient, - TenantConfigurationSyncState: &tenantConfigurationSyncStateClient, - TenantSettings: &tenantSettingsClient, - User: &userClient, - UserConfirmationPasswordSend: &userConfirmationPasswordSendClient, - UserGroup: &userGroupClient, - UserIdentity: &userIdentityClient, - UserSubscription: &userSubscriptionClient, - UserToken: &userTokenClient, - Users: &usersClient, + usersClient, err := users.NewUsersClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building Users client: %+v", err) } + configureFunc(usersClient.Client) + + return &Client{ + Api: apiClient, + ApiDiagnostic: apiDiagnosticClient, + ApiIssue: apiIssueClient, + ApiIssueAttachment: apiIssueAttachmentClient, + ApiIssueComment: apiIssueCommentClient, + ApiManagementService: apiManagementServiceClient, + ApiManagementServiceSkus: apiManagementServiceSkusClient, + ApiOperation: apiOperationClient, + ApiOperationPolicy: apiOperationPolicyClient, + ApiOperationTag: apiOperationTagClient, + ApiOperationsByTag: apiOperationsByTagClient, + ApiPolicy: apiPolicyClient, + ApiProduct: apiProductClient, + ApiRelease: apiReleaseClient, + ApiRevision: apiRevisionClient, + ApiSchema: apiSchemaClient, + ApiTag: apiTagClient, + ApiTagDescription: apiTagDescriptionClient, + ApiVersionSet: apiVersionSetClient, + ApiVersionSets: apiVersionSetsClient, + ApiWiki: apiWikiClient, + ApisByTag: apisByTagClient, + Authorization: authorizationClient, + AuthorizationAccessPolicy: authorizationAccessPolicyClient, + AuthorizationConfirmConsentCode: authorizationConfirmConsentCodeClient, + AuthorizationLoginLinks: authorizationLoginLinksClient, + AuthorizationProvider: authorizationProviderClient, + AuthorizationServer: authorizationServerClient, + Authorizations: authorizationsClient, + Backend: backendClient, + BackendReconnect: backendReconnectClient, + Cache: cacheClient, + Certificate: certificateClient, + ContentType: contentTypeClient, + ContentTypeContentItem: contentTypeContentItemClient, + DelegationSettings: delegationSettingsClient, + DeletedService: deletedServiceClient, + Diagnostic: diagnosticClient, + DocumentationResource: documentationResourceClient, + EmailTemplate: emailTemplateClient, + EmailTemplates: emailTemplatesClient, + Gateway: gatewayClient, + GatewayApi: gatewayApiClient, + GatewayCertificateAuthority: gatewayCertificateAuthorityClient, + GatewayGenerateToken: gatewayGenerateTokenClient, + GatewayHostnameConfiguration: gatewayHostnameConfigurationClient, + GatewayListKeys: gatewayListKeysClient, + GatewayRegenerateKey: gatewayRegenerateKeyClient, + GraphQLApiResolver: graphQLApiResolverClient, + GraphQLApiResolverPolicy: graphQLApiResolverPolicyClient, + Group: groupClient, + GroupUser: groupUserClient, + IdentityProvider: identityProviderClient, + Issue: issueClient, + Logger: loggerClient, + NamedValue: namedValueClient, + NetworkStatus: networkStatusClient, + Notification: notificationClient, + NotificationRecipientEmail: notificationRecipientEmailClient, + NotificationRecipientUser: notificationRecipientUserClient, + OpenidConnectProvider: openidConnectProviderClient, + OutboundNetworkDependenciesEndpoints: outboundNetworkDependenciesEndpointsClient, + PerformConnectivityCheck: performConnectivityCheckClient, + Policy: policyClient, + PolicyDescription: policyDescriptionClient, + PolicyFragment: policyFragmentClient, + PortalConfig: portalConfigClient, + PortalRevision: portalRevisionClient, + PortalSettings: portalSettingsClient, + PrivateEndpointConnections: privateEndpointConnectionsClient, + Product: productClient, + ProductApi: productApiClient, + ProductGroup: productGroupClient, + ProductPolicy: productPolicyClient, + ProductSubscription: productSubscriptionClient, + ProductTag: productTagClient, + ProductWiki: productWikiClient, + ProductsByTag: productsByTagClient, + QuotaByCounterKeys: quotaByCounterKeysClient, + QuotaByPeriodKeys: quotaByPeriodKeysClient, + Region: regionClient, + Reports: reportsClient, + Schema: schemaClient, + SignInSettings: signInSettingsClient, + SignUpSettings: signUpSettingsClient, + Skus: skusClient, + Subscription: subscriptionClient, + Tag: tagClient, + TagResource: tagResourceClient, + TenantAccess: tenantAccessClient, + TenantAccessGit: tenantAccessGitClient, + TenantConfiguration: tenantConfigurationClient, + TenantConfigurationSyncState: tenantConfigurationSyncStateClient, + TenantSettings: tenantSettingsClient, + User: userClient, + UserConfirmationPasswordSend: userConfirmationPasswordSendClient, + UserGroup: userGroupClient, + UserIdentity: userIdentityClient, + UserSubscription: userSubscriptionClient, + UserToken: userTokenClient, + Users: usersClient, + }, nil } diff --git a/resource-manager/apimanagement/2022-08-01/contenttype/client.go b/resource-manager/apimanagement/2022-08-01/contenttype/client.go index ad798035bab..b5de661e117 100644 --- a/resource-manager/apimanagement/2022-08-01/contenttype/client.go +++ b/resource-manager/apimanagement/2022-08-01/contenttype/client.go @@ -1,18 +1,26 @@ package contenttype -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 ContentTypeClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewContentTypeClientWithBaseURI(endpoint string) ContentTypeClient { - return ContentTypeClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewContentTypeClientWithBaseURI(api environments.Api) (*ContentTypeClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "contenttype", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ContentTypeClient: %+v", err) } + + return &ContentTypeClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2022-08-01/contenttype/method_createorupdate.go b/resource-manager/apimanagement/2022-08-01/contenttype/method_createorupdate.go new file mode 100644 index 00000000000..777eb60bb34 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/contenttype/method_createorupdate.go @@ -0,0 +1,85 @@ +package contenttype + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ContentTypeContract +} + +type CreateOrUpdateOperationOptions struct { + IfMatch *string +} + +func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { + return CreateOrUpdateOperationOptions{} +} + +func (o CreateOrUpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o CreateOrUpdateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o CreateOrUpdateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// CreateOrUpdate ... +func (c ContentTypeClient) CreateOrUpdate(ctx context.Context, id ContentTypeId, input ContentTypeContract, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + OptionsObject: options, + } + + 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/apimanagement/2022-08-01/contenttype/method_createorupdate_autorest.go b/resource-manager/apimanagement/2022-08-01/contenttype/method_createorupdate_autorest.go deleted file mode 100644 index 7e7af790b98..00000000000 --- a/resource-manager/apimanagement/2022-08-01/contenttype/method_createorupdate_autorest.go +++ /dev/null @@ -1,98 +0,0 @@ -package contenttype - -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 *ContentTypeContract -} - -type CreateOrUpdateOperationOptions struct { - IfMatch *string -} - -func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { - return CreateOrUpdateOperationOptions{} -} - -func (o CreateOrUpdateOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o CreateOrUpdateOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// CreateOrUpdate ... -func (c ContentTypeClient) CreateOrUpdate(ctx context.Context, id ContentTypeId, input ContentTypeContract, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdate(ctx, id, input, options) - if err != nil { - err = autorest.NewErrorWithError(err, "contenttype.ContentTypeClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "contenttype.ContentTypeClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCreateOrUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "contenttype.ContentTypeClient", "CreateOrUpdate", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCreateOrUpdate prepares the CreateOrUpdate request. -func (c ContentTypeClient) preparerForCreateOrUpdate(ctx context.Context, id ContentTypeId, input ContentTypeContract, options CreateOrUpdateOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - 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 ContentTypeClient) responderForCreateOrUpdate(resp *http.Response) (result CreateOrUpdateOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2022-08-01/contenttype/method_delete.go b/resource-manager/apimanagement/2022-08-01/contenttype/method_delete.go new file mode 100644 index 00000000000..5a87b291973 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/contenttype/method_delete.go @@ -0,0 +1,76 @@ +package contenttype + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +type DeleteOperationOptions struct { + IfMatch *string +} + +func DefaultDeleteOperationOptions() DeleteOperationOptions { + return DeleteOperationOptions{} +} + +func (o DeleteOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o DeleteOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o DeleteOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// Delete ... +func (c ContentTypeClient) Delete(ctx context.Context, id ContentTypeId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2022-08-01/contenttype/method_delete_autorest.go b/resource-manager/apimanagement/2022-08-01/contenttype/method_delete_autorest.go deleted file mode 100644 index c67c198a0f2..00000000000 --- a/resource-manager/apimanagement/2022-08-01/contenttype/method_delete_autorest.go +++ /dev/null @@ -1,95 +0,0 @@ -package contenttype - -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 DeleteOperationResponse struct { - HttpResponse *http.Response -} - -type DeleteOperationOptions struct { - IfMatch *string -} - -func DefaultDeleteOperationOptions() DeleteOperationOptions { - return DeleteOperationOptions{} -} - -func (o DeleteOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o DeleteOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// Delete ... -func (c ContentTypeClient) Delete(ctx context.Context, id ContentTypeId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { - req, err := c.preparerForDelete(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "contenttype.ContentTypeClient", "Delete", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "contenttype.ContentTypeClient", "Delete", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForDelete(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "contenttype.ContentTypeClient", "Delete", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForDelete prepares the Delete request. -func (c ContentTypeClient) preparerForDelete(ctx context.Context, id ContentTypeId, options DeleteOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForDelete handles the response to the Delete request. The method always -// closes the http.Response Body. -func (c ContentTypeClient) responderForDelete(resp *http.Response) (result DeleteOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2022-08-01/contenttype/method_get.go b/resource-manager/apimanagement/2022-08-01/contenttype/method_get.go new file mode 100644 index 00000000000..45f141d65b2 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/contenttype/method_get.go @@ -0,0 +1,51 @@ +package contenttype + +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 *ContentTypeContract +} + +// Get ... +func (c ContentTypeClient) Get(ctx context.Context, id ContentTypeId) (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/apimanagement/2022-08-01/contenttype/method_get_autorest.go b/resource-manager/apimanagement/2022-08-01/contenttype/method_get_autorest.go deleted file mode 100644 index ffff3ebdfb5..00000000000 --- a/resource-manager/apimanagement/2022-08-01/contenttype/method_get_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package contenttype - -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 *ContentTypeContract -} - -// Get ... -func (c ContentTypeClient) Get(ctx context.Context, id ContentTypeId) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "contenttype.ContentTypeClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "contenttype.ContentTypeClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "contenttype.ContentTypeClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c ContentTypeClient) preparerForGet(ctx context.Context, id ContentTypeId) (*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 ContentTypeClient) 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/apimanagement/2022-08-01/contenttype/method_listbyservice.go b/resource-manager/apimanagement/2022-08-01/contenttype/method_listbyservice.go new file mode 100644 index 00000000000..3a6d95c44ce --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/contenttype/method_listbyservice.go @@ -0,0 +1,89 @@ +package contenttype + +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 ListByServiceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ContentTypeContract +} + +type ListByServiceCompleteResult struct { + Items []ContentTypeContract +} + +// ListByService ... +func (c ContentTypeClient) ListByService(ctx context.Context, id ServiceId) (result ListByServiceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/contentTypes", 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 *[]ContentTypeContract `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByServiceComplete retrieves all the results into a single object +func (c ContentTypeClient) ListByServiceComplete(ctx context.Context, id ServiceId) (ListByServiceCompleteResult, error) { + return c.ListByServiceCompleteMatchingPredicate(ctx, id, ContentTypeContractOperationPredicate{}) +} + +// ListByServiceCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ContentTypeClient) ListByServiceCompleteMatchingPredicate(ctx context.Context, id ServiceId, predicate ContentTypeContractOperationPredicate) (result ListByServiceCompleteResult, err error) { + items := make([]ContentTypeContract, 0) + + resp, err := c.ListByService(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 = ListByServiceCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/apimanagement/2022-08-01/contenttype/method_listbyservice_autorest.go b/resource-manager/apimanagement/2022-08-01/contenttype/method_listbyservice_autorest.go deleted file mode 100644 index 80dfbe9830a..00000000000 --- a/resource-manager/apimanagement/2022-08-01/contenttype/method_listbyservice_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package contenttype - -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 ListByServiceOperationResponse struct { - HttpResponse *http.Response - Model *[]ContentTypeContract - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListByServiceOperationResponse, error) -} - -type ListByServiceCompleteResult struct { - Items []ContentTypeContract -} - -func (r ListByServiceOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListByServiceOperationResponse) LoadMore(ctx context.Context) (resp ListByServiceOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListByService ... -func (c ContentTypeClient) ListByService(ctx context.Context, id ServiceId) (resp ListByServiceOperationResponse, err error) { - req, err := c.preparerForListByService(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "contenttype.ContentTypeClient", "ListByService", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "contenttype.ContentTypeClient", "ListByService", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListByService(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "contenttype.ContentTypeClient", "ListByService", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListByService prepares the ListByService request. -func (c ContentTypeClient) preparerForListByService(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(fmt.Sprintf("%s/contentTypes", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListByServiceWithNextLink prepares the ListByService request with the given nextLink token. -func (c ContentTypeClient) preparerForListByServiceWithNextLink(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)) -} - -// responderForListByService handles the response to the ListByService request. The method always -// closes the http.Response Body. -func (c ContentTypeClient) responderForListByService(resp *http.Response) (result ListByServiceOperationResponse, err error) { - type page struct { - Values []ContentTypeContract `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 ListByServiceOperationResponse, err error) { - req, err := c.preparerForListByServiceWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "contenttype.ContentTypeClient", "ListByService", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "contenttype.ContentTypeClient", "ListByService", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByService(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "contenttype.ContentTypeClient", "ListByService", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListByServiceComplete retrieves all of the results into a single object -func (c ContentTypeClient) ListByServiceComplete(ctx context.Context, id ServiceId) (ListByServiceCompleteResult, error) { - return c.ListByServiceCompleteMatchingPredicate(ctx, id, ContentTypeContractOperationPredicate{}) -} - -// ListByServiceCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c ContentTypeClient) ListByServiceCompleteMatchingPredicate(ctx context.Context, id ServiceId, predicate ContentTypeContractOperationPredicate) (resp ListByServiceCompleteResult, err error) { - items := make([]ContentTypeContract, 0) - - page, err := c.ListByService(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 := ListByServiceCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/apimanagement/2022-08-01/contenttypecontentitem/client.go b/resource-manager/apimanagement/2022-08-01/contenttypecontentitem/client.go index 89ca6821ddb..c927b66bbf1 100644 --- a/resource-manager/apimanagement/2022-08-01/contenttypecontentitem/client.go +++ b/resource-manager/apimanagement/2022-08-01/contenttypecontentitem/client.go @@ -1,18 +1,26 @@ package contenttypecontentitem -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 ContentTypeContentItemClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewContentTypeContentItemClientWithBaseURI(endpoint string) ContentTypeContentItemClient { - return ContentTypeContentItemClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewContentTypeContentItemClientWithBaseURI(api environments.Api) (*ContentTypeContentItemClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "contenttypecontentitem", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ContentTypeContentItemClient: %+v", err) } + + return &ContentTypeContentItemClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2022-08-01/contenttypecontentitem/method_contentitemcreateorupdate.go b/resource-manager/apimanagement/2022-08-01/contenttypecontentitem/method_contentitemcreateorupdate.go new file mode 100644 index 00000000000..f64c33e51f2 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/contenttypecontentitem/method_contentitemcreateorupdate.go @@ -0,0 +1,85 @@ +package contenttypecontentitem + +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 ContentItemCreateOrUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ContentItemContract +} + +type ContentItemCreateOrUpdateOperationOptions struct { + IfMatch *string +} + +func DefaultContentItemCreateOrUpdateOperationOptions() ContentItemCreateOrUpdateOperationOptions { + return ContentItemCreateOrUpdateOperationOptions{} +} + +func (o ContentItemCreateOrUpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o ContentItemCreateOrUpdateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ContentItemCreateOrUpdateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// ContentItemCreateOrUpdate ... +func (c ContentTypeContentItemClient) ContentItemCreateOrUpdate(ctx context.Context, id ContentItemId, input ContentItemContract, options ContentItemCreateOrUpdateOperationOptions) (result ContentItemCreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + OptionsObject: options, + } + + 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/apimanagement/2022-08-01/contenttypecontentitem/method_contentitemcreateorupdate_autorest.go b/resource-manager/apimanagement/2022-08-01/contenttypecontentitem/method_contentitemcreateorupdate_autorest.go deleted file mode 100644 index 74712be0162..00000000000 --- a/resource-manager/apimanagement/2022-08-01/contenttypecontentitem/method_contentitemcreateorupdate_autorest.go +++ /dev/null @@ -1,98 +0,0 @@ -package contenttypecontentitem - -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 ContentItemCreateOrUpdateOperationResponse struct { - HttpResponse *http.Response - Model *ContentItemContract -} - -type ContentItemCreateOrUpdateOperationOptions struct { - IfMatch *string -} - -func DefaultContentItemCreateOrUpdateOperationOptions() ContentItemCreateOrUpdateOperationOptions { - return ContentItemCreateOrUpdateOperationOptions{} -} - -func (o ContentItemCreateOrUpdateOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o ContentItemCreateOrUpdateOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// ContentItemCreateOrUpdate ... -func (c ContentTypeContentItemClient) ContentItemCreateOrUpdate(ctx context.Context, id ContentItemId, input ContentItemContract, options ContentItemCreateOrUpdateOperationOptions) (result ContentItemCreateOrUpdateOperationResponse, err error) { - req, err := c.preparerForContentItemCreateOrUpdate(ctx, id, input, options) - if err != nil { - err = autorest.NewErrorWithError(err, "contenttypecontentitem.ContentTypeContentItemClient", "ContentItemCreateOrUpdate", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "contenttypecontentitem.ContentTypeContentItemClient", "ContentItemCreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForContentItemCreateOrUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "contenttypecontentitem.ContentTypeContentItemClient", "ContentItemCreateOrUpdate", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForContentItemCreateOrUpdate prepares the ContentItemCreateOrUpdate request. -func (c ContentTypeContentItemClient) preparerForContentItemCreateOrUpdate(ctx context.Context, id ContentItemId, input ContentItemContract, options ContentItemCreateOrUpdateOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForContentItemCreateOrUpdate handles the response to the ContentItemCreateOrUpdate request. The method always -// closes the http.Response Body. -func (c ContentTypeContentItemClient) responderForContentItemCreateOrUpdate(resp *http.Response) (result ContentItemCreateOrUpdateOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2022-08-01/contenttypecontentitem/method_contentitemdelete.go b/resource-manager/apimanagement/2022-08-01/contenttypecontentitem/method_contentitemdelete.go new file mode 100644 index 00000000000..5b8b348a02c --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/contenttypecontentitem/method_contentitemdelete.go @@ -0,0 +1,76 @@ +package contenttypecontentitem + +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 ContentItemDeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +type ContentItemDeleteOperationOptions struct { + IfMatch *string +} + +func DefaultContentItemDeleteOperationOptions() ContentItemDeleteOperationOptions { + return ContentItemDeleteOperationOptions{} +} + +func (o ContentItemDeleteOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o ContentItemDeleteOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ContentItemDeleteOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// ContentItemDelete ... +func (c ContentTypeContentItemClient) ContentItemDelete(ctx context.Context, id ContentItemId, options ContentItemDeleteOperationOptions) (result ContentItemDeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2022-08-01/contenttypecontentitem/method_contentitemdelete_autorest.go b/resource-manager/apimanagement/2022-08-01/contenttypecontentitem/method_contentitemdelete_autorest.go deleted file mode 100644 index 701903e5664..00000000000 --- a/resource-manager/apimanagement/2022-08-01/contenttypecontentitem/method_contentitemdelete_autorest.go +++ /dev/null @@ -1,95 +0,0 @@ -package contenttypecontentitem - -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 ContentItemDeleteOperationResponse struct { - HttpResponse *http.Response -} - -type ContentItemDeleteOperationOptions struct { - IfMatch *string -} - -func DefaultContentItemDeleteOperationOptions() ContentItemDeleteOperationOptions { - return ContentItemDeleteOperationOptions{} -} - -func (o ContentItemDeleteOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o ContentItemDeleteOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// ContentItemDelete ... -func (c ContentTypeContentItemClient) ContentItemDelete(ctx context.Context, id ContentItemId, options ContentItemDeleteOperationOptions) (result ContentItemDeleteOperationResponse, err error) { - req, err := c.preparerForContentItemDelete(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "contenttypecontentitem.ContentTypeContentItemClient", "ContentItemDelete", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "contenttypecontentitem.ContentTypeContentItemClient", "ContentItemDelete", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForContentItemDelete(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "contenttypecontentitem.ContentTypeContentItemClient", "ContentItemDelete", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForContentItemDelete prepares the ContentItemDelete request. -func (c ContentTypeContentItemClient) preparerForContentItemDelete(ctx context.Context, id ContentItemId, options ContentItemDeleteOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForContentItemDelete handles the response to the ContentItemDelete request. The method always -// closes the http.Response Body. -func (c ContentTypeContentItemClient) responderForContentItemDelete(resp *http.Response) (result ContentItemDeleteOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2022-08-01/contenttypecontentitem/method_contentitemget.go b/resource-manager/apimanagement/2022-08-01/contenttypecontentitem/method_contentitemget.go new file mode 100644 index 00000000000..8ea76ef555d --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/contenttypecontentitem/method_contentitemget.go @@ -0,0 +1,51 @@ +package contenttypecontentitem + +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 ContentItemGetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ContentItemContract +} + +// ContentItemGet ... +func (c ContentTypeContentItemClient) ContentItemGet(ctx context.Context, id ContentItemId) (result ContentItemGetOperationResponse, 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/apimanagement/2022-08-01/contenttypecontentitem/method_contentitemget_autorest.go b/resource-manager/apimanagement/2022-08-01/contenttypecontentitem/method_contentitemget_autorest.go deleted file mode 100644 index efbe49d07d9..00000000000 --- a/resource-manager/apimanagement/2022-08-01/contenttypecontentitem/method_contentitemget_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package contenttypecontentitem - -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 ContentItemGetOperationResponse struct { - HttpResponse *http.Response - Model *ContentItemContract -} - -// ContentItemGet ... -func (c ContentTypeContentItemClient) ContentItemGet(ctx context.Context, id ContentItemId) (result ContentItemGetOperationResponse, err error) { - req, err := c.preparerForContentItemGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "contenttypecontentitem.ContentTypeContentItemClient", "ContentItemGet", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "contenttypecontentitem.ContentTypeContentItemClient", "ContentItemGet", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForContentItemGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "contenttypecontentitem.ContentTypeContentItemClient", "ContentItemGet", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForContentItemGet prepares the ContentItemGet request. -func (c ContentTypeContentItemClient) preparerForContentItemGet(ctx context.Context, id ContentItemId) (*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)) -} - -// responderForContentItemGet handles the response to the ContentItemGet request. The method always -// closes the http.Response Body. -func (c ContentTypeContentItemClient) responderForContentItemGet(resp *http.Response) (result ContentItemGetOperationResponse, 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/apimanagement/2022-08-01/contenttypecontentitem/method_contentitemgetentitytag.go b/resource-manager/apimanagement/2022-08-01/contenttypecontentitem/method_contentitemgetentitytag.go new file mode 100644 index 00000000000..072a373e255 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/contenttypecontentitem/method_contentitemgetentitytag.go @@ -0,0 +1,46 @@ +package contenttypecontentitem + +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 ContentItemGetEntityTagOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// ContentItemGetEntityTag ... +func (c ContentTypeContentItemClient) ContentItemGetEntityTag(ctx context.Context, id ContentItemId) (result ContentItemGetEntityTagOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodHead, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2022-08-01/contenttypecontentitem/method_contentitemgetentitytag_autorest.go b/resource-manager/apimanagement/2022-08-01/contenttypecontentitem/method_contentitemgetentitytag_autorest.go deleted file mode 100644 index b6ba07420c2..00000000000 --- a/resource-manager/apimanagement/2022-08-01/contenttypecontentitem/method_contentitemgetentitytag_autorest.go +++ /dev/null @@ -1,66 +0,0 @@ -package contenttypecontentitem - -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 ContentItemGetEntityTagOperationResponse struct { - HttpResponse *http.Response -} - -// ContentItemGetEntityTag ... -func (c ContentTypeContentItemClient) ContentItemGetEntityTag(ctx context.Context, id ContentItemId) (result ContentItemGetEntityTagOperationResponse, err error) { - req, err := c.preparerForContentItemGetEntityTag(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "contenttypecontentitem.ContentTypeContentItemClient", "ContentItemGetEntityTag", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "contenttypecontentitem.ContentTypeContentItemClient", "ContentItemGetEntityTag", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForContentItemGetEntityTag(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "contenttypecontentitem.ContentTypeContentItemClient", "ContentItemGetEntityTag", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForContentItemGetEntityTag prepares the ContentItemGetEntityTag request. -func (c ContentTypeContentItemClient) preparerForContentItemGetEntityTag(ctx context.Context, id ContentItemId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsHead(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForContentItemGetEntityTag handles the response to the ContentItemGetEntityTag request. The method always -// closes the http.Response Body. -func (c ContentTypeContentItemClient) responderForContentItemGetEntityTag(resp *http.Response) (result ContentItemGetEntityTagOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2022-08-01/contenttypecontentitem/method_contentitemlistbyservice.go b/resource-manager/apimanagement/2022-08-01/contenttypecontentitem/method_contentitemlistbyservice.go new file mode 100644 index 00000000000..8e83525cd40 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/contenttypecontentitem/method_contentitemlistbyservice.go @@ -0,0 +1,89 @@ +package contenttypecontentitem + +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 ContentItemListByServiceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ContentItemContract +} + +type ContentItemListByServiceCompleteResult struct { + Items []ContentItemContract +} + +// ContentItemListByService ... +func (c ContentTypeContentItemClient) ContentItemListByService(ctx context.Context, id ContentTypeId) (result ContentItemListByServiceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/contentItems", 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 *[]ContentItemContract `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ContentItemListByServiceComplete retrieves all the results into a single object +func (c ContentTypeContentItemClient) ContentItemListByServiceComplete(ctx context.Context, id ContentTypeId) (ContentItemListByServiceCompleteResult, error) { + return c.ContentItemListByServiceCompleteMatchingPredicate(ctx, id, ContentItemContractOperationPredicate{}) +} + +// ContentItemListByServiceCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ContentTypeContentItemClient) ContentItemListByServiceCompleteMatchingPredicate(ctx context.Context, id ContentTypeId, predicate ContentItemContractOperationPredicate) (result ContentItemListByServiceCompleteResult, err error) { + items := make([]ContentItemContract, 0) + + resp, err := c.ContentItemListByService(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 = ContentItemListByServiceCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/apimanagement/2022-08-01/contenttypecontentitem/method_contentitemlistbyservice_autorest.go b/resource-manager/apimanagement/2022-08-01/contenttypecontentitem/method_contentitemlistbyservice_autorest.go deleted file mode 100644 index 4a4be76da22..00000000000 --- a/resource-manager/apimanagement/2022-08-01/contenttypecontentitem/method_contentitemlistbyservice_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package contenttypecontentitem - -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 ContentItemListByServiceOperationResponse struct { - HttpResponse *http.Response - Model *[]ContentItemContract - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ContentItemListByServiceOperationResponse, error) -} - -type ContentItemListByServiceCompleteResult struct { - Items []ContentItemContract -} - -func (r ContentItemListByServiceOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ContentItemListByServiceOperationResponse) LoadMore(ctx context.Context) (resp ContentItemListByServiceOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ContentItemListByService ... -func (c ContentTypeContentItemClient) ContentItemListByService(ctx context.Context, id ContentTypeId) (resp ContentItemListByServiceOperationResponse, err error) { - req, err := c.preparerForContentItemListByService(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "contenttypecontentitem.ContentTypeContentItemClient", "ContentItemListByService", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "contenttypecontentitem.ContentTypeContentItemClient", "ContentItemListByService", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForContentItemListByService(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "contenttypecontentitem.ContentTypeContentItemClient", "ContentItemListByService", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForContentItemListByService prepares the ContentItemListByService request. -func (c ContentTypeContentItemClient) preparerForContentItemListByService(ctx context.Context, id ContentTypeId) (*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/contentItems", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForContentItemListByServiceWithNextLink prepares the ContentItemListByService request with the given nextLink token. -func (c ContentTypeContentItemClient) preparerForContentItemListByServiceWithNextLink(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)) -} - -// responderForContentItemListByService handles the response to the ContentItemListByService request. The method always -// closes the http.Response Body. -func (c ContentTypeContentItemClient) responderForContentItemListByService(resp *http.Response) (result ContentItemListByServiceOperationResponse, err error) { - type page struct { - Values []ContentItemContract `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 ContentItemListByServiceOperationResponse, err error) { - req, err := c.preparerForContentItemListByServiceWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "contenttypecontentitem.ContentTypeContentItemClient", "ContentItemListByService", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "contenttypecontentitem.ContentTypeContentItemClient", "ContentItemListByService", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForContentItemListByService(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "contenttypecontentitem.ContentTypeContentItemClient", "ContentItemListByService", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ContentItemListByServiceComplete retrieves all of the results into a single object -func (c ContentTypeContentItemClient) ContentItemListByServiceComplete(ctx context.Context, id ContentTypeId) (ContentItemListByServiceCompleteResult, error) { - return c.ContentItemListByServiceCompleteMatchingPredicate(ctx, id, ContentItemContractOperationPredicate{}) -} - -// ContentItemListByServiceCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c ContentTypeContentItemClient) ContentItemListByServiceCompleteMatchingPredicate(ctx context.Context, id ContentTypeId, predicate ContentItemContractOperationPredicate) (resp ContentItemListByServiceCompleteResult, err error) { - items := make([]ContentItemContract, 0) - - page, err := c.ContentItemListByService(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 := ContentItemListByServiceCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/apimanagement/2022-08-01/delegationsettings/client.go b/resource-manager/apimanagement/2022-08-01/delegationsettings/client.go index 72c97b7519c..7feac89a16f 100644 --- a/resource-manager/apimanagement/2022-08-01/delegationsettings/client.go +++ b/resource-manager/apimanagement/2022-08-01/delegationsettings/client.go @@ -1,18 +1,26 @@ package delegationsettings -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 DelegationSettingsClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewDelegationSettingsClientWithBaseURI(endpoint string) DelegationSettingsClient { - return DelegationSettingsClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewDelegationSettingsClientWithBaseURI(api environments.Api) (*DelegationSettingsClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "delegationsettings", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating DelegationSettingsClient: %+v", err) } + + return &DelegationSettingsClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2022-08-01/delegationsettings/method_createorupdate.go b/resource-manager/apimanagement/2022-08-01/delegationsettings/method_createorupdate.go new file mode 100644 index 00000000000..798382faf25 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/delegationsettings/method_createorupdate.go @@ -0,0 +1,84 @@ +package delegationsettings + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PortalDelegationSettings +} + +type CreateOrUpdateOperationOptions struct { + IfMatch *string +} + +func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { + return CreateOrUpdateOperationOptions{} +} + +func (o CreateOrUpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o CreateOrUpdateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o CreateOrUpdateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// CreateOrUpdate ... +func (c DelegationSettingsClient) CreateOrUpdate(ctx context.Context, id ServiceId, input PortalDelegationSettings, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/portalsettings/delegation", id.ID()), + OptionsObject: options, + } + + 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/apimanagement/2022-08-01/delegationsettings/method_createorupdate_autorest.go b/resource-manager/apimanagement/2022-08-01/delegationsettings/method_createorupdate_autorest.go deleted file mode 100644 index 51373a1a8ce..00000000000 --- a/resource-manager/apimanagement/2022-08-01/delegationsettings/method_createorupdate_autorest.go +++ /dev/null @@ -1,99 +0,0 @@ -package delegationsettings - -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 CreateOrUpdateOperationResponse struct { - HttpResponse *http.Response - Model *PortalDelegationSettings -} - -type CreateOrUpdateOperationOptions struct { - IfMatch *string -} - -func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { - return CreateOrUpdateOperationOptions{} -} - -func (o CreateOrUpdateOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o CreateOrUpdateOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// CreateOrUpdate ... -func (c DelegationSettingsClient) CreateOrUpdate(ctx context.Context, id ServiceId, input PortalDelegationSettings, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdate(ctx, id, input, options) - if err != nil { - err = autorest.NewErrorWithError(err, "delegationsettings.DelegationSettingsClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "delegationsettings.DelegationSettingsClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCreateOrUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "delegationsettings.DelegationSettingsClient", "CreateOrUpdate", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCreateOrUpdate prepares the CreateOrUpdate request. -func (c DelegationSettingsClient) preparerForCreateOrUpdate(ctx context.Context, id ServiceId, input PortalDelegationSettings, options CreateOrUpdateOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/portalsettings/delegation", 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 DelegationSettingsClient) 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/apimanagement/2022-08-01/delegationsettings/method_get.go b/resource-manager/apimanagement/2022-08-01/delegationsettings/method_get.go new file mode 100644 index 00000000000..7e0f9378ef1 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/delegationsettings/method_get.go @@ -0,0 +1,52 @@ +package delegationsettings + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PortalDelegationSettings +} + +// Get ... +func (c DelegationSettingsClient) 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: fmt.Sprintf("%s/portalsettings/delegation", 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/apimanagement/2022-08-01/delegationsettings/method_get_autorest.go b/resource-manager/apimanagement/2022-08-01/delegationsettings/method_get_autorest.go deleted file mode 100644 index e2553b0753d..00000000000 --- a/resource-manager/apimanagement/2022-08-01/delegationsettings/method_get_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package delegationsettings - -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 GetOperationResponse struct { - HttpResponse *http.Response - Model *PortalDelegationSettings -} - -// Get ... -func (c DelegationSettingsClient) Get(ctx context.Context, id ServiceId) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "delegationsettings.DelegationSettingsClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "delegationsettings.DelegationSettingsClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "delegationsettings.DelegationSettingsClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c DelegationSettingsClient) 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(fmt.Sprintf("%s/portalsettings/delegation", 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 DelegationSettingsClient) 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/apimanagement/2022-08-01/delegationsettings/method_getentitytag.go b/resource-manager/apimanagement/2022-08-01/delegationsettings/method_getentitytag.go new file mode 100644 index 00000000000..6d1fc5745c7 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/delegationsettings/method_getentitytag.go @@ -0,0 +1,47 @@ +package delegationsettings + +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 GetEntityTagOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// GetEntityTag ... +func (c DelegationSettingsClient) GetEntityTag(ctx context.Context, id ServiceId) (result GetEntityTagOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodHead, + Path: fmt.Sprintf("%s/portalsettings/delegation", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2022-08-01/delegationsettings/method_getentitytag_autorest.go b/resource-manager/apimanagement/2022-08-01/delegationsettings/method_getentitytag_autorest.go deleted file mode 100644 index 7a92ab1b000..00000000000 --- a/resource-manager/apimanagement/2022-08-01/delegationsettings/method_getentitytag_autorest.go +++ /dev/null @@ -1,67 +0,0 @@ -package delegationsettings - -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 GetEntityTagOperationResponse struct { - HttpResponse *http.Response -} - -// GetEntityTag ... -func (c DelegationSettingsClient) GetEntityTag(ctx context.Context, id ServiceId) (result GetEntityTagOperationResponse, err error) { - req, err := c.preparerForGetEntityTag(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "delegationsettings.DelegationSettingsClient", "GetEntityTag", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "delegationsettings.DelegationSettingsClient", "GetEntityTag", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetEntityTag(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "delegationsettings.DelegationSettingsClient", "GetEntityTag", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetEntityTag prepares the GetEntityTag request. -func (c DelegationSettingsClient) preparerForGetEntityTag(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.AsHead(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/portalsettings/delegation", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetEntityTag handles the response to the GetEntityTag request. The method always -// closes the http.Response Body. -func (c DelegationSettingsClient) responderForGetEntityTag(resp *http.Response) (result GetEntityTagOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2022-08-01/delegationsettings/method_listsecrets.go b/resource-manager/apimanagement/2022-08-01/delegationsettings/method_listsecrets.go new file mode 100644 index 00000000000..baf7a240e3b --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/delegationsettings/method_listsecrets.go @@ -0,0 +1,52 @@ +package delegationsettings + +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 ListSecretsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PortalSettingValidationKeyContract +} + +// ListSecrets ... +func (c DelegationSettingsClient) ListSecrets(ctx context.Context, id ServiceId) (result ListSecretsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/portalsettings/delegation/listSecrets", 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/apimanagement/2022-08-01/delegationsettings/method_listsecrets_autorest.go b/resource-manager/apimanagement/2022-08-01/delegationsettings/method_listsecrets_autorest.go deleted file mode 100644 index 279c998cc3b..00000000000 --- a/resource-manager/apimanagement/2022-08-01/delegationsettings/method_listsecrets_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package delegationsettings - -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 ListSecretsOperationResponse struct { - HttpResponse *http.Response - Model *PortalSettingValidationKeyContract -} - -// ListSecrets ... -func (c DelegationSettingsClient) ListSecrets(ctx context.Context, id ServiceId) (result ListSecretsOperationResponse, err error) { - req, err := c.preparerForListSecrets(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "delegationsettings.DelegationSettingsClient", "ListSecrets", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "delegationsettings.DelegationSettingsClient", "ListSecrets", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListSecrets(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "delegationsettings.DelegationSettingsClient", "ListSecrets", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForListSecrets prepares the ListSecrets request. -func (c DelegationSettingsClient) preparerForListSecrets(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.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/portalsettings/delegation/listSecrets", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListSecrets handles the response to the ListSecrets request. The method always -// closes the http.Response Body. -func (c DelegationSettingsClient) responderForListSecrets(resp *http.Response) (result ListSecretsOperationResponse, 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/apimanagement/2022-08-01/delegationsettings/method_update.go b/resource-manager/apimanagement/2022-08-01/delegationsettings/method_update.go new file mode 100644 index 00000000000..924b296b5fa --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/delegationsettings/method_update.go @@ -0,0 +1,79 @@ +package delegationsettings + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +type UpdateOperationOptions struct { + IfMatch *string +} + +func DefaultUpdateOperationOptions() UpdateOperationOptions { + return UpdateOperationOptions{} +} + +func (o UpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o UpdateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o UpdateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// Update ... +func (c DelegationSettingsClient) Update(ctx context.Context, id ServiceId, input PortalDelegationSettings, options UpdateOperationOptions) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: http.MethodPatch, + Path: fmt.Sprintf("%s/portalsettings/delegation", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2022-08-01/delegationsettings/method_update_autorest.go b/resource-manager/apimanagement/2022-08-01/delegationsettings/method_update_autorest.go deleted file mode 100644 index c768645478b..00000000000 --- a/resource-manager/apimanagement/2022-08-01/delegationsettings/method_update_autorest.go +++ /dev/null @@ -1,97 +0,0 @@ -package delegationsettings - -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 UpdateOperationResponse struct { - HttpResponse *http.Response -} - -type UpdateOperationOptions struct { - IfMatch *string -} - -func DefaultUpdateOperationOptions() UpdateOperationOptions { - return UpdateOperationOptions{} -} - -func (o UpdateOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o UpdateOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// Update ... -func (c DelegationSettingsClient) Update(ctx context.Context, id ServiceId, input PortalDelegationSettings, options UpdateOperationOptions) (result UpdateOperationResponse, err error) { - req, err := c.preparerForUpdate(ctx, id, input, options) - if err != nil { - err = autorest.NewErrorWithError(err, "delegationsettings.DelegationSettingsClient", "Update", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "delegationsettings.DelegationSettingsClient", "Update", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "delegationsettings.DelegationSettingsClient", "Update", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForUpdate prepares the Update request. -func (c DelegationSettingsClient) preparerForUpdate(ctx context.Context, id ServiceId, input PortalDelegationSettings, options UpdateOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPatch(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/portalsettings/delegation", 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 DelegationSettingsClient) responderForUpdate(resp *http.Response) (result UpdateOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2022-08-01/deletedservice/client.go b/resource-manager/apimanagement/2022-08-01/deletedservice/client.go index 481a31f9a8a..95e9b5a5088 100644 --- a/resource-manager/apimanagement/2022-08-01/deletedservice/client.go +++ b/resource-manager/apimanagement/2022-08-01/deletedservice/client.go @@ -1,18 +1,26 @@ package deletedservice -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 DeletedServiceClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewDeletedServiceClientWithBaseURI(endpoint string) DeletedServiceClient { - return DeletedServiceClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewDeletedServiceClientWithBaseURI(api environments.Api) (*DeletedServiceClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "deletedservice", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating DeletedServiceClient: %+v", err) } + + return &DeletedServiceClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2022-08-01/deletedservice/method_getbyname.go b/resource-manager/apimanagement/2022-08-01/deletedservice/method_getbyname.go new file mode 100644 index 00000000000..f6404fd9b48 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/deletedservice/method_getbyname.go @@ -0,0 +1,51 @@ +package deletedservice + +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 GetByNameOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DeletedServiceContract +} + +// GetByName ... +func (c DeletedServiceClient) GetByName(ctx context.Context, id DeletedServiceId) (result GetByNameOperationResponse, 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/apimanagement/2022-08-01/deletedservice/method_getbyname_autorest.go b/resource-manager/apimanagement/2022-08-01/deletedservice/method_getbyname_autorest.go deleted file mode 100644 index f80305a22eb..00000000000 --- a/resource-manager/apimanagement/2022-08-01/deletedservice/method_getbyname_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package deletedservice - -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 GetByNameOperationResponse struct { - HttpResponse *http.Response - Model *DeletedServiceContract -} - -// GetByName ... -func (c DeletedServiceClient) GetByName(ctx context.Context, id DeletedServiceId) (result GetByNameOperationResponse, err error) { - req, err := c.preparerForGetByName(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "deletedservice.DeletedServiceClient", "GetByName", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "deletedservice.DeletedServiceClient", "GetByName", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetByName(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "deletedservice.DeletedServiceClient", "GetByName", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetByName prepares the GetByName request. -func (c DeletedServiceClient) preparerForGetByName(ctx context.Context, id DeletedServiceId) (*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)) -} - -// responderForGetByName handles the response to the GetByName request. The method always -// closes the http.Response Body. -func (c DeletedServiceClient) responderForGetByName(resp *http.Response) (result GetByNameOperationResponse, 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/apimanagement/2022-08-01/deletedservice/method_listbysubscription.go b/resource-manager/apimanagement/2022-08-01/deletedservice/method_listbysubscription.go new file mode 100644 index 00000000000..f6077a9e1f1 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/deletedservice/method_listbysubscription.go @@ -0,0 +1,90 @@ +package deletedservice + +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 *[]DeletedServiceContract +} + +type ListBySubscriptionCompleteResult struct { + Items []DeletedServiceContract +} + +// ListBySubscription ... +func (c DeletedServiceClient) 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.ApiManagement/deletedServices", 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 *[]DeletedServiceContract `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 DeletedServiceClient) ListBySubscriptionComplete(ctx context.Context, id commonids.SubscriptionId) (ListBySubscriptionCompleteResult, error) { + return c.ListBySubscriptionCompleteMatchingPredicate(ctx, id, DeletedServiceContractOperationPredicate{}) +} + +// ListBySubscriptionCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c DeletedServiceClient) ListBySubscriptionCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate DeletedServiceContractOperationPredicate) (result ListBySubscriptionCompleteResult, err error) { + items := make([]DeletedServiceContract, 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{ + Items: items, + } + return +} diff --git a/resource-manager/apimanagement/2022-08-01/deletedservice/method_listbysubscription_autorest.go b/resource-manager/apimanagement/2022-08-01/deletedservice/method_listbysubscription_autorest.go deleted file mode 100644 index 34e994381a2..00000000000 --- a/resource-manager/apimanagement/2022-08-01/deletedservice/method_listbysubscription_autorest.go +++ /dev/null @@ -1,187 +0,0 @@ -package deletedservice - -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 *[]DeletedServiceContract - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListBySubscriptionOperationResponse, error) -} - -type ListBySubscriptionCompleteResult struct { - Items []DeletedServiceContract -} - -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 DeletedServiceClient) ListBySubscription(ctx context.Context, id commonids.SubscriptionId) (resp ListBySubscriptionOperationResponse, err error) { - req, err := c.preparerForListBySubscription(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "deletedservice.DeletedServiceClient", "ListBySubscription", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "deletedservice.DeletedServiceClient", "ListBySubscription", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListBySubscription(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "deletedservice.DeletedServiceClient", "ListBySubscription", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListBySubscription prepares the ListBySubscription request. -func (c DeletedServiceClient) 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.ApiManagement/deletedServices", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListBySubscriptionWithNextLink prepares the ListBySubscription request with the given nextLink token. -func (c DeletedServiceClient) 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 DeletedServiceClient) responderForListBySubscription(resp *http.Response) (result ListBySubscriptionOperationResponse, err error) { - type page struct { - Values []DeletedServiceContract `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, "deletedservice.DeletedServiceClient", "ListBySubscription", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "deletedservice.DeletedServiceClient", "ListBySubscription", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListBySubscription(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "deletedservice.DeletedServiceClient", "ListBySubscription", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListBySubscriptionComplete retrieves all of the results into a single object -func (c DeletedServiceClient) ListBySubscriptionComplete(ctx context.Context, id commonids.SubscriptionId) (ListBySubscriptionCompleteResult, error) { - return c.ListBySubscriptionCompleteMatchingPredicate(ctx, id, DeletedServiceContractOperationPredicate{}) -} - -// ListBySubscriptionCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c DeletedServiceClient) ListBySubscriptionCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate DeletedServiceContractOperationPredicate) (resp ListBySubscriptionCompleteResult, err error) { - items := make([]DeletedServiceContract, 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/apimanagement/2022-08-01/deletedservice/method_purge.go b/resource-manager/apimanagement/2022-08-01/deletedservice/method_purge.go new file mode 100644 index 00000000000..0e5dcf28a3d --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/deletedservice/method_purge.go @@ -0,0 +1,71 @@ +package deletedservice + +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 PurgeOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Purge ... +func (c DeletedServiceClient) Purge(ctx context.Context, id DeletedServiceId) (result PurgeOperationResponse, 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 +} + +// PurgeThenPoll performs Purge then polls until it's completed +func (c DeletedServiceClient) PurgeThenPoll(ctx context.Context, id DeletedServiceId) error { + result, err := c.Purge(ctx, id) + if err != nil { + return fmt.Errorf("performing Purge: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Purge: %+v", err) + } + + return nil +} diff --git a/resource-manager/apimanagement/2022-08-01/deletedservice/method_purge_autorest.go b/resource-manager/apimanagement/2022-08-01/deletedservice/method_purge_autorest.go deleted file mode 100644 index 3494c6cdd2e..00000000000 --- a/resource-manager/apimanagement/2022-08-01/deletedservice/method_purge_autorest.go +++ /dev/null @@ -1,78 +0,0 @@ -package deletedservice - -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 PurgeOperationResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// Purge ... -func (c DeletedServiceClient) Purge(ctx context.Context, id DeletedServiceId) (result PurgeOperationResponse, err error) { - req, err := c.preparerForPurge(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "deletedservice.DeletedServiceClient", "Purge", nil, "Failure preparing request") - return - } - - result, err = c.senderForPurge(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "deletedservice.DeletedServiceClient", "Purge", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// PurgeThenPoll performs Purge then polls until it's completed -func (c DeletedServiceClient) PurgeThenPoll(ctx context.Context, id DeletedServiceId) error { - result, err := c.Purge(ctx, id) - if err != nil { - return fmt.Errorf("performing Purge: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after Purge: %+v", err) - } - - return nil -} - -// preparerForPurge prepares the Purge request. -func (c DeletedServiceClient) preparerForPurge(ctx context.Context, id DeletedServiceId) (*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)) -} - -// senderForPurge sends the Purge request. The method will close the -// http.Response Body if it receives an error. -func (c DeletedServiceClient) senderForPurge(ctx context.Context, req *http.Request) (future PurgeOperationResponse, 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/apimanagement/2022-08-01/diagnostic/client.go b/resource-manager/apimanagement/2022-08-01/diagnostic/client.go index 724671ed06e..c68f037e03e 100644 --- a/resource-manager/apimanagement/2022-08-01/diagnostic/client.go +++ b/resource-manager/apimanagement/2022-08-01/diagnostic/client.go @@ -1,18 +1,26 @@ package diagnostic -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 DiagnosticClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewDiagnosticClientWithBaseURI(endpoint string) DiagnosticClient { - return DiagnosticClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewDiagnosticClientWithBaseURI(api environments.Api) (*DiagnosticClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "diagnostic", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating DiagnosticClient: %+v", err) } + + return &DiagnosticClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2022-08-01/diagnostic/constants.go b/resource-manager/apimanagement/2022-08-01/diagnostic/constants.go index b75c24b4d61..cde4ab74afa 100644 --- a/resource-manager/apimanagement/2022-08-01/diagnostic/constants.go +++ b/resource-manager/apimanagement/2022-08-01/diagnostic/constants.go @@ -1,6 +1,10 @@ package diagnostic -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 PossibleValuesForAlwaysLog() []string { } } +func (s *AlwaysLog) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAlwaysLog(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseAlwaysLog(input string) (*AlwaysLog, error) { vals := map[string]AlwaysLog{ "allerrors": AlwaysLogAllErrors, @@ -44,6 +61,19 @@ func PossibleValuesForDataMaskingMode() []string { } } +func (s *DataMaskingMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDataMaskingMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseDataMaskingMode(input string) (*DataMaskingMode, error) { vals := map[string]DataMaskingMode{ "hide": DataMaskingModeHide, @@ -74,6 +104,19 @@ func PossibleValuesForHTTPCorrelationProtocol() []string { } } +func (s *HTTPCorrelationProtocol) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseHTTPCorrelationProtocol(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseHTTPCorrelationProtocol(input string) (*HTTPCorrelationProtocol, error) { vals := map[string]HTTPCorrelationProtocol{ "legacy": HTTPCorrelationProtocolLegacy, @@ -103,6 +146,19 @@ func PossibleValuesForOperationNameFormat() []string { } } +func (s *OperationNameFormat) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseOperationNameFormat(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseOperationNameFormat(input string) (*OperationNameFormat, error) { vals := map[string]OperationNameFormat{ "name": OperationNameFormatName, @@ -129,6 +185,19 @@ func PossibleValuesForSamplingType() []string { } } +func (s *SamplingType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSamplingType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseSamplingType(input string) (*SamplingType, error) { vals := map[string]SamplingType{ "fixed": SamplingTypeFixed, @@ -158,6 +227,19 @@ func PossibleValuesForVerbosity() []string { } } +func (s *Verbosity) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseVerbosity(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseVerbosity(input string) (*Verbosity, error) { vals := map[string]Verbosity{ "error": VerbosityError, diff --git a/resource-manager/apimanagement/2022-08-01/diagnostic/method_createorupdate.go b/resource-manager/apimanagement/2022-08-01/diagnostic/method_createorupdate.go new file mode 100644 index 00000000000..7b559f7022a --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/diagnostic/method_createorupdate.go @@ -0,0 +1,85 @@ +package diagnostic + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DiagnosticContract +} + +type CreateOrUpdateOperationOptions struct { + IfMatch *string +} + +func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { + return CreateOrUpdateOperationOptions{} +} + +func (o CreateOrUpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o CreateOrUpdateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o CreateOrUpdateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// CreateOrUpdate ... +func (c DiagnosticClient) CreateOrUpdate(ctx context.Context, id DiagnosticId, input DiagnosticContract, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + OptionsObject: options, + } + + 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/apimanagement/2022-08-01/diagnostic/method_createorupdate_autorest.go b/resource-manager/apimanagement/2022-08-01/diagnostic/method_createorupdate_autorest.go deleted file mode 100644 index b4c6a433f43..00000000000 --- a/resource-manager/apimanagement/2022-08-01/diagnostic/method_createorupdate_autorest.go +++ /dev/null @@ -1,98 +0,0 @@ -package diagnostic - -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 *DiagnosticContract -} - -type CreateOrUpdateOperationOptions struct { - IfMatch *string -} - -func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { - return CreateOrUpdateOperationOptions{} -} - -func (o CreateOrUpdateOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o CreateOrUpdateOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// CreateOrUpdate ... -func (c DiagnosticClient) CreateOrUpdate(ctx context.Context, id DiagnosticId, input DiagnosticContract, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdate(ctx, id, input, options) - if err != nil { - err = autorest.NewErrorWithError(err, "diagnostic.DiagnosticClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "diagnostic.DiagnosticClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCreateOrUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "diagnostic.DiagnosticClient", "CreateOrUpdate", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCreateOrUpdate prepares the CreateOrUpdate request. -func (c DiagnosticClient) preparerForCreateOrUpdate(ctx context.Context, id DiagnosticId, input DiagnosticContract, options CreateOrUpdateOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - 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 DiagnosticClient) responderForCreateOrUpdate(resp *http.Response) (result CreateOrUpdateOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2022-08-01/diagnostic/method_delete.go b/resource-manager/apimanagement/2022-08-01/diagnostic/method_delete.go new file mode 100644 index 00000000000..3cd08df2cd9 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/diagnostic/method_delete.go @@ -0,0 +1,76 @@ +package diagnostic + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +type DeleteOperationOptions struct { + IfMatch *string +} + +func DefaultDeleteOperationOptions() DeleteOperationOptions { + return DeleteOperationOptions{} +} + +func (o DeleteOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o DeleteOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o DeleteOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// Delete ... +func (c DiagnosticClient) Delete(ctx context.Context, id DiagnosticId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2022-08-01/diagnostic/method_delete_autorest.go b/resource-manager/apimanagement/2022-08-01/diagnostic/method_delete_autorest.go deleted file mode 100644 index e91965ee97f..00000000000 --- a/resource-manager/apimanagement/2022-08-01/diagnostic/method_delete_autorest.go +++ /dev/null @@ -1,95 +0,0 @@ -package diagnostic - -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 DeleteOperationResponse struct { - HttpResponse *http.Response -} - -type DeleteOperationOptions struct { - IfMatch *string -} - -func DefaultDeleteOperationOptions() DeleteOperationOptions { - return DeleteOperationOptions{} -} - -func (o DeleteOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o DeleteOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// Delete ... -func (c DiagnosticClient) Delete(ctx context.Context, id DiagnosticId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { - req, err := c.preparerForDelete(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "diagnostic.DiagnosticClient", "Delete", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "diagnostic.DiagnosticClient", "Delete", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForDelete(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "diagnostic.DiagnosticClient", "Delete", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForDelete prepares the Delete request. -func (c DiagnosticClient) preparerForDelete(ctx context.Context, id DiagnosticId, options DeleteOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForDelete handles the response to the Delete request. The method always -// closes the http.Response Body. -func (c DiagnosticClient) responderForDelete(resp *http.Response) (result DeleteOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2022-08-01/diagnostic/method_get.go b/resource-manager/apimanagement/2022-08-01/diagnostic/method_get.go new file mode 100644 index 00000000000..efc4cc74089 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/diagnostic/method_get.go @@ -0,0 +1,51 @@ +package diagnostic + +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 *DiagnosticContract +} + +// Get ... +func (c DiagnosticClient) Get(ctx context.Context, id DiagnosticId) (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/apimanagement/2022-08-01/diagnostic/method_get_autorest.go b/resource-manager/apimanagement/2022-08-01/diagnostic/method_get_autorest.go deleted file mode 100644 index c5725fba3fd..00000000000 --- a/resource-manager/apimanagement/2022-08-01/diagnostic/method_get_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package diagnostic - -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 *DiagnosticContract -} - -// Get ... -func (c DiagnosticClient) Get(ctx context.Context, id DiagnosticId) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "diagnostic.DiagnosticClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "diagnostic.DiagnosticClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "diagnostic.DiagnosticClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c DiagnosticClient) preparerForGet(ctx context.Context, id DiagnosticId) (*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 DiagnosticClient) 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/apimanagement/2022-08-01/diagnostic/method_getentitytag.go b/resource-manager/apimanagement/2022-08-01/diagnostic/method_getentitytag.go new file mode 100644 index 00000000000..8be53cb6cbf --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/diagnostic/method_getentitytag.go @@ -0,0 +1,46 @@ +package diagnostic + +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 GetEntityTagOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// GetEntityTag ... +func (c DiagnosticClient) GetEntityTag(ctx context.Context, id DiagnosticId) (result GetEntityTagOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodHead, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2022-08-01/diagnostic/method_getentitytag_autorest.go b/resource-manager/apimanagement/2022-08-01/diagnostic/method_getentitytag_autorest.go deleted file mode 100644 index f06e74665d8..00000000000 --- a/resource-manager/apimanagement/2022-08-01/diagnostic/method_getentitytag_autorest.go +++ /dev/null @@ -1,66 +0,0 @@ -package diagnostic - -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 GetEntityTagOperationResponse struct { - HttpResponse *http.Response -} - -// GetEntityTag ... -func (c DiagnosticClient) GetEntityTag(ctx context.Context, id DiagnosticId) (result GetEntityTagOperationResponse, err error) { - req, err := c.preparerForGetEntityTag(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "diagnostic.DiagnosticClient", "GetEntityTag", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "diagnostic.DiagnosticClient", "GetEntityTag", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetEntityTag(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "diagnostic.DiagnosticClient", "GetEntityTag", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetEntityTag prepares the GetEntityTag request. -func (c DiagnosticClient) preparerForGetEntityTag(ctx context.Context, id DiagnosticId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsHead(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetEntityTag handles the response to the GetEntityTag request. The method always -// closes the http.Response Body. -func (c DiagnosticClient) responderForGetEntityTag(resp *http.Response) (result GetEntityTagOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2022-08-01/diagnostic/method_listbyservice.go b/resource-manager/apimanagement/2022-08-01/diagnostic/method_listbyservice.go new file mode 100644 index 00000000000..591d81877f4 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/diagnostic/method_listbyservice.go @@ -0,0 +1,125 @@ +package diagnostic + +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 ListByServiceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]DiagnosticContract +} + +type ListByServiceCompleteResult struct { + Items []DiagnosticContract +} + +type ListByServiceOperationOptions struct { + Filter *string + Skip *int64 + Top *int64 +} + +func DefaultListByServiceOperationOptions() ListByServiceOperationOptions { + return ListByServiceOperationOptions{} +} + +func (o ListByServiceOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListByServiceOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListByServiceOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.Skip != nil { + out.Append("$skip", fmt.Sprintf("%v", *o.Skip)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +// ListByService ... +func (c DiagnosticClient) ListByService(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (result ListByServiceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/diagnostics", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]DiagnosticContract `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByServiceComplete retrieves all the results into a single object +func (c DiagnosticClient) ListByServiceComplete(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (ListByServiceCompleteResult, error) { + return c.ListByServiceCompleteMatchingPredicate(ctx, id, options, DiagnosticContractOperationPredicate{}) +} + +// ListByServiceCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c DiagnosticClient) ListByServiceCompleteMatchingPredicate(ctx context.Context, id ServiceId, options ListByServiceOperationOptions, predicate DiagnosticContractOperationPredicate) (result ListByServiceCompleteResult, err error) { + items := make([]DiagnosticContract, 0) + + resp, err := c.ListByService(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByServiceCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/apimanagement/2022-08-01/diagnostic/method_listbyservice_autorest.go b/resource-manager/apimanagement/2022-08-01/diagnostic/method_listbyservice_autorest.go deleted file mode 100644 index f02ef63c2c4..00000000000 --- a/resource-manager/apimanagement/2022-08-01/diagnostic/method_listbyservice_autorest.go +++ /dev/null @@ -1,225 +0,0 @@ -package diagnostic - -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 ListByServiceOperationResponse struct { - HttpResponse *http.Response - Model *[]DiagnosticContract - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListByServiceOperationResponse, error) -} - -type ListByServiceCompleteResult struct { - Items []DiagnosticContract -} - -func (r ListByServiceOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListByServiceOperationResponse) LoadMore(ctx context.Context) (resp ListByServiceOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -type ListByServiceOperationOptions struct { - Filter *string - Skip *int64 - Top *int64 -} - -func DefaultListByServiceOperationOptions() ListByServiceOperationOptions { - return ListByServiceOperationOptions{} -} - -func (o ListByServiceOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o ListByServiceOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Filter != nil { - out["$filter"] = *o.Filter - } - - if o.Skip != nil { - out["$skip"] = *o.Skip - } - - if o.Top != nil { - out["$top"] = *o.Top - } - - return out -} - -// ListByService ... -func (c DiagnosticClient) ListByService(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (resp ListByServiceOperationResponse, err error) { - req, err := c.preparerForListByService(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "diagnostic.DiagnosticClient", "ListByService", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "diagnostic.DiagnosticClient", "ListByService", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListByService(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "diagnostic.DiagnosticClient", "ListByService", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListByService prepares the ListByService request. -func (c DiagnosticClient) preparerForListByService(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/diagnostics", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListByServiceWithNextLink prepares the ListByService request with the given nextLink token. -func (c DiagnosticClient) preparerForListByServiceWithNextLink(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)) -} - -// responderForListByService handles the response to the ListByService request. The method always -// closes the http.Response Body. -func (c DiagnosticClient) responderForListByService(resp *http.Response) (result ListByServiceOperationResponse, err error) { - type page struct { - Values []DiagnosticContract `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 ListByServiceOperationResponse, err error) { - req, err := c.preparerForListByServiceWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "diagnostic.DiagnosticClient", "ListByService", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "diagnostic.DiagnosticClient", "ListByService", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByService(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "diagnostic.DiagnosticClient", "ListByService", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListByServiceComplete retrieves all of the results into a single object -func (c DiagnosticClient) ListByServiceComplete(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (ListByServiceCompleteResult, error) { - return c.ListByServiceCompleteMatchingPredicate(ctx, id, options, DiagnosticContractOperationPredicate{}) -} - -// ListByServiceCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c DiagnosticClient) ListByServiceCompleteMatchingPredicate(ctx context.Context, id ServiceId, options ListByServiceOperationOptions, predicate DiagnosticContractOperationPredicate) (resp ListByServiceCompleteResult, err error) { - items := make([]DiagnosticContract, 0) - - page, err := c.ListByService(ctx, id, options) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListByServiceCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/apimanagement/2022-08-01/diagnostic/method_update.go b/resource-manager/apimanagement/2022-08-01/diagnostic/method_update.go new file mode 100644 index 00000000000..cc36660c9e8 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/diagnostic/method_update.go @@ -0,0 +1,84 @@ +package diagnostic + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DiagnosticContract +} + +type UpdateOperationOptions struct { + IfMatch *string +} + +func DefaultUpdateOperationOptions() UpdateOperationOptions { + return UpdateOperationOptions{} +} + +func (o UpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o UpdateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o UpdateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// Update ... +func (c DiagnosticClient) Update(ctx context.Context, id DiagnosticId, input DiagnosticContract, options UpdateOperationOptions) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + OptionsObject: options, + } + + 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/apimanagement/2022-08-01/diagnostic/method_update_autorest.go b/resource-manager/apimanagement/2022-08-01/diagnostic/method_update_autorest.go deleted file mode 100644 index f0c0c3763a8..00000000000 --- a/resource-manager/apimanagement/2022-08-01/diagnostic/method_update_autorest.go +++ /dev/null @@ -1,98 +0,0 @@ -package diagnostic - -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 *DiagnosticContract -} - -type UpdateOperationOptions struct { - IfMatch *string -} - -func DefaultUpdateOperationOptions() UpdateOperationOptions { - return UpdateOperationOptions{} -} - -func (o UpdateOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o UpdateOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// Update ... -func (c DiagnosticClient) Update(ctx context.Context, id DiagnosticId, input DiagnosticContract, options UpdateOperationOptions) (result UpdateOperationResponse, err error) { - req, err := c.preparerForUpdate(ctx, id, input, options) - if err != nil { - err = autorest.NewErrorWithError(err, "diagnostic.DiagnosticClient", "Update", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "diagnostic.DiagnosticClient", "Update", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "diagnostic.DiagnosticClient", "Update", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForUpdate prepares the Update request. -func (c DiagnosticClient) preparerForUpdate(ctx context.Context, id DiagnosticId, input DiagnosticContract, options UpdateOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPatch(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - 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 DiagnosticClient) 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/apimanagement/2022-08-01/documentationresource/client.go b/resource-manager/apimanagement/2022-08-01/documentationresource/client.go index 4e67ef4a7b0..2ea8568342e 100644 --- a/resource-manager/apimanagement/2022-08-01/documentationresource/client.go +++ b/resource-manager/apimanagement/2022-08-01/documentationresource/client.go @@ -1,18 +1,26 @@ package documentationresource -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 DocumentationResourceClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewDocumentationResourceClientWithBaseURI(endpoint string) DocumentationResourceClient { - return DocumentationResourceClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewDocumentationResourceClientWithBaseURI(api environments.Api) (*DocumentationResourceClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "documentationresource", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating DocumentationResourceClient: %+v", err) } + + return &DocumentationResourceClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2022-08-01/documentationresource/method_createorupdate.go b/resource-manager/apimanagement/2022-08-01/documentationresource/method_createorupdate.go new file mode 100644 index 00000000000..71a26b35388 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/documentationresource/method_createorupdate.go @@ -0,0 +1,85 @@ +package documentationresource + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DocumentationContract +} + +type CreateOrUpdateOperationOptions struct { + IfMatch *string +} + +func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { + return CreateOrUpdateOperationOptions{} +} + +func (o CreateOrUpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o CreateOrUpdateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o CreateOrUpdateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// CreateOrUpdate ... +func (c DocumentationResourceClient) CreateOrUpdate(ctx context.Context, id DocumentationId, input DocumentationContract, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + OptionsObject: options, + } + + 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/apimanagement/2022-08-01/documentationresource/method_createorupdate_autorest.go b/resource-manager/apimanagement/2022-08-01/documentationresource/method_createorupdate_autorest.go deleted file mode 100644 index 9a9d4a32d99..00000000000 --- a/resource-manager/apimanagement/2022-08-01/documentationresource/method_createorupdate_autorest.go +++ /dev/null @@ -1,98 +0,0 @@ -package documentationresource - -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 *DocumentationContract -} - -type CreateOrUpdateOperationOptions struct { - IfMatch *string -} - -func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { - return CreateOrUpdateOperationOptions{} -} - -func (o CreateOrUpdateOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o CreateOrUpdateOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// CreateOrUpdate ... -func (c DocumentationResourceClient) CreateOrUpdate(ctx context.Context, id DocumentationId, input DocumentationContract, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdate(ctx, id, input, options) - if err != nil { - err = autorest.NewErrorWithError(err, "documentationresource.DocumentationResourceClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "documentationresource.DocumentationResourceClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCreateOrUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "documentationresource.DocumentationResourceClient", "CreateOrUpdate", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCreateOrUpdate prepares the CreateOrUpdate request. -func (c DocumentationResourceClient) preparerForCreateOrUpdate(ctx context.Context, id DocumentationId, input DocumentationContract, options CreateOrUpdateOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - 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 DocumentationResourceClient) responderForCreateOrUpdate(resp *http.Response) (result CreateOrUpdateOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2022-08-01/documentationresource/method_delete.go b/resource-manager/apimanagement/2022-08-01/documentationresource/method_delete.go new file mode 100644 index 00000000000..317039d8290 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/documentationresource/method_delete.go @@ -0,0 +1,76 @@ +package documentationresource + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +type DeleteOperationOptions struct { + IfMatch *string +} + +func DefaultDeleteOperationOptions() DeleteOperationOptions { + return DeleteOperationOptions{} +} + +func (o DeleteOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o DeleteOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o DeleteOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// Delete ... +func (c DocumentationResourceClient) Delete(ctx context.Context, id DocumentationId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2022-08-01/documentationresource/method_delete_autorest.go b/resource-manager/apimanagement/2022-08-01/documentationresource/method_delete_autorest.go deleted file mode 100644 index 70d423f9ada..00000000000 --- a/resource-manager/apimanagement/2022-08-01/documentationresource/method_delete_autorest.go +++ /dev/null @@ -1,95 +0,0 @@ -package documentationresource - -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 DeleteOperationResponse struct { - HttpResponse *http.Response -} - -type DeleteOperationOptions struct { - IfMatch *string -} - -func DefaultDeleteOperationOptions() DeleteOperationOptions { - return DeleteOperationOptions{} -} - -func (o DeleteOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o DeleteOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// Delete ... -func (c DocumentationResourceClient) Delete(ctx context.Context, id DocumentationId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { - req, err := c.preparerForDelete(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "documentationresource.DocumentationResourceClient", "Delete", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "documentationresource.DocumentationResourceClient", "Delete", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForDelete(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "documentationresource.DocumentationResourceClient", "Delete", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForDelete prepares the Delete request. -func (c DocumentationResourceClient) preparerForDelete(ctx context.Context, id DocumentationId, options DeleteOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForDelete handles the response to the Delete request. The method always -// closes the http.Response Body. -func (c DocumentationResourceClient) responderForDelete(resp *http.Response) (result DeleteOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2022-08-01/documentationresource/method_get.go b/resource-manager/apimanagement/2022-08-01/documentationresource/method_get.go new file mode 100644 index 00000000000..6bb219a02d1 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/documentationresource/method_get.go @@ -0,0 +1,51 @@ +package documentationresource + +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 *DocumentationContract +} + +// Get ... +func (c DocumentationResourceClient) Get(ctx context.Context, id DocumentationId) (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/apimanagement/2022-08-01/documentationresource/method_get_autorest.go b/resource-manager/apimanagement/2022-08-01/documentationresource/method_get_autorest.go deleted file mode 100644 index 6b1ff42de13..00000000000 --- a/resource-manager/apimanagement/2022-08-01/documentationresource/method_get_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package documentationresource - -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 *DocumentationContract -} - -// Get ... -func (c DocumentationResourceClient) Get(ctx context.Context, id DocumentationId) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "documentationresource.DocumentationResourceClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "documentationresource.DocumentationResourceClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "documentationresource.DocumentationResourceClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c DocumentationResourceClient) preparerForGet(ctx context.Context, id DocumentationId) (*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 DocumentationResourceClient) 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/apimanagement/2022-08-01/documentationresource/method_getentitytag.go b/resource-manager/apimanagement/2022-08-01/documentationresource/method_getentitytag.go new file mode 100644 index 00000000000..2a462006188 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/documentationresource/method_getentitytag.go @@ -0,0 +1,46 @@ +package documentationresource + +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 GetEntityTagOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// GetEntityTag ... +func (c DocumentationResourceClient) GetEntityTag(ctx context.Context, id DocumentationId) (result GetEntityTagOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodHead, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2022-08-01/documentationresource/method_getentitytag_autorest.go b/resource-manager/apimanagement/2022-08-01/documentationresource/method_getentitytag_autorest.go deleted file mode 100644 index a93dbaf8157..00000000000 --- a/resource-manager/apimanagement/2022-08-01/documentationresource/method_getentitytag_autorest.go +++ /dev/null @@ -1,66 +0,0 @@ -package documentationresource - -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 GetEntityTagOperationResponse struct { - HttpResponse *http.Response -} - -// GetEntityTag ... -func (c DocumentationResourceClient) GetEntityTag(ctx context.Context, id DocumentationId) (result GetEntityTagOperationResponse, err error) { - req, err := c.preparerForGetEntityTag(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "documentationresource.DocumentationResourceClient", "GetEntityTag", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "documentationresource.DocumentationResourceClient", "GetEntityTag", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetEntityTag(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "documentationresource.DocumentationResourceClient", "GetEntityTag", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetEntityTag prepares the GetEntityTag request. -func (c DocumentationResourceClient) preparerForGetEntityTag(ctx context.Context, id DocumentationId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsHead(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetEntityTag handles the response to the GetEntityTag request. The method always -// closes the http.Response Body. -func (c DocumentationResourceClient) responderForGetEntityTag(resp *http.Response) (result GetEntityTagOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2022-08-01/documentationresource/method_listbyservice.go b/resource-manager/apimanagement/2022-08-01/documentationresource/method_listbyservice.go new file mode 100644 index 00000000000..fe6333d8f8c --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/documentationresource/method_listbyservice.go @@ -0,0 +1,125 @@ +package documentationresource + +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 ListByServiceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]DocumentationContract +} + +type ListByServiceCompleteResult struct { + Items []DocumentationContract +} + +type ListByServiceOperationOptions struct { + Filter *string + Skip *int64 + Top *int64 +} + +func DefaultListByServiceOperationOptions() ListByServiceOperationOptions { + return ListByServiceOperationOptions{} +} + +func (o ListByServiceOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListByServiceOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListByServiceOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.Skip != nil { + out.Append("$skip", fmt.Sprintf("%v", *o.Skip)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +// ListByService ... +func (c DocumentationResourceClient) ListByService(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (result ListByServiceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/documentations", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]DocumentationContract `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByServiceComplete retrieves all the results into a single object +func (c DocumentationResourceClient) ListByServiceComplete(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (ListByServiceCompleteResult, error) { + return c.ListByServiceCompleteMatchingPredicate(ctx, id, options, DocumentationContractOperationPredicate{}) +} + +// ListByServiceCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c DocumentationResourceClient) ListByServiceCompleteMatchingPredicate(ctx context.Context, id ServiceId, options ListByServiceOperationOptions, predicate DocumentationContractOperationPredicate) (result ListByServiceCompleteResult, err error) { + items := make([]DocumentationContract, 0) + + resp, err := c.ListByService(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByServiceCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/apimanagement/2022-08-01/documentationresource/method_listbyservice_autorest.go b/resource-manager/apimanagement/2022-08-01/documentationresource/method_listbyservice_autorest.go deleted file mode 100644 index 2c9d3da0f67..00000000000 --- a/resource-manager/apimanagement/2022-08-01/documentationresource/method_listbyservice_autorest.go +++ /dev/null @@ -1,225 +0,0 @@ -package documentationresource - -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 ListByServiceOperationResponse struct { - HttpResponse *http.Response - Model *[]DocumentationContract - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListByServiceOperationResponse, error) -} - -type ListByServiceCompleteResult struct { - Items []DocumentationContract -} - -func (r ListByServiceOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListByServiceOperationResponse) LoadMore(ctx context.Context) (resp ListByServiceOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -type ListByServiceOperationOptions struct { - Filter *string - Skip *int64 - Top *int64 -} - -func DefaultListByServiceOperationOptions() ListByServiceOperationOptions { - return ListByServiceOperationOptions{} -} - -func (o ListByServiceOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o ListByServiceOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Filter != nil { - out["$filter"] = *o.Filter - } - - if o.Skip != nil { - out["$skip"] = *o.Skip - } - - if o.Top != nil { - out["$top"] = *o.Top - } - - return out -} - -// ListByService ... -func (c DocumentationResourceClient) ListByService(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (resp ListByServiceOperationResponse, err error) { - req, err := c.preparerForListByService(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "documentationresource.DocumentationResourceClient", "ListByService", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "documentationresource.DocumentationResourceClient", "ListByService", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListByService(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "documentationresource.DocumentationResourceClient", "ListByService", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListByService prepares the ListByService request. -func (c DocumentationResourceClient) preparerForListByService(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/documentations", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListByServiceWithNextLink prepares the ListByService request with the given nextLink token. -func (c DocumentationResourceClient) preparerForListByServiceWithNextLink(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)) -} - -// responderForListByService handles the response to the ListByService request. The method always -// closes the http.Response Body. -func (c DocumentationResourceClient) responderForListByService(resp *http.Response) (result ListByServiceOperationResponse, err error) { - type page struct { - Values []DocumentationContract `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 ListByServiceOperationResponse, err error) { - req, err := c.preparerForListByServiceWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "documentationresource.DocumentationResourceClient", "ListByService", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "documentationresource.DocumentationResourceClient", "ListByService", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByService(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "documentationresource.DocumentationResourceClient", "ListByService", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListByServiceComplete retrieves all of the results into a single object -func (c DocumentationResourceClient) ListByServiceComplete(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (ListByServiceCompleteResult, error) { - return c.ListByServiceCompleteMatchingPredicate(ctx, id, options, DocumentationContractOperationPredicate{}) -} - -// ListByServiceCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c DocumentationResourceClient) ListByServiceCompleteMatchingPredicate(ctx context.Context, id ServiceId, options ListByServiceOperationOptions, predicate DocumentationContractOperationPredicate) (resp ListByServiceCompleteResult, err error) { - items := make([]DocumentationContract, 0) - - page, err := c.ListByService(ctx, id, options) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListByServiceCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/apimanagement/2022-08-01/documentationresource/method_update.go b/resource-manager/apimanagement/2022-08-01/documentationresource/method_update.go new file mode 100644 index 00000000000..440a0e90747 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/documentationresource/method_update.go @@ -0,0 +1,84 @@ +package documentationresource + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DocumentationContract +} + +type UpdateOperationOptions struct { + IfMatch *string +} + +func DefaultUpdateOperationOptions() UpdateOperationOptions { + return UpdateOperationOptions{} +} + +func (o UpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o UpdateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o UpdateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// Update ... +func (c DocumentationResourceClient) Update(ctx context.Context, id DocumentationId, input DocumentationUpdateContract, options UpdateOperationOptions) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + OptionsObject: options, + } + + 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/apimanagement/2022-08-01/documentationresource/method_update_autorest.go b/resource-manager/apimanagement/2022-08-01/documentationresource/method_update_autorest.go deleted file mode 100644 index ebde148c0ac..00000000000 --- a/resource-manager/apimanagement/2022-08-01/documentationresource/method_update_autorest.go +++ /dev/null @@ -1,98 +0,0 @@ -package documentationresource - -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 *DocumentationContract -} - -type UpdateOperationOptions struct { - IfMatch *string -} - -func DefaultUpdateOperationOptions() UpdateOperationOptions { - return UpdateOperationOptions{} -} - -func (o UpdateOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o UpdateOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// Update ... -func (c DocumentationResourceClient) Update(ctx context.Context, id DocumentationId, input DocumentationUpdateContract, options UpdateOperationOptions) (result UpdateOperationResponse, err error) { - req, err := c.preparerForUpdate(ctx, id, input, options) - if err != nil { - err = autorest.NewErrorWithError(err, "documentationresource.DocumentationResourceClient", "Update", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "documentationresource.DocumentationResourceClient", "Update", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "documentationresource.DocumentationResourceClient", "Update", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForUpdate prepares the Update request. -func (c DocumentationResourceClient) preparerForUpdate(ctx context.Context, id DocumentationId, input DocumentationUpdateContract, options UpdateOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPatch(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - 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 DocumentationResourceClient) 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/apimanagement/2022-08-01/emailtemplate/client.go b/resource-manager/apimanagement/2022-08-01/emailtemplate/client.go index fcf62feaf0d..f33adb74866 100644 --- a/resource-manager/apimanagement/2022-08-01/emailtemplate/client.go +++ b/resource-manager/apimanagement/2022-08-01/emailtemplate/client.go @@ -1,18 +1,26 @@ package emailtemplate -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 EmailTemplateClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewEmailTemplateClientWithBaseURI(endpoint string) EmailTemplateClient { - return EmailTemplateClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewEmailTemplateClientWithBaseURI(api environments.Api) (*EmailTemplateClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "emailtemplate", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating EmailTemplateClient: %+v", err) } + + return &EmailTemplateClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2022-08-01/emailtemplate/method_listbyservice.go b/resource-manager/apimanagement/2022-08-01/emailtemplate/method_listbyservice.go new file mode 100644 index 00000000000..ece5fedb586 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/emailtemplate/method_listbyservice.go @@ -0,0 +1,125 @@ +package emailtemplate + +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 ListByServiceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]EmailTemplateContract +} + +type ListByServiceCompleteResult struct { + Items []EmailTemplateContract +} + +type ListByServiceOperationOptions struct { + Filter *string + Skip *int64 + Top *int64 +} + +func DefaultListByServiceOperationOptions() ListByServiceOperationOptions { + return ListByServiceOperationOptions{} +} + +func (o ListByServiceOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListByServiceOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListByServiceOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.Skip != nil { + out.Append("$skip", fmt.Sprintf("%v", *o.Skip)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +// ListByService ... +func (c EmailTemplateClient) ListByService(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (result ListByServiceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/templates", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]EmailTemplateContract `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByServiceComplete retrieves all the results into a single object +func (c EmailTemplateClient) ListByServiceComplete(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (ListByServiceCompleteResult, error) { + return c.ListByServiceCompleteMatchingPredicate(ctx, id, options, EmailTemplateContractOperationPredicate{}) +} + +// ListByServiceCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c EmailTemplateClient) ListByServiceCompleteMatchingPredicate(ctx context.Context, id ServiceId, options ListByServiceOperationOptions, predicate EmailTemplateContractOperationPredicate) (result ListByServiceCompleteResult, err error) { + items := make([]EmailTemplateContract, 0) + + resp, err := c.ListByService(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByServiceCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/apimanagement/2022-08-01/emailtemplate/method_listbyservice_autorest.go b/resource-manager/apimanagement/2022-08-01/emailtemplate/method_listbyservice_autorest.go deleted file mode 100644 index 69b66381ca2..00000000000 --- a/resource-manager/apimanagement/2022-08-01/emailtemplate/method_listbyservice_autorest.go +++ /dev/null @@ -1,225 +0,0 @@ -package emailtemplate - -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 ListByServiceOperationResponse struct { - HttpResponse *http.Response - Model *[]EmailTemplateContract - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListByServiceOperationResponse, error) -} - -type ListByServiceCompleteResult struct { - Items []EmailTemplateContract -} - -func (r ListByServiceOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListByServiceOperationResponse) LoadMore(ctx context.Context) (resp ListByServiceOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -type ListByServiceOperationOptions struct { - Filter *string - Skip *int64 - Top *int64 -} - -func DefaultListByServiceOperationOptions() ListByServiceOperationOptions { - return ListByServiceOperationOptions{} -} - -func (o ListByServiceOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o ListByServiceOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Filter != nil { - out["$filter"] = *o.Filter - } - - if o.Skip != nil { - out["$skip"] = *o.Skip - } - - if o.Top != nil { - out["$top"] = *o.Top - } - - return out -} - -// ListByService ... -func (c EmailTemplateClient) ListByService(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (resp ListByServiceOperationResponse, err error) { - req, err := c.preparerForListByService(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "emailtemplate.EmailTemplateClient", "ListByService", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "emailtemplate.EmailTemplateClient", "ListByService", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListByService(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "emailtemplate.EmailTemplateClient", "ListByService", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListByService prepares the ListByService request. -func (c EmailTemplateClient) preparerForListByService(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/templates", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListByServiceWithNextLink prepares the ListByService request with the given nextLink token. -func (c EmailTemplateClient) preparerForListByServiceWithNextLink(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)) -} - -// responderForListByService handles the response to the ListByService request. The method always -// closes the http.Response Body. -func (c EmailTemplateClient) responderForListByService(resp *http.Response) (result ListByServiceOperationResponse, err error) { - type page struct { - Values []EmailTemplateContract `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 ListByServiceOperationResponse, err error) { - req, err := c.preparerForListByServiceWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "emailtemplate.EmailTemplateClient", "ListByService", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "emailtemplate.EmailTemplateClient", "ListByService", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByService(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "emailtemplate.EmailTemplateClient", "ListByService", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListByServiceComplete retrieves all of the results into a single object -func (c EmailTemplateClient) ListByServiceComplete(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (ListByServiceCompleteResult, error) { - return c.ListByServiceCompleteMatchingPredicate(ctx, id, options, EmailTemplateContractOperationPredicate{}) -} - -// ListByServiceCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c EmailTemplateClient) ListByServiceCompleteMatchingPredicate(ctx context.Context, id ServiceId, options ListByServiceOperationOptions, predicate EmailTemplateContractOperationPredicate) (resp ListByServiceCompleteResult, err error) { - items := make([]EmailTemplateContract, 0) - - page, err := c.ListByService(ctx, id, options) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListByServiceCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/apimanagement/2022-08-01/emailtemplates/client.go b/resource-manager/apimanagement/2022-08-01/emailtemplates/client.go index 9794f3dc9e2..95f5deb2ef2 100644 --- a/resource-manager/apimanagement/2022-08-01/emailtemplates/client.go +++ b/resource-manager/apimanagement/2022-08-01/emailtemplates/client.go @@ -1,18 +1,26 @@ package emailtemplates -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 EmailTemplatesClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewEmailTemplatesClientWithBaseURI(endpoint string) EmailTemplatesClient { - return EmailTemplatesClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewEmailTemplatesClientWithBaseURI(api environments.Api) (*EmailTemplatesClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "emailtemplates", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating EmailTemplatesClient: %+v", err) } + + return &EmailTemplatesClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2022-08-01/emailtemplates/constants.go b/resource-manager/apimanagement/2022-08-01/emailtemplates/constants.go index 178c1c73651..19dadfefea4 100644 --- a/resource-manager/apimanagement/2022-08-01/emailtemplates/constants.go +++ b/resource-manager/apimanagement/2022-08-01/emailtemplates/constants.go @@ -1,6 +1,10 @@ package emailtemplates -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. @@ -43,6 +47,19 @@ func PossibleValuesForTemplateName() []string { } } +func (s *TemplateName) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseTemplateName(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseTemplateName(input string) (*TemplateName, error) { vals := map[string]TemplateName{ "accountcloseddeveloper": TemplateNameAccountClosedDeveloper, diff --git a/resource-manager/apimanagement/2022-08-01/emailtemplates/method_emailtemplatecreateorupdate.go b/resource-manager/apimanagement/2022-08-01/emailtemplates/method_emailtemplatecreateorupdate.go new file mode 100644 index 00000000000..80154b944bc --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/emailtemplates/method_emailtemplatecreateorupdate.go @@ -0,0 +1,85 @@ +package emailtemplates + +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 EmailTemplateCreateOrUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *EmailTemplateContract +} + +type EmailTemplateCreateOrUpdateOperationOptions struct { + IfMatch *string +} + +func DefaultEmailTemplateCreateOrUpdateOperationOptions() EmailTemplateCreateOrUpdateOperationOptions { + return EmailTemplateCreateOrUpdateOperationOptions{} +} + +func (o EmailTemplateCreateOrUpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o EmailTemplateCreateOrUpdateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o EmailTemplateCreateOrUpdateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// EmailTemplateCreateOrUpdate ... +func (c EmailTemplatesClient) EmailTemplateCreateOrUpdate(ctx context.Context, id TemplateId, input EmailTemplateUpdateParameters, options EmailTemplateCreateOrUpdateOperationOptions) (result EmailTemplateCreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + OptionsObject: options, + } + + 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/apimanagement/2022-08-01/emailtemplates/method_emailtemplatecreateorupdate_autorest.go b/resource-manager/apimanagement/2022-08-01/emailtemplates/method_emailtemplatecreateorupdate_autorest.go deleted file mode 100644 index 3a2c54ff109..00000000000 --- a/resource-manager/apimanagement/2022-08-01/emailtemplates/method_emailtemplatecreateorupdate_autorest.go +++ /dev/null @@ -1,98 +0,0 @@ -package emailtemplates - -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 EmailTemplateCreateOrUpdateOperationResponse struct { - HttpResponse *http.Response - Model *EmailTemplateContract -} - -type EmailTemplateCreateOrUpdateOperationOptions struct { - IfMatch *string -} - -func DefaultEmailTemplateCreateOrUpdateOperationOptions() EmailTemplateCreateOrUpdateOperationOptions { - return EmailTemplateCreateOrUpdateOperationOptions{} -} - -func (o EmailTemplateCreateOrUpdateOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o EmailTemplateCreateOrUpdateOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// EmailTemplateCreateOrUpdate ... -func (c EmailTemplatesClient) EmailTemplateCreateOrUpdate(ctx context.Context, id TemplateId, input EmailTemplateUpdateParameters, options EmailTemplateCreateOrUpdateOperationOptions) (result EmailTemplateCreateOrUpdateOperationResponse, err error) { - req, err := c.preparerForEmailTemplateCreateOrUpdate(ctx, id, input, options) - if err != nil { - err = autorest.NewErrorWithError(err, "emailtemplates.EmailTemplatesClient", "EmailTemplateCreateOrUpdate", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "emailtemplates.EmailTemplatesClient", "EmailTemplateCreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForEmailTemplateCreateOrUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "emailtemplates.EmailTemplatesClient", "EmailTemplateCreateOrUpdate", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForEmailTemplateCreateOrUpdate prepares the EmailTemplateCreateOrUpdate request. -func (c EmailTemplatesClient) preparerForEmailTemplateCreateOrUpdate(ctx context.Context, id TemplateId, input EmailTemplateUpdateParameters, options EmailTemplateCreateOrUpdateOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForEmailTemplateCreateOrUpdate handles the response to the EmailTemplateCreateOrUpdate request. The method always -// closes the http.Response Body. -func (c EmailTemplatesClient) responderForEmailTemplateCreateOrUpdate(resp *http.Response) (result EmailTemplateCreateOrUpdateOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2022-08-01/emailtemplates/method_emailtemplatedelete.go b/resource-manager/apimanagement/2022-08-01/emailtemplates/method_emailtemplatedelete.go new file mode 100644 index 00000000000..0edd892ed23 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/emailtemplates/method_emailtemplatedelete.go @@ -0,0 +1,76 @@ +package emailtemplates + +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 EmailTemplateDeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +type EmailTemplateDeleteOperationOptions struct { + IfMatch *string +} + +func DefaultEmailTemplateDeleteOperationOptions() EmailTemplateDeleteOperationOptions { + return EmailTemplateDeleteOperationOptions{} +} + +func (o EmailTemplateDeleteOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o EmailTemplateDeleteOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o EmailTemplateDeleteOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// EmailTemplateDelete ... +func (c EmailTemplatesClient) EmailTemplateDelete(ctx context.Context, id TemplateId, options EmailTemplateDeleteOperationOptions) (result EmailTemplateDeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2022-08-01/emailtemplates/method_emailtemplatedelete_autorest.go b/resource-manager/apimanagement/2022-08-01/emailtemplates/method_emailtemplatedelete_autorest.go deleted file mode 100644 index ec2f991850a..00000000000 --- a/resource-manager/apimanagement/2022-08-01/emailtemplates/method_emailtemplatedelete_autorest.go +++ /dev/null @@ -1,95 +0,0 @@ -package emailtemplates - -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 EmailTemplateDeleteOperationResponse struct { - HttpResponse *http.Response -} - -type EmailTemplateDeleteOperationOptions struct { - IfMatch *string -} - -func DefaultEmailTemplateDeleteOperationOptions() EmailTemplateDeleteOperationOptions { - return EmailTemplateDeleteOperationOptions{} -} - -func (o EmailTemplateDeleteOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o EmailTemplateDeleteOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// EmailTemplateDelete ... -func (c EmailTemplatesClient) EmailTemplateDelete(ctx context.Context, id TemplateId, options EmailTemplateDeleteOperationOptions) (result EmailTemplateDeleteOperationResponse, err error) { - req, err := c.preparerForEmailTemplateDelete(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "emailtemplates.EmailTemplatesClient", "EmailTemplateDelete", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "emailtemplates.EmailTemplatesClient", "EmailTemplateDelete", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForEmailTemplateDelete(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "emailtemplates.EmailTemplatesClient", "EmailTemplateDelete", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForEmailTemplateDelete prepares the EmailTemplateDelete request. -func (c EmailTemplatesClient) preparerForEmailTemplateDelete(ctx context.Context, id TemplateId, options EmailTemplateDeleteOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForEmailTemplateDelete handles the response to the EmailTemplateDelete request. The method always -// closes the http.Response Body. -func (c EmailTemplatesClient) responderForEmailTemplateDelete(resp *http.Response) (result EmailTemplateDeleteOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2022-08-01/emailtemplates/method_emailtemplateget.go b/resource-manager/apimanagement/2022-08-01/emailtemplates/method_emailtemplateget.go new file mode 100644 index 00000000000..91bd3f56c3a --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/emailtemplates/method_emailtemplateget.go @@ -0,0 +1,51 @@ +package emailtemplates + +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 EmailTemplateGetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *EmailTemplateContract +} + +// EmailTemplateGet ... +func (c EmailTemplatesClient) EmailTemplateGet(ctx context.Context, id TemplateId) (result EmailTemplateGetOperationResponse, 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/apimanagement/2022-08-01/emailtemplates/method_emailtemplateget_autorest.go b/resource-manager/apimanagement/2022-08-01/emailtemplates/method_emailtemplateget_autorest.go deleted file mode 100644 index 42f4ac52fc2..00000000000 --- a/resource-manager/apimanagement/2022-08-01/emailtemplates/method_emailtemplateget_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package emailtemplates - -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 EmailTemplateGetOperationResponse struct { - HttpResponse *http.Response - Model *EmailTemplateContract -} - -// EmailTemplateGet ... -func (c EmailTemplatesClient) EmailTemplateGet(ctx context.Context, id TemplateId) (result EmailTemplateGetOperationResponse, err error) { - req, err := c.preparerForEmailTemplateGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "emailtemplates.EmailTemplatesClient", "EmailTemplateGet", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "emailtemplates.EmailTemplatesClient", "EmailTemplateGet", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForEmailTemplateGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "emailtemplates.EmailTemplatesClient", "EmailTemplateGet", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForEmailTemplateGet prepares the EmailTemplateGet request. -func (c EmailTemplatesClient) preparerForEmailTemplateGet(ctx context.Context, id TemplateId) (*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)) -} - -// responderForEmailTemplateGet handles the response to the EmailTemplateGet request. The method always -// closes the http.Response Body. -func (c EmailTemplatesClient) responderForEmailTemplateGet(resp *http.Response) (result EmailTemplateGetOperationResponse, 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/apimanagement/2022-08-01/emailtemplates/method_emailtemplategetentitytag.go b/resource-manager/apimanagement/2022-08-01/emailtemplates/method_emailtemplategetentitytag.go new file mode 100644 index 00000000000..fd7e5616549 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/emailtemplates/method_emailtemplategetentitytag.go @@ -0,0 +1,46 @@ +package emailtemplates + +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 EmailTemplateGetEntityTagOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// EmailTemplateGetEntityTag ... +func (c EmailTemplatesClient) EmailTemplateGetEntityTag(ctx context.Context, id TemplateId) (result EmailTemplateGetEntityTagOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodHead, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2022-08-01/emailtemplates/method_emailtemplategetentitytag_autorest.go b/resource-manager/apimanagement/2022-08-01/emailtemplates/method_emailtemplategetentitytag_autorest.go deleted file mode 100644 index 81853d22c98..00000000000 --- a/resource-manager/apimanagement/2022-08-01/emailtemplates/method_emailtemplategetentitytag_autorest.go +++ /dev/null @@ -1,66 +0,0 @@ -package emailtemplates - -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 EmailTemplateGetEntityTagOperationResponse struct { - HttpResponse *http.Response -} - -// EmailTemplateGetEntityTag ... -func (c EmailTemplatesClient) EmailTemplateGetEntityTag(ctx context.Context, id TemplateId) (result EmailTemplateGetEntityTagOperationResponse, err error) { - req, err := c.preparerForEmailTemplateGetEntityTag(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "emailtemplates.EmailTemplatesClient", "EmailTemplateGetEntityTag", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "emailtemplates.EmailTemplatesClient", "EmailTemplateGetEntityTag", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForEmailTemplateGetEntityTag(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "emailtemplates.EmailTemplatesClient", "EmailTemplateGetEntityTag", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForEmailTemplateGetEntityTag prepares the EmailTemplateGetEntityTag request. -func (c EmailTemplatesClient) preparerForEmailTemplateGetEntityTag(ctx context.Context, id TemplateId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsHead(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForEmailTemplateGetEntityTag handles the response to the EmailTemplateGetEntityTag request. The method always -// closes the http.Response Body. -func (c EmailTemplatesClient) responderForEmailTemplateGetEntityTag(resp *http.Response) (result EmailTemplateGetEntityTagOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2022-08-01/emailtemplates/method_emailtemplateupdate.go b/resource-manager/apimanagement/2022-08-01/emailtemplates/method_emailtemplateupdate.go new file mode 100644 index 00000000000..5e5c6f703f2 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/emailtemplates/method_emailtemplateupdate.go @@ -0,0 +1,84 @@ +package emailtemplates + +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 EmailTemplateUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *EmailTemplateContract +} + +type EmailTemplateUpdateOperationOptions struct { + IfMatch *string +} + +func DefaultEmailTemplateUpdateOperationOptions() EmailTemplateUpdateOperationOptions { + return EmailTemplateUpdateOperationOptions{} +} + +func (o EmailTemplateUpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o EmailTemplateUpdateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o EmailTemplateUpdateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// EmailTemplateUpdate ... +func (c EmailTemplatesClient) EmailTemplateUpdate(ctx context.Context, id TemplateId, input EmailTemplateUpdateParameters, options EmailTemplateUpdateOperationOptions) (result EmailTemplateUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + OptionsObject: options, + } + + 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/apimanagement/2022-08-01/emailtemplates/method_emailtemplateupdate_autorest.go b/resource-manager/apimanagement/2022-08-01/emailtemplates/method_emailtemplateupdate_autorest.go deleted file mode 100644 index c53ed3c1cf7..00000000000 --- a/resource-manager/apimanagement/2022-08-01/emailtemplates/method_emailtemplateupdate_autorest.go +++ /dev/null @@ -1,98 +0,0 @@ -package emailtemplates - -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 EmailTemplateUpdateOperationResponse struct { - HttpResponse *http.Response - Model *EmailTemplateContract -} - -type EmailTemplateUpdateOperationOptions struct { - IfMatch *string -} - -func DefaultEmailTemplateUpdateOperationOptions() EmailTemplateUpdateOperationOptions { - return EmailTemplateUpdateOperationOptions{} -} - -func (o EmailTemplateUpdateOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o EmailTemplateUpdateOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// EmailTemplateUpdate ... -func (c EmailTemplatesClient) EmailTemplateUpdate(ctx context.Context, id TemplateId, input EmailTemplateUpdateParameters, options EmailTemplateUpdateOperationOptions) (result EmailTemplateUpdateOperationResponse, err error) { - req, err := c.preparerForEmailTemplateUpdate(ctx, id, input, options) - if err != nil { - err = autorest.NewErrorWithError(err, "emailtemplates.EmailTemplatesClient", "EmailTemplateUpdate", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "emailtemplates.EmailTemplatesClient", "EmailTemplateUpdate", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForEmailTemplateUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "emailtemplates.EmailTemplatesClient", "EmailTemplateUpdate", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForEmailTemplateUpdate prepares the EmailTemplateUpdate request. -func (c EmailTemplatesClient) preparerForEmailTemplateUpdate(ctx context.Context, id TemplateId, input EmailTemplateUpdateParameters, options EmailTemplateUpdateOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPatch(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForEmailTemplateUpdate handles the response to the EmailTemplateUpdate request. The method always -// closes the http.Response Body. -func (c EmailTemplatesClient) responderForEmailTemplateUpdate(resp *http.Response) (result EmailTemplateUpdateOperationResponse, 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/apimanagement/2022-08-01/gateway/client.go b/resource-manager/apimanagement/2022-08-01/gateway/client.go index a88c9cdaf70..03f53b2017c 100644 --- a/resource-manager/apimanagement/2022-08-01/gateway/client.go +++ b/resource-manager/apimanagement/2022-08-01/gateway/client.go @@ -1,18 +1,26 @@ package gateway -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 GatewayClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewGatewayClientWithBaseURI(endpoint string) GatewayClient { - return GatewayClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewGatewayClientWithBaseURI(api environments.Api) (*GatewayClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "gateway", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating GatewayClient: %+v", err) } + + return &GatewayClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2022-08-01/gateway/method_createorupdate.go b/resource-manager/apimanagement/2022-08-01/gateway/method_createorupdate.go new file mode 100644 index 00000000000..b166d062bf3 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/gateway/method_createorupdate.go @@ -0,0 +1,85 @@ +package gateway + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *GatewayContract +} + +type CreateOrUpdateOperationOptions struct { + IfMatch *string +} + +func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { + return CreateOrUpdateOperationOptions{} +} + +func (o CreateOrUpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o CreateOrUpdateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o CreateOrUpdateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// CreateOrUpdate ... +func (c GatewayClient) CreateOrUpdate(ctx context.Context, id GatewayId, input GatewayContract, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + OptionsObject: options, + } + + 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/apimanagement/2022-08-01/gateway/method_createorupdate_autorest.go b/resource-manager/apimanagement/2022-08-01/gateway/method_createorupdate_autorest.go deleted file mode 100644 index 6dd5cff75d6..00000000000 --- a/resource-manager/apimanagement/2022-08-01/gateway/method_createorupdate_autorest.go +++ /dev/null @@ -1,98 +0,0 @@ -package gateway - -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 *GatewayContract -} - -type CreateOrUpdateOperationOptions struct { - IfMatch *string -} - -func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { - return CreateOrUpdateOperationOptions{} -} - -func (o CreateOrUpdateOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o CreateOrUpdateOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// CreateOrUpdate ... -func (c GatewayClient) CreateOrUpdate(ctx context.Context, id GatewayId, input GatewayContract, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdate(ctx, id, input, options) - if err != nil { - err = autorest.NewErrorWithError(err, "gateway.GatewayClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "gateway.GatewayClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCreateOrUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "gateway.GatewayClient", "CreateOrUpdate", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCreateOrUpdate prepares the CreateOrUpdate request. -func (c GatewayClient) preparerForCreateOrUpdate(ctx context.Context, id GatewayId, input GatewayContract, options CreateOrUpdateOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - 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 GatewayClient) responderForCreateOrUpdate(resp *http.Response) (result CreateOrUpdateOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2022-08-01/gateway/method_delete.go b/resource-manager/apimanagement/2022-08-01/gateway/method_delete.go new file mode 100644 index 00000000000..34c8698ad34 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/gateway/method_delete.go @@ -0,0 +1,76 @@ +package gateway + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +type DeleteOperationOptions struct { + IfMatch *string +} + +func DefaultDeleteOperationOptions() DeleteOperationOptions { + return DeleteOperationOptions{} +} + +func (o DeleteOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o DeleteOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o DeleteOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// Delete ... +func (c GatewayClient) Delete(ctx context.Context, id GatewayId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2022-08-01/gateway/method_delete_autorest.go b/resource-manager/apimanagement/2022-08-01/gateway/method_delete_autorest.go deleted file mode 100644 index 1f3f99da15b..00000000000 --- a/resource-manager/apimanagement/2022-08-01/gateway/method_delete_autorest.go +++ /dev/null @@ -1,95 +0,0 @@ -package gateway - -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 DeleteOperationResponse struct { - HttpResponse *http.Response -} - -type DeleteOperationOptions struct { - IfMatch *string -} - -func DefaultDeleteOperationOptions() DeleteOperationOptions { - return DeleteOperationOptions{} -} - -func (o DeleteOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o DeleteOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// Delete ... -func (c GatewayClient) Delete(ctx context.Context, id GatewayId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { - req, err := c.preparerForDelete(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "gateway.GatewayClient", "Delete", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "gateway.GatewayClient", "Delete", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForDelete(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "gateway.GatewayClient", "Delete", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForDelete prepares the Delete request. -func (c GatewayClient) preparerForDelete(ctx context.Context, id GatewayId, options DeleteOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForDelete handles the response to the Delete request. The method always -// closes the http.Response Body. -func (c GatewayClient) responderForDelete(resp *http.Response) (result DeleteOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2022-08-01/gateway/method_get.go b/resource-manager/apimanagement/2022-08-01/gateway/method_get.go new file mode 100644 index 00000000000..73393157e02 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/gateway/method_get.go @@ -0,0 +1,51 @@ +package gateway + +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 *GatewayContract +} + +// Get ... +func (c GatewayClient) Get(ctx context.Context, id GatewayId) (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/apimanagement/2022-08-01/gateway/method_get_autorest.go b/resource-manager/apimanagement/2022-08-01/gateway/method_get_autorest.go deleted file mode 100644 index 516262b26c0..00000000000 --- a/resource-manager/apimanagement/2022-08-01/gateway/method_get_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package gateway - -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 *GatewayContract -} - -// Get ... -func (c GatewayClient) Get(ctx context.Context, id GatewayId) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "gateway.GatewayClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "gateway.GatewayClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "gateway.GatewayClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c GatewayClient) preparerForGet(ctx context.Context, id GatewayId) (*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 GatewayClient) 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/apimanagement/2022-08-01/gateway/method_getentitytag.go b/resource-manager/apimanagement/2022-08-01/gateway/method_getentitytag.go new file mode 100644 index 00000000000..34c8cd8439b --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/gateway/method_getentitytag.go @@ -0,0 +1,46 @@ +package gateway + +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 GetEntityTagOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// GetEntityTag ... +func (c GatewayClient) GetEntityTag(ctx context.Context, id GatewayId) (result GetEntityTagOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodHead, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2022-08-01/gateway/method_getentitytag_autorest.go b/resource-manager/apimanagement/2022-08-01/gateway/method_getentitytag_autorest.go deleted file mode 100644 index 023b4dd2c1b..00000000000 --- a/resource-manager/apimanagement/2022-08-01/gateway/method_getentitytag_autorest.go +++ /dev/null @@ -1,66 +0,0 @@ -package gateway - -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 GetEntityTagOperationResponse struct { - HttpResponse *http.Response -} - -// GetEntityTag ... -func (c GatewayClient) GetEntityTag(ctx context.Context, id GatewayId) (result GetEntityTagOperationResponse, err error) { - req, err := c.preparerForGetEntityTag(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "gateway.GatewayClient", "GetEntityTag", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "gateway.GatewayClient", "GetEntityTag", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetEntityTag(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "gateway.GatewayClient", "GetEntityTag", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetEntityTag prepares the GetEntityTag request. -func (c GatewayClient) preparerForGetEntityTag(ctx context.Context, id GatewayId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsHead(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetEntityTag handles the response to the GetEntityTag request. The method always -// closes the http.Response Body. -func (c GatewayClient) responderForGetEntityTag(resp *http.Response) (result GetEntityTagOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2022-08-01/gateway/method_listbyservice.go b/resource-manager/apimanagement/2022-08-01/gateway/method_listbyservice.go new file mode 100644 index 00000000000..2e1953f23da --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/gateway/method_listbyservice.go @@ -0,0 +1,125 @@ +package gateway + +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 ListByServiceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]GatewayContract +} + +type ListByServiceCompleteResult struct { + Items []GatewayContract +} + +type ListByServiceOperationOptions struct { + Filter *string + Skip *int64 + Top *int64 +} + +func DefaultListByServiceOperationOptions() ListByServiceOperationOptions { + return ListByServiceOperationOptions{} +} + +func (o ListByServiceOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListByServiceOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListByServiceOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.Skip != nil { + out.Append("$skip", fmt.Sprintf("%v", *o.Skip)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +// ListByService ... +func (c GatewayClient) ListByService(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (result ListByServiceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/gateways", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]GatewayContract `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByServiceComplete retrieves all the results into a single object +func (c GatewayClient) ListByServiceComplete(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (ListByServiceCompleteResult, error) { + return c.ListByServiceCompleteMatchingPredicate(ctx, id, options, GatewayContractOperationPredicate{}) +} + +// ListByServiceCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c GatewayClient) ListByServiceCompleteMatchingPredicate(ctx context.Context, id ServiceId, options ListByServiceOperationOptions, predicate GatewayContractOperationPredicate) (result ListByServiceCompleteResult, err error) { + items := make([]GatewayContract, 0) + + resp, err := c.ListByService(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByServiceCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/apimanagement/2022-08-01/gateway/method_listbyservice_autorest.go b/resource-manager/apimanagement/2022-08-01/gateway/method_listbyservice_autorest.go deleted file mode 100644 index 6bef69b64f7..00000000000 --- a/resource-manager/apimanagement/2022-08-01/gateway/method_listbyservice_autorest.go +++ /dev/null @@ -1,225 +0,0 @@ -package gateway - -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 ListByServiceOperationResponse struct { - HttpResponse *http.Response - Model *[]GatewayContract - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListByServiceOperationResponse, error) -} - -type ListByServiceCompleteResult struct { - Items []GatewayContract -} - -func (r ListByServiceOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListByServiceOperationResponse) LoadMore(ctx context.Context) (resp ListByServiceOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -type ListByServiceOperationOptions struct { - Filter *string - Skip *int64 - Top *int64 -} - -func DefaultListByServiceOperationOptions() ListByServiceOperationOptions { - return ListByServiceOperationOptions{} -} - -func (o ListByServiceOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o ListByServiceOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Filter != nil { - out["$filter"] = *o.Filter - } - - if o.Skip != nil { - out["$skip"] = *o.Skip - } - - if o.Top != nil { - out["$top"] = *o.Top - } - - return out -} - -// ListByService ... -func (c GatewayClient) ListByService(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (resp ListByServiceOperationResponse, err error) { - req, err := c.preparerForListByService(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "gateway.GatewayClient", "ListByService", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "gateway.GatewayClient", "ListByService", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListByService(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "gateway.GatewayClient", "ListByService", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListByService prepares the ListByService request. -func (c GatewayClient) preparerForListByService(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/gateways", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListByServiceWithNextLink prepares the ListByService request with the given nextLink token. -func (c GatewayClient) preparerForListByServiceWithNextLink(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)) -} - -// responderForListByService handles the response to the ListByService request. The method always -// closes the http.Response Body. -func (c GatewayClient) responderForListByService(resp *http.Response) (result ListByServiceOperationResponse, err error) { - type page struct { - Values []GatewayContract `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 ListByServiceOperationResponse, err error) { - req, err := c.preparerForListByServiceWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "gateway.GatewayClient", "ListByService", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "gateway.GatewayClient", "ListByService", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByService(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "gateway.GatewayClient", "ListByService", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListByServiceComplete retrieves all of the results into a single object -func (c GatewayClient) ListByServiceComplete(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (ListByServiceCompleteResult, error) { - return c.ListByServiceCompleteMatchingPredicate(ctx, id, options, GatewayContractOperationPredicate{}) -} - -// ListByServiceCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c GatewayClient) ListByServiceCompleteMatchingPredicate(ctx context.Context, id ServiceId, options ListByServiceOperationOptions, predicate GatewayContractOperationPredicate) (resp ListByServiceCompleteResult, err error) { - items := make([]GatewayContract, 0) - - page, err := c.ListByService(ctx, id, options) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListByServiceCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/apimanagement/2022-08-01/gateway/method_update.go b/resource-manager/apimanagement/2022-08-01/gateway/method_update.go new file mode 100644 index 00000000000..fcf2126f5bd --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/gateway/method_update.go @@ -0,0 +1,84 @@ +package gateway + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *GatewayContract +} + +type UpdateOperationOptions struct { + IfMatch *string +} + +func DefaultUpdateOperationOptions() UpdateOperationOptions { + return UpdateOperationOptions{} +} + +func (o UpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o UpdateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o UpdateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// Update ... +func (c GatewayClient) Update(ctx context.Context, id GatewayId, input GatewayContract, options UpdateOperationOptions) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + OptionsObject: options, + } + + 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/apimanagement/2022-08-01/gateway/method_update_autorest.go b/resource-manager/apimanagement/2022-08-01/gateway/method_update_autorest.go deleted file mode 100644 index f307a2b614f..00000000000 --- a/resource-manager/apimanagement/2022-08-01/gateway/method_update_autorest.go +++ /dev/null @@ -1,98 +0,0 @@ -package gateway - -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 *GatewayContract -} - -type UpdateOperationOptions struct { - IfMatch *string -} - -func DefaultUpdateOperationOptions() UpdateOperationOptions { - return UpdateOperationOptions{} -} - -func (o UpdateOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o UpdateOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// Update ... -func (c GatewayClient) Update(ctx context.Context, id GatewayId, input GatewayContract, options UpdateOperationOptions) (result UpdateOperationResponse, err error) { - req, err := c.preparerForUpdate(ctx, id, input, options) - if err != nil { - err = autorest.NewErrorWithError(err, "gateway.GatewayClient", "Update", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "gateway.GatewayClient", "Update", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "gateway.GatewayClient", "Update", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForUpdate prepares the Update request. -func (c GatewayClient) preparerForUpdate(ctx context.Context, id GatewayId, input GatewayContract, options UpdateOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPatch(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - 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 GatewayClient) 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/apimanagement/2022-08-01/gatewayapi/client.go b/resource-manager/apimanagement/2022-08-01/gatewayapi/client.go index 46a46094cd5..e697610f2b9 100644 --- a/resource-manager/apimanagement/2022-08-01/gatewayapi/client.go +++ b/resource-manager/apimanagement/2022-08-01/gatewayapi/client.go @@ -1,18 +1,26 @@ package gatewayapi -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 GatewayApiClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewGatewayApiClientWithBaseURI(endpoint string) GatewayApiClient { - return GatewayApiClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewGatewayApiClientWithBaseURI(api environments.Api) (*GatewayApiClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "gatewayapi", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating GatewayApiClient: %+v", err) } + + return &GatewayApiClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2022-08-01/gatewayapi/constants.go b/resource-manager/apimanagement/2022-08-01/gatewayapi/constants.go index 0be8c860d66..0da8f569039 100644 --- a/resource-manager/apimanagement/2022-08-01/gatewayapi/constants.go +++ b/resource-manager/apimanagement/2022-08-01/gatewayapi/constants.go @@ -1,6 +1,10 @@ package gatewayapi -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 PossibleValuesForApiType() []string { } } +func (s *ApiType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseApiType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseApiType(input string) (*ApiType, error) { vals := map[string]ApiType{ "graphql": ApiTypeGraphql, @@ -53,6 +70,19 @@ func PossibleValuesForBearerTokenSendingMethods() []string { } } +func (s *BearerTokenSendingMethods) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseBearerTokenSendingMethods(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseBearerTokenSendingMethods(input string) (*BearerTokenSendingMethods, error) { vals := map[string]BearerTokenSendingMethods{ "authorizationheader": BearerTokenSendingMethodsAuthorizationHeader, @@ -85,6 +115,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{ "http": ProtocolHTTP, @@ -113,6 +156,19 @@ func PossibleValuesForProvisioningState() []string { } } +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseProvisioningState(input string) (*ProvisioningState, error) { vals := map[string]ProvisioningState{ "created": ProvisioningStateCreated, @@ -142,6 +198,19 @@ func PossibleValuesForVersioningScheme() []string { } } +func (s *VersioningScheme) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseVersioningScheme(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseVersioningScheme(input string) (*VersioningScheme, error) { vals := map[string]VersioningScheme{ "header": VersioningSchemeHeader, diff --git a/resource-manager/apimanagement/2022-08-01/gatewayapi/method_createorupdate.go b/resource-manager/apimanagement/2022-08-01/gatewayapi/method_createorupdate.go new file mode 100644 index 00000000000..8fd635de876 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/gatewayapi/method_createorupdate.go @@ -0,0 +1,56 @@ +package gatewayapi + +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 *ApiContract +} + +// CreateOrUpdate ... +func (c GatewayApiClient) CreateOrUpdate(ctx context.Context, id GatewayApiId, input AssociationContract) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + if err = resp.Unmarshal(&result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2022-08-01/gatewayapi/method_createorupdate_autorest.go b/resource-manager/apimanagement/2022-08-01/gatewayapi/method_createorupdate_autorest.go deleted file mode 100644 index e8e7ed2c7aa..00000000000 --- a/resource-manager/apimanagement/2022-08-01/gatewayapi/method_createorupdate_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package gatewayapi - -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 *ApiContract -} - -// CreateOrUpdate ... -func (c GatewayApiClient) CreateOrUpdate(ctx context.Context, id GatewayApiId, input AssociationContract) (result CreateOrUpdateOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "gatewayapi.GatewayApiClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "gatewayapi.GatewayApiClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCreateOrUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "gatewayapi.GatewayApiClient", "CreateOrUpdate", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCreateOrUpdate prepares the CreateOrUpdate request. -func (c GatewayApiClient) preparerForCreateOrUpdate(ctx context.Context, id GatewayApiId, input AssociationContract) (*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 GatewayApiClient) responderForCreateOrUpdate(resp *http.Response) (result CreateOrUpdateOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2022-08-01/gatewayapi/method_delete.go b/resource-manager/apimanagement/2022-08-01/gatewayapi/method_delete.go new file mode 100644 index 00000000000..293176f784a --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/gatewayapi/method_delete.go @@ -0,0 +1,47 @@ +package gatewayapi + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c GatewayApiClient) Delete(ctx context.Context, id GatewayApiId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2022-08-01/gatewayapi/method_delete_autorest.go b/resource-manager/apimanagement/2022-08-01/gatewayapi/method_delete_autorest.go deleted file mode 100644 index 5da91051687..00000000000 --- a/resource-manager/apimanagement/2022-08-01/gatewayapi/method_delete_autorest.go +++ /dev/null @@ -1,66 +0,0 @@ -package gatewayapi - -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 DeleteOperationResponse struct { - HttpResponse *http.Response -} - -// Delete ... -func (c GatewayApiClient) Delete(ctx context.Context, id GatewayApiId) (result DeleteOperationResponse, err error) { - req, err := c.preparerForDelete(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "gatewayapi.GatewayApiClient", "Delete", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "gatewayapi.GatewayApiClient", "Delete", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForDelete(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "gatewayapi.GatewayApiClient", "Delete", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForDelete prepares the Delete request. -func (c GatewayApiClient) preparerForDelete(ctx context.Context, id GatewayApiId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForDelete handles the response to the Delete request. The method always -// closes the http.Response Body. -func (c GatewayApiClient) responderForDelete(resp *http.Response) (result DeleteOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2022-08-01/gatewayapi/method_getentitytag.go b/resource-manager/apimanagement/2022-08-01/gatewayapi/method_getentitytag.go new file mode 100644 index 00000000000..e14c0b61f72 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/gatewayapi/method_getentitytag.go @@ -0,0 +1,46 @@ +package gatewayapi + +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 GetEntityTagOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// GetEntityTag ... +func (c GatewayApiClient) GetEntityTag(ctx context.Context, id GatewayApiId) (result GetEntityTagOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodHead, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2022-08-01/gatewayapi/method_getentitytag_autorest.go b/resource-manager/apimanagement/2022-08-01/gatewayapi/method_getentitytag_autorest.go deleted file mode 100644 index 9d658fd84a6..00000000000 --- a/resource-manager/apimanagement/2022-08-01/gatewayapi/method_getentitytag_autorest.go +++ /dev/null @@ -1,66 +0,0 @@ -package gatewayapi - -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 GetEntityTagOperationResponse struct { - HttpResponse *http.Response -} - -// GetEntityTag ... -func (c GatewayApiClient) GetEntityTag(ctx context.Context, id GatewayApiId) (result GetEntityTagOperationResponse, err error) { - req, err := c.preparerForGetEntityTag(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "gatewayapi.GatewayApiClient", "GetEntityTag", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "gatewayapi.GatewayApiClient", "GetEntityTag", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetEntityTag(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "gatewayapi.GatewayApiClient", "GetEntityTag", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetEntityTag prepares the GetEntityTag request. -func (c GatewayApiClient) preparerForGetEntityTag(ctx context.Context, id GatewayApiId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsHead(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetEntityTag handles the response to the GetEntityTag request. The method always -// closes the http.Response Body. -func (c GatewayApiClient) responderForGetEntityTag(resp *http.Response) (result GetEntityTagOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2022-08-01/gatewayapi/method_listbyservice.go b/resource-manager/apimanagement/2022-08-01/gatewayapi/method_listbyservice.go new file mode 100644 index 00000000000..478f87c8195 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/gatewayapi/method_listbyservice.go @@ -0,0 +1,125 @@ +package gatewayapi + +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 ListByServiceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ApiContract +} + +type ListByServiceCompleteResult struct { + Items []ApiContract +} + +type ListByServiceOperationOptions struct { + Filter *string + Skip *int64 + Top *int64 +} + +func DefaultListByServiceOperationOptions() ListByServiceOperationOptions { + return ListByServiceOperationOptions{} +} + +func (o ListByServiceOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListByServiceOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListByServiceOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.Skip != nil { + out.Append("$skip", fmt.Sprintf("%v", *o.Skip)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +// ListByService ... +func (c GatewayApiClient) ListByService(ctx context.Context, id GatewayId, options ListByServiceOperationOptions) (result ListByServiceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/apis", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ApiContract `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByServiceComplete retrieves all the results into a single object +func (c GatewayApiClient) ListByServiceComplete(ctx context.Context, id GatewayId, options ListByServiceOperationOptions) (ListByServiceCompleteResult, error) { + return c.ListByServiceCompleteMatchingPredicate(ctx, id, options, ApiContractOperationPredicate{}) +} + +// ListByServiceCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c GatewayApiClient) ListByServiceCompleteMatchingPredicate(ctx context.Context, id GatewayId, options ListByServiceOperationOptions, predicate ApiContractOperationPredicate) (result ListByServiceCompleteResult, err error) { + items := make([]ApiContract, 0) + + resp, err := c.ListByService(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByServiceCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/apimanagement/2022-08-01/gatewayapi/method_listbyservice_autorest.go b/resource-manager/apimanagement/2022-08-01/gatewayapi/method_listbyservice_autorest.go deleted file mode 100644 index d219bb643d7..00000000000 --- a/resource-manager/apimanagement/2022-08-01/gatewayapi/method_listbyservice_autorest.go +++ /dev/null @@ -1,225 +0,0 @@ -package gatewayapi - -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 ListByServiceOperationResponse struct { - HttpResponse *http.Response - Model *[]ApiContract - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListByServiceOperationResponse, error) -} - -type ListByServiceCompleteResult struct { - Items []ApiContract -} - -func (r ListByServiceOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListByServiceOperationResponse) LoadMore(ctx context.Context) (resp ListByServiceOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -type ListByServiceOperationOptions struct { - Filter *string - Skip *int64 - Top *int64 -} - -func DefaultListByServiceOperationOptions() ListByServiceOperationOptions { - return ListByServiceOperationOptions{} -} - -func (o ListByServiceOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o ListByServiceOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Filter != nil { - out["$filter"] = *o.Filter - } - - if o.Skip != nil { - out["$skip"] = *o.Skip - } - - if o.Top != nil { - out["$top"] = *o.Top - } - - return out -} - -// ListByService ... -func (c GatewayApiClient) ListByService(ctx context.Context, id GatewayId, options ListByServiceOperationOptions) (resp ListByServiceOperationResponse, err error) { - req, err := c.preparerForListByService(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "gatewayapi.GatewayApiClient", "ListByService", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "gatewayapi.GatewayApiClient", "ListByService", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListByService(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "gatewayapi.GatewayApiClient", "ListByService", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListByService prepares the ListByService request. -func (c GatewayApiClient) preparerForListByService(ctx context.Context, id GatewayId, options ListByServiceOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/apis", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListByServiceWithNextLink prepares the ListByService request with the given nextLink token. -func (c GatewayApiClient) preparerForListByServiceWithNextLink(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)) -} - -// responderForListByService handles the response to the ListByService request. The method always -// closes the http.Response Body. -func (c GatewayApiClient) responderForListByService(resp *http.Response) (result ListByServiceOperationResponse, err error) { - type page struct { - Values []ApiContract `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 ListByServiceOperationResponse, err error) { - req, err := c.preparerForListByServiceWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "gatewayapi.GatewayApiClient", "ListByService", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "gatewayapi.GatewayApiClient", "ListByService", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByService(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "gatewayapi.GatewayApiClient", "ListByService", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListByServiceComplete retrieves all of the results into a single object -func (c GatewayApiClient) ListByServiceComplete(ctx context.Context, id GatewayId, options ListByServiceOperationOptions) (ListByServiceCompleteResult, error) { - return c.ListByServiceCompleteMatchingPredicate(ctx, id, options, ApiContractOperationPredicate{}) -} - -// ListByServiceCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c GatewayApiClient) ListByServiceCompleteMatchingPredicate(ctx context.Context, id GatewayId, options ListByServiceOperationOptions, predicate ApiContractOperationPredicate) (resp ListByServiceCompleteResult, err error) { - items := make([]ApiContract, 0) - - page, err := c.ListByService(ctx, id, options) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListByServiceCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/apimanagement/2022-08-01/gatewaycertificateauthority/client.go b/resource-manager/apimanagement/2022-08-01/gatewaycertificateauthority/client.go index 05f22b3b215..43210db9dbb 100644 --- a/resource-manager/apimanagement/2022-08-01/gatewaycertificateauthority/client.go +++ b/resource-manager/apimanagement/2022-08-01/gatewaycertificateauthority/client.go @@ -1,18 +1,26 @@ package gatewaycertificateauthority -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 GatewayCertificateAuthorityClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewGatewayCertificateAuthorityClientWithBaseURI(endpoint string) GatewayCertificateAuthorityClient { - return GatewayCertificateAuthorityClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewGatewayCertificateAuthorityClientWithBaseURI(api environments.Api) (*GatewayCertificateAuthorityClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "gatewaycertificateauthority", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating GatewayCertificateAuthorityClient: %+v", err) } + + return &GatewayCertificateAuthorityClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2022-08-01/gatewaycertificateauthority/method_createorupdate.go b/resource-manager/apimanagement/2022-08-01/gatewaycertificateauthority/method_createorupdate.go new file mode 100644 index 00000000000..a982aaf94c4 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/gatewaycertificateauthority/method_createorupdate.go @@ -0,0 +1,85 @@ +package gatewaycertificateauthority + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *GatewayCertificateAuthorityContract +} + +type CreateOrUpdateOperationOptions struct { + IfMatch *string +} + +func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { + return CreateOrUpdateOperationOptions{} +} + +func (o CreateOrUpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o CreateOrUpdateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o CreateOrUpdateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// CreateOrUpdate ... +func (c GatewayCertificateAuthorityClient) CreateOrUpdate(ctx context.Context, id CertificateAuthorityId, input GatewayCertificateAuthorityContract, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + OptionsObject: options, + } + + 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/apimanagement/2022-08-01/gatewaycertificateauthority/method_createorupdate_autorest.go b/resource-manager/apimanagement/2022-08-01/gatewaycertificateauthority/method_createorupdate_autorest.go deleted file mode 100644 index 4e7230468d3..00000000000 --- a/resource-manager/apimanagement/2022-08-01/gatewaycertificateauthority/method_createorupdate_autorest.go +++ /dev/null @@ -1,98 +0,0 @@ -package gatewaycertificateauthority - -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 *GatewayCertificateAuthorityContract -} - -type CreateOrUpdateOperationOptions struct { - IfMatch *string -} - -func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { - return CreateOrUpdateOperationOptions{} -} - -func (o CreateOrUpdateOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o CreateOrUpdateOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// CreateOrUpdate ... -func (c GatewayCertificateAuthorityClient) CreateOrUpdate(ctx context.Context, id CertificateAuthorityId, input GatewayCertificateAuthorityContract, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdate(ctx, id, input, options) - if err != nil { - err = autorest.NewErrorWithError(err, "gatewaycertificateauthority.GatewayCertificateAuthorityClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "gatewaycertificateauthority.GatewayCertificateAuthorityClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCreateOrUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "gatewaycertificateauthority.GatewayCertificateAuthorityClient", "CreateOrUpdate", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCreateOrUpdate prepares the CreateOrUpdate request. -func (c GatewayCertificateAuthorityClient) preparerForCreateOrUpdate(ctx context.Context, id CertificateAuthorityId, input GatewayCertificateAuthorityContract, options CreateOrUpdateOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - 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 GatewayCertificateAuthorityClient) responderForCreateOrUpdate(resp *http.Response) (result CreateOrUpdateOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2022-08-01/gatewaycertificateauthority/method_delete.go b/resource-manager/apimanagement/2022-08-01/gatewaycertificateauthority/method_delete.go new file mode 100644 index 00000000000..ee1deb63010 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/gatewaycertificateauthority/method_delete.go @@ -0,0 +1,76 @@ +package gatewaycertificateauthority + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +type DeleteOperationOptions struct { + IfMatch *string +} + +func DefaultDeleteOperationOptions() DeleteOperationOptions { + return DeleteOperationOptions{} +} + +func (o DeleteOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o DeleteOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o DeleteOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// Delete ... +func (c GatewayCertificateAuthorityClient) Delete(ctx context.Context, id CertificateAuthorityId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2022-08-01/gatewaycertificateauthority/method_delete_autorest.go b/resource-manager/apimanagement/2022-08-01/gatewaycertificateauthority/method_delete_autorest.go deleted file mode 100644 index 0f9df6ed8a0..00000000000 --- a/resource-manager/apimanagement/2022-08-01/gatewaycertificateauthority/method_delete_autorest.go +++ /dev/null @@ -1,95 +0,0 @@ -package gatewaycertificateauthority - -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 DeleteOperationResponse struct { - HttpResponse *http.Response -} - -type DeleteOperationOptions struct { - IfMatch *string -} - -func DefaultDeleteOperationOptions() DeleteOperationOptions { - return DeleteOperationOptions{} -} - -func (o DeleteOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o DeleteOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// Delete ... -func (c GatewayCertificateAuthorityClient) Delete(ctx context.Context, id CertificateAuthorityId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { - req, err := c.preparerForDelete(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "gatewaycertificateauthority.GatewayCertificateAuthorityClient", "Delete", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "gatewaycertificateauthority.GatewayCertificateAuthorityClient", "Delete", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForDelete(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "gatewaycertificateauthority.GatewayCertificateAuthorityClient", "Delete", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForDelete prepares the Delete request. -func (c GatewayCertificateAuthorityClient) preparerForDelete(ctx context.Context, id CertificateAuthorityId, options DeleteOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForDelete handles the response to the Delete request. The method always -// closes the http.Response Body. -func (c GatewayCertificateAuthorityClient) responderForDelete(resp *http.Response) (result DeleteOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2022-08-01/gatewaycertificateauthority/method_get.go b/resource-manager/apimanagement/2022-08-01/gatewaycertificateauthority/method_get.go new file mode 100644 index 00000000000..12ff864df7c --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/gatewaycertificateauthority/method_get.go @@ -0,0 +1,51 @@ +package gatewaycertificateauthority + +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 *GatewayCertificateAuthorityContract +} + +// Get ... +func (c GatewayCertificateAuthorityClient) Get(ctx context.Context, id CertificateAuthorityId) (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/apimanagement/2022-08-01/gatewaycertificateauthority/method_get_autorest.go b/resource-manager/apimanagement/2022-08-01/gatewaycertificateauthority/method_get_autorest.go deleted file mode 100644 index c858b3b46b5..00000000000 --- a/resource-manager/apimanagement/2022-08-01/gatewaycertificateauthority/method_get_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package gatewaycertificateauthority - -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 *GatewayCertificateAuthorityContract -} - -// Get ... -func (c GatewayCertificateAuthorityClient) Get(ctx context.Context, id CertificateAuthorityId) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "gatewaycertificateauthority.GatewayCertificateAuthorityClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "gatewaycertificateauthority.GatewayCertificateAuthorityClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "gatewaycertificateauthority.GatewayCertificateAuthorityClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c GatewayCertificateAuthorityClient) preparerForGet(ctx context.Context, id CertificateAuthorityId) (*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 GatewayCertificateAuthorityClient) 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/apimanagement/2022-08-01/gatewaycertificateauthority/method_getentitytag.go b/resource-manager/apimanagement/2022-08-01/gatewaycertificateauthority/method_getentitytag.go new file mode 100644 index 00000000000..cc382dbb6d8 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/gatewaycertificateauthority/method_getentitytag.go @@ -0,0 +1,46 @@ +package gatewaycertificateauthority + +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 GetEntityTagOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// GetEntityTag ... +func (c GatewayCertificateAuthorityClient) GetEntityTag(ctx context.Context, id CertificateAuthorityId) (result GetEntityTagOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodHead, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2022-08-01/gatewaycertificateauthority/method_getentitytag_autorest.go b/resource-manager/apimanagement/2022-08-01/gatewaycertificateauthority/method_getentitytag_autorest.go deleted file mode 100644 index 642eee2277d..00000000000 --- a/resource-manager/apimanagement/2022-08-01/gatewaycertificateauthority/method_getentitytag_autorest.go +++ /dev/null @@ -1,66 +0,0 @@ -package gatewaycertificateauthority - -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 GetEntityTagOperationResponse struct { - HttpResponse *http.Response -} - -// GetEntityTag ... -func (c GatewayCertificateAuthorityClient) GetEntityTag(ctx context.Context, id CertificateAuthorityId) (result GetEntityTagOperationResponse, err error) { - req, err := c.preparerForGetEntityTag(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "gatewaycertificateauthority.GatewayCertificateAuthorityClient", "GetEntityTag", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "gatewaycertificateauthority.GatewayCertificateAuthorityClient", "GetEntityTag", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetEntityTag(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "gatewaycertificateauthority.GatewayCertificateAuthorityClient", "GetEntityTag", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetEntityTag prepares the GetEntityTag request. -func (c GatewayCertificateAuthorityClient) preparerForGetEntityTag(ctx context.Context, id CertificateAuthorityId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsHead(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetEntityTag handles the response to the GetEntityTag request. The method always -// closes the http.Response Body. -func (c GatewayCertificateAuthorityClient) responderForGetEntityTag(resp *http.Response) (result GetEntityTagOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2022-08-01/gatewaycertificateauthority/method_listbyservice.go b/resource-manager/apimanagement/2022-08-01/gatewaycertificateauthority/method_listbyservice.go new file mode 100644 index 00000000000..3b24a4a53a6 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/gatewaycertificateauthority/method_listbyservice.go @@ -0,0 +1,125 @@ +package gatewaycertificateauthority + +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 ListByServiceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]GatewayCertificateAuthorityContract +} + +type ListByServiceCompleteResult struct { + Items []GatewayCertificateAuthorityContract +} + +type ListByServiceOperationOptions struct { + Filter *string + Skip *int64 + Top *int64 +} + +func DefaultListByServiceOperationOptions() ListByServiceOperationOptions { + return ListByServiceOperationOptions{} +} + +func (o ListByServiceOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListByServiceOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListByServiceOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.Skip != nil { + out.Append("$skip", fmt.Sprintf("%v", *o.Skip)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +// ListByService ... +func (c GatewayCertificateAuthorityClient) ListByService(ctx context.Context, id GatewayId, options ListByServiceOperationOptions) (result ListByServiceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/certificateAuthorities", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]GatewayCertificateAuthorityContract `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByServiceComplete retrieves all the results into a single object +func (c GatewayCertificateAuthorityClient) ListByServiceComplete(ctx context.Context, id GatewayId, options ListByServiceOperationOptions) (ListByServiceCompleteResult, error) { + return c.ListByServiceCompleteMatchingPredicate(ctx, id, options, GatewayCertificateAuthorityContractOperationPredicate{}) +} + +// ListByServiceCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c GatewayCertificateAuthorityClient) ListByServiceCompleteMatchingPredicate(ctx context.Context, id GatewayId, options ListByServiceOperationOptions, predicate GatewayCertificateAuthorityContractOperationPredicate) (result ListByServiceCompleteResult, err error) { + items := make([]GatewayCertificateAuthorityContract, 0) + + resp, err := c.ListByService(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByServiceCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/apimanagement/2022-08-01/gatewaycertificateauthority/method_listbyservice_autorest.go b/resource-manager/apimanagement/2022-08-01/gatewaycertificateauthority/method_listbyservice_autorest.go deleted file mode 100644 index e629cd90912..00000000000 --- a/resource-manager/apimanagement/2022-08-01/gatewaycertificateauthority/method_listbyservice_autorest.go +++ /dev/null @@ -1,225 +0,0 @@ -package gatewaycertificateauthority - -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 ListByServiceOperationResponse struct { - HttpResponse *http.Response - Model *[]GatewayCertificateAuthorityContract - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListByServiceOperationResponse, error) -} - -type ListByServiceCompleteResult struct { - Items []GatewayCertificateAuthorityContract -} - -func (r ListByServiceOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListByServiceOperationResponse) LoadMore(ctx context.Context) (resp ListByServiceOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -type ListByServiceOperationOptions struct { - Filter *string - Skip *int64 - Top *int64 -} - -func DefaultListByServiceOperationOptions() ListByServiceOperationOptions { - return ListByServiceOperationOptions{} -} - -func (o ListByServiceOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o ListByServiceOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Filter != nil { - out["$filter"] = *o.Filter - } - - if o.Skip != nil { - out["$skip"] = *o.Skip - } - - if o.Top != nil { - out["$top"] = *o.Top - } - - return out -} - -// ListByService ... -func (c GatewayCertificateAuthorityClient) ListByService(ctx context.Context, id GatewayId, options ListByServiceOperationOptions) (resp ListByServiceOperationResponse, err error) { - req, err := c.preparerForListByService(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "gatewaycertificateauthority.GatewayCertificateAuthorityClient", "ListByService", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "gatewaycertificateauthority.GatewayCertificateAuthorityClient", "ListByService", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListByService(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "gatewaycertificateauthority.GatewayCertificateAuthorityClient", "ListByService", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListByService prepares the ListByService request. -func (c GatewayCertificateAuthorityClient) preparerForListByService(ctx context.Context, id GatewayId, options ListByServiceOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/certificateAuthorities", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListByServiceWithNextLink prepares the ListByService request with the given nextLink token. -func (c GatewayCertificateAuthorityClient) preparerForListByServiceWithNextLink(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)) -} - -// responderForListByService handles the response to the ListByService request. The method always -// closes the http.Response Body. -func (c GatewayCertificateAuthorityClient) responderForListByService(resp *http.Response) (result ListByServiceOperationResponse, err error) { - type page struct { - Values []GatewayCertificateAuthorityContract `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 ListByServiceOperationResponse, err error) { - req, err := c.preparerForListByServiceWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "gatewaycertificateauthority.GatewayCertificateAuthorityClient", "ListByService", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "gatewaycertificateauthority.GatewayCertificateAuthorityClient", "ListByService", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByService(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "gatewaycertificateauthority.GatewayCertificateAuthorityClient", "ListByService", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListByServiceComplete retrieves all of the results into a single object -func (c GatewayCertificateAuthorityClient) ListByServiceComplete(ctx context.Context, id GatewayId, options ListByServiceOperationOptions) (ListByServiceCompleteResult, error) { - return c.ListByServiceCompleteMatchingPredicate(ctx, id, options, GatewayCertificateAuthorityContractOperationPredicate{}) -} - -// ListByServiceCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c GatewayCertificateAuthorityClient) ListByServiceCompleteMatchingPredicate(ctx context.Context, id GatewayId, options ListByServiceOperationOptions, predicate GatewayCertificateAuthorityContractOperationPredicate) (resp ListByServiceCompleteResult, err error) { - items := make([]GatewayCertificateAuthorityContract, 0) - - page, err := c.ListByService(ctx, id, options) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListByServiceCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/apimanagement/2022-08-01/gatewaygeneratetoken/client.go b/resource-manager/apimanagement/2022-08-01/gatewaygeneratetoken/client.go index 5eef6f835aa..d2ebe3b89b3 100644 --- a/resource-manager/apimanagement/2022-08-01/gatewaygeneratetoken/client.go +++ b/resource-manager/apimanagement/2022-08-01/gatewaygeneratetoken/client.go @@ -1,18 +1,26 @@ package gatewaygeneratetoken -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 GatewayGenerateTokenClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewGatewayGenerateTokenClientWithBaseURI(endpoint string) GatewayGenerateTokenClient { - return GatewayGenerateTokenClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewGatewayGenerateTokenClientWithBaseURI(api environments.Api) (*GatewayGenerateTokenClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "gatewaygeneratetoken", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating GatewayGenerateTokenClient: %+v", err) } + + return &GatewayGenerateTokenClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2022-08-01/gatewaygeneratetoken/constants.go b/resource-manager/apimanagement/2022-08-01/gatewaygeneratetoken/constants.go index 2b5b29d0556..23e4c225a32 100644 --- a/resource-manager/apimanagement/2022-08-01/gatewaygeneratetoken/constants.go +++ b/resource-manager/apimanagement/2022-08-01/gatewaygeneratetoken/constants.go @@ -1,6 +1,10 @@ package gatewaygeneratetoken -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 PossibleValuesForKeyType() []string { } } +func (s *KeyType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseKeyType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseKeyType(input string) (*KeyType, error) { vals := map[string]KeyType{ "primary": KeyTypePrimary, diff --git a/resource-manager/apimanagement/2022-08-01/gatewaygeneratetoken/method_gatewaygeneratetoken.go b/resource-manager/apimanagement/2022-08-01/gatewaygeneratetoken/method_gatewaygeneratetoken.go new file mode 100644 index 00000000000..3c75500bfd1 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/gatewaygeneratetoken/method_gatewaygeneratetoken.go @@ -0,0 +1,56 @@ +package gatewaygeneratetoken + +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 GatewayGenerateTokenOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *GatewayTokenContract +} + +// GatewayGenerateToken ... +func (c GatewayGenerateTokenClient) GatewayGenerateToken(ctx context.Context, id GatewayId, input GatewayTokenRequestContract) (result GatewayGenerateTokenOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/generateToken", 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/apimanagement/2022-08-01/gatewaygeneratetoken/method_gatewaygeneratetoken_autorest.go b/resource-manager/apimanagement/2022-08-01/gatewaygeneratetoken/method_gatewaygeneratetoken_autorest.go deleted file mode 100644 index cec0cc96400..00000000000 --- a/resource-manager/apimanagement/2022-08-01/gatewaygeneratetoken/method_gatewaygeneratetoken_autorest.go +++ /dev/null @@ -1,70 +0,0 @@ -package gatewaygeneratetoken - -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 GatewayGenerateTokenOperationResponse struct { - HttpResponse *http.Response - Model *GatewayTokenContract -} - -// GatewayGenerateToken ... -func (c GatewayGenerateTokenClient) GatewayGenerateToken(ctx context.Context, id GatewayId, input GatewayTokenRequestContract) (result GatewayGenerateTokenOperationResponse, err error) { - req, err := c.preparerForGatewayGenerateToken(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "gatewaygeneratetoken.GatewayGenerateTokenClient", "GatewayGenerateToken", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "gatewaygeneratetoken.GatewayGenerateTokenClient", "GatewayGenerateToken", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGatewayGenerateToken(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "gatewaygeneratetoken.GatewayGenerateTokenClient", "GatewayGenerateToken", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGatewayGenerateToken prepares the GatewayGenerateToken request. -func (c GatewayGenerateTokenClient) preparerForGatewayGenerateToken(ctx context.Context, id GatewayId, input GatewayTokenRequestContract) (*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/generateToken", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGatewayGenerateToken handles the response to the GatewayGenerateToken request. The method always -// closes the http.Response Body. -func (c GatewayGenerateTokenClient) responderForGatewayGenerateToken(resp *http.Response) (result GatewayGenerateTokenOperationResponse, 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/apimanagement/2022-08-01/gatewayhostnameconfiguration/client.go b/resource-manager/apimanagement/2022-08-01/gatewayhostnameconfiguration/client.go index d6e83f1d02e..652c5e5e27d 100644 --- a/resource-manager/apimanagement/2022-08-01/gatewayhostnameconfiguration/client.go +++ b/resource-manager/apimanagement/2022-08-01/gatewayhostnameconfiguration/client.go @@ -1,18 +1,26 @@ package gatewayhostnameconfiguration -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 GatewayHostnameConfigurationClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewGatewayHostnameConfigurationClientWithBaseURI(endpoint string) GatewayHostnameConfigurationClient { - return GatewayHostnameConfigurationClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewGatewayHostnameConfigurationClientWithBaseURI(api environments.Api) (*GatewayHostnameConfigurationClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "gatewayhostnameconfiguration", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating GatewayHostnameConfigurationClient: %+v", err) } + + return &GatewayHostnameConfigurationClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2022-08-01/gatewayhostnameconfiguration/method_createorupdate.go b/resource-manager/apimanagement/2022-08-01/gatewayhostnameconfiguration/method_createorupdate.go new file mode 100644 index 00000000000..1a362be1c96 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/gatewayhostnameconfiguration/method_createorupdate.go @@ -0,0 +1,85 @@ +package gatewayhostnameconfiguration + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *GatewayHostnameConfigurationContract +} + +type CreateOrUpdateOperationOptions struct { + IfMatch *string +} + +func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { + return CreateOrUpdateOperationOptions{} +} + +func (o CreateOrUpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o CreateOrUpdateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o CreateOrUpdateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// CreateOrUpdate ... +func (c GatewayHostnameConfigurationClient) CreateOrUpdate(ctx context.Context, id HostnameConfigurationId, input GatewayHostnameConfigurationContract, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + OptionsObject: options, + } + + 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/apimanagement/2022-08-01/gatewayhostnameconfiguration/method_createorupdate_autorest.go b/resource-manager/apimanagement/2022-08-01/gatewayhostnameconfiguration/method_createorupdate_autorest.go deleted file mode 100644 index 1636e17ebb1..00000000000 --- a/resource-manager/apimanagement/2022-08-01/gatewayhostnameconfiguration/method_createorupdate_autorest.go +++ /dev/null @@ -1,98 +0,0 @@ -package gatewayhostnameconfiguration - -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 *GatewayHostnameConfigurationContract -} - -type CreateOrUpdateOperationOptions struct { - IfMatch *string -} - -func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { - return CreateOrUpdateOperationOptions{} -} - -func (o CreateOrUpdateOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o CreateOrUpdateOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// CreateOrUpdate ... -func (c GatewayHostnameConfigurationClient) CreateOrUpdate(ctx context.Context, id HostnameConfigurationId, input GatewayHostnameConfigurationContract, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdate(ctx, id, input, options) - if err != nil { - err = autorest.NewErrorWithError(err, "gatewayhostnameconfiguration.GatewayHostnameConfigurationClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "gatewayhostnameconfiguration.GatewayHostnameConfigurationClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCreateOrUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "gatewayhostnameconfiguration.GatewayHostnameConfigurationClient", "CreateOrUpdate", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCreateOrUpdate prepares the CreateOrUpdate request. -func (c GatewayHostnameConfigurationClient) preparerForCreateOrUpdate(ctx context.Context, id HostnameConfigurationId, input GatewayHostnameConfigurationContract, options CreateOrUpdateOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - 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 GatewayHostnameConfigurationClient) responderForCreateOrUpdate(resp *http.Response) (result CreateOrUpdateOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2022-08-01/gatewayhostnameconfiguration/method_delete.go b/resource-manager/apimanagement/2022-08-01/gatewayhostnameconfiguration/method_delete.go new file mode 100644 index 00000000000..d36e0d55e20 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/gatewayhostnameconfiguration/method_delete.go @@ -0,0 +1,76 @@ +package gatewayhostnameconfiguration + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +type DeleteOperationOptions struct { + IfMatch *string +} + +func DefaultDeleteOperationOptions() DeleteOperationOptions { + return DeleteOperationOptions{} +} + +func (o DeleteOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o DeleteOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o DeleteOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// Delete ... +func (c GatewayHostnameConfigurationClient) Delete(ctx context.Context, id HostnameConfigurationId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2022-08-01/gatewayhostnameconfiguration/method_delete_autorest.go b/resource-manager/apimanagement/2022-08-01/gatewayhostnameconfiguration/method_delete_autorest.go deleted file mode 100644 index 64f4fa809d7..00000000000 --- a/resource-manager/apimanagement/2022-08-01/gatewayhostnameconfiguration/method_delete_autorest.go +++ /dev/null @@ -1,95 +0,0 @@ -package gatewayhostnameconfiguration - -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 DeleteOperationResponse struct { - HttpResponse *http.Response -} - -type DeleteOperationOptions struct { - IfMatch *string -} - -func DefaultDeleteOperationOptions() DeleteOperationOptions { - return DeleteOperationOptions{} -} - -func (o DeleteOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o DeleteOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// Delete ... -func (c GatewayHostnameConfigurationClient) Delete(ctx context.Context, id HostnameConfigurationId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { - req, err := c.preparerForDelete(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "gatewayhostnameconfiguration.GatewayHostnameConfigurationClient", "Delete", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "gatewayhostnameconfiguration.GatewayHostnameConfigurationClient", "Delete", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForDelete(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "gatewayhostnameconfiguration.GatewayHostnameConfigurationClient", "Delete", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForDelete prepares the Delete request. -func (c GatewayHostnameConfigurationClient) preparerForDelete(ctx context.Context, id HostnameConfigurationId, options DeleteOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForDelete handles the response to the Delete request. The method always -// closes the http.Response Body. -func (c GatewayHostnameConfigurationClient) responderForDelete(resp *http.Response) (result DeleteOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2022-08-01/gatewayhostnameconfiguration/method_get.go b/resource-manager/apimanagement/2022-08-01/gatewayhostnameconfiguration/method_get.go new file mode 100644 index 00000000000..f1f5ec6b270 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/gatewayhostnameconfiguration/method_get.go @@ -0,0 +1,51 @@ +package gatewayhostnameconfiguration + +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 *GatewayHostnameConfigurationContract +} + +// Get ... +func (c GatewayHostnameConfigurationClient) Get(ctx context.Context, id HostnameConfigurationId) (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/apimanagement/2022-08-01/gatewayhostnameconfiguration/method_get_autorest.go b/resource-manager/apimanagement/2022-08-01/gatewayhostnameconfiguration/method_get_autorest.go deleted file mode 100644 index be5cbec23ca..00000000000 --- a/resource-manager/apimanagement/2022-08-01/gatewayhostnameconfiguration/method_get_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package gatewayhostnameconfiguration - -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 *GatewayHostnameConfigurationContract -} - -// Get ... -func (c GatewayHostnameConfigurationClient) Get(ctx context.Context, id HostnameConfigurationId) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "gatewayhostnameconfiguration.GatewayHostnameConfigurationClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "gatewayhostnameconfiguration.GatewayHostnameConfigurationClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "gatewayhostnameconfiguration.GatewayHostnameConfigurationClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c GatewayHostnameConfigurationClient) preparerForGet(ctx context.Context, id HostnameConfigurationId) (*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 GatewayHostnameConfigurationClient) 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/apimanagement/2022-08-01/gatewayhostnameconfiguration/method_getentitytag.go b/resource-manager/apimanagement/2022-08-01/gatewayhostnameconfiguration/method_getentitytag.go new file mode 100644 index 00000000000..76b08b4e076 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/gatewayhostnameconfiguration/method_getentitytag.go @@ -0,0 +1,46 @@ +package gatewayhostnameconfiguration + +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 GetEntityTagOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// GetEntityTag ... +func (c GatewayHostnameConfigurationClient) GetEntityTag(ctx context.Context, id HostnameConfigurationId) (result GetEntityTagOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodHead, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2022-08-01/gatewayhostnameconfiguration/method_getentitytag_autorest.go b/resource-manager/apimanagement/2022-08-01/gatewayhostnameconfiguration/method_getentitytag_autorest.go deleted file mode 100644 index 424ecbb64c0..00000000000 --- a/resource-manager/apimanagement/2022-08-01/gatewayhostnameconfiguration/method_getentitytag_autorest.go +++ /dev/null @@ -1,66 +0,0 @@ -package gatewayhostnameconfiguration - -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 GetEntityTagOperationResponse struct { - HttpResponse *http.Response -} - -// GetEntityTag ... -func (c GatewayHostnameConfigurationClient) GetEntityTag(ctx context.Context, id HostnameConfigurationId) (result GetEntityTagOperationResponse, err error) { - req, err := c.preparerForGetEntityTag(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "gatewayhostnameconfiguration.GatewayHostnameConfigurationClient", "GetEntityTag", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "gatewayhostnameconfiguration.GatewayHostnameConfigurationClient", "GetEntityTag", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetEntityTag(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "gatewayhostnameconfiguration.GatewayHostnameConfigurationClient", "GetEntityTag", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetEntityTag prepares the GetEntityTag request. -func (c GatewayHostnameConfigurationClient) preparerForGetEntityTag(ctx context.Context, id HostnameConfigurationId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsHead(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetEntityTag handles the response to the GetEntityTag request. The method always -// closes the http.Response Body. -func (c GatewayHostnameConfigurationClient) responderForGetEntityTag(resp *http.Response) (result GetEntityTagOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2022-08-01/gatewayhostnameconfiguration/method_listbyservice.go b/resource-manager/apimanagement/2022-08-01/gatewayhostnameconfiguration/method_listbyservice.go new file mode 100644 index 00000000000..6842b2c14d3 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/gatewayhostnameconfiguration/method_listbyservice.go @@ -0,0 +1,125 @@ +package gatewayhostnameconfiguration + +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 ListByServiceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]GatewayHostnameConfigurationContract +} + +type ListByServiceCompleteResult struct { + Items []GatewayHostnameConfigurationContract +} + +type ListByServiceOperationOptions struct { + Filter *string + Skip *int64 + Top *int64 +} + +func DefaultListByServiceOperationOptions() ListByServiceOperationOptions { + return ListByServiceOperationOptions{} +} + +func (o ListByServiceOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListByServiceOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListByServiceOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.Skip != nil { + out.Append("$skip", fmt.Sprintf("%v", *o.Skip)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +// ListByService ... +func (c GatewayHostnameConfigurationClient) ListByService(ctx context.Context, id GatewayId, options ListByServiceOperationOptions) (result ListByServiceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/hostnameConfigurations", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]GatewayHostnameConfigurationContract `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByServiceComplete retrieves all the results into a single object +func (c GatewayHostnameConfigurationClient) ListByServiceComplete(ctx context.Context, id GatewayId, options ListByServiceOperationOptions) (ListByServiceCompleteResult, error) { + return c.ListByServiceCompleteMatchingPredicate(ctx, id, options, GatewayHostnameConfigurationContractOperationPredicate{}) +} + +// ListByServiceCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c GatewayHostnameConfigurationClient) ListByServiceCompleteMatchingPredicate(ctx context.Context, id GatewayId, options ListByServiceOperationOptions, predicate GatewayHostnameConfigurationContractOperationPredicate) (result ListByServiceCompleteResult, err error) { + items := make([]GatewayHostnameConfigurationContract, 0) + + resp, err := c.ListByService(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByServiceCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/apimanagement/2022-08-01/gatewayhostnameconfiguration/method_listbyservice_autorest.go b/resource-manager/apimanagement/2022-08-01/gatewayhostnameconfiguration/method_listbyservice_autorest.go deleted file mode 100644 index ce7ed9c80f0..00000000000 --- a/resource-manager/apimanagement/2022-08-01/gatewayhostnameconfiguration/method_listbyservice_autorest.go +++ /dev/null @@ -1,225 +0,0 @@ -package gatewayhostnameconfiguration - -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 ListByServiceOperationResponse struct { - HttpResponse *http.Response - Model *[]GatewayHostnameConfigurationContract - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListByServiceOperationResponse, error) -} - -type ListByServiceCompleteResult struct { - Items []GatewayHostnameConfigurationContract -} - -func (r ListByServiceOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListByServiceOperationResponse) LoadMore(ctx context.Context) (resp ListByServiceOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -type ListByServiceOperationOptions struct { - Filter *string - Skip *int64 - Top *int64 -} - -func DefaultListByServiceOperationOptions() ListByServiceOperationOptions { - return ListByServiceOperationOptions{} -} - -func (o ListByServiceOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o ListByServiceOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Filter != nil { - out["$filter"] = *o.Filter - } - - if o.Skip != nil { - out["$skip"] = *o.Skip - } - - if o.Top != nil { - out["$top"] = *o.Top - } - - return out -} - -// ListByService ... -func (c GatewayHostnameConfigurationClient) ListByService(ctx context.Context, id GatewayId, options ListByServiceOperationOptions) (resp ListByServiceOperationResponse, err error) { - req, err := c.preparerForListByService(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "gatewayhostnameconfiguration.GatewayHostnameConfigurationClient", "ListByService", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "gatewayhostnameconfiguration.GatewayHostnameConfigurationClient", "ListByService", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListByService(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "gatewayhostnameconfiguration.GatewayHostnameConfigurationClient", "ListByService", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListByService prepares the ListByService request. -func (c GatewayHostnameConfigurationClient) preparerForListByService(ctx context.Context, id GatewayId, options ListByServiceOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/hostnameConfigurations", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListByServiceWithNextLink prepares the ListByService request with the given nextLink token. -func (c GatewayHostnameConfigurationClient) preparerForListByServiceWithNextLink(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)) -} - -// responderForListByService handles the response to the ListByService request. The method always -// closes the http.Response Body. -func (c GatewayHostnameConfigurationClient) responderForListByService(resp *http.Response) (result ListByServiceOperationResponse, err error) { - type page struct { - Values []GatewayHostnameConfigurationContract `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 ListByServiceOperationResponse, err error) { - req, err := c.preparerForListByServiceWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "gatewayhostnameconfiguration.GatewayHostnameConfigurationClient", "ListByService", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "gatewayhostnameconfiguration.GatewayHostnameConfigurationClient", "ListByService", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByService(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "gatewayhostnameconfiguration.GatewayHostnameConfigurationClient", "ListByService", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListByServiceComplete retrieves all of the results into a single object -func (c GatewayHostnameConfigurationClient) ListByServiceComplete(ctx context.Context, id GatewayId, options ListByServiceOperationOptions) (ListByServiceCompleteResult, error) { - return c.ListByServiceCompleteMatchingPredicate(ctx, id, options, GatewayHostnameConfigurationContractOperationPredicate{}) -} - -// ListByServiceCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c GatewayHostnameConfigurationClient) ListByServiceCompleteMatchingPredicate(ctx context.Context, id GatewayId, options ListByServiceOperationOptions, predicate GatewayHostnameConfigurationContractOperationPredicate) (resp ListByServiceCompleteResult, err error) { - items := make([]GatewayHostnameConfigurationContract, 0) - - page, err := c.ListByService(ctx, id, options) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListByServiceCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/apimanagement/2022-08-01/gatewaylistkeys/client.go b/resource-manager/apimanagement/2022-08-01/gatewaylistkeys/client.go index 01978a51eaa..fb1f3f83c7a 100644 --- a/resource-manager/apimanagement/2022-08-01/gatewaylistkeys/client.go +++ b/resource-manager/apimanagement/2022-08-01/gatewaylistkeys/client.go @@ -1,18 +1,26 @@ package gatewaylistkeys -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 GatewayListKeysClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewGatewayListKeysClientWithBaseURI(endpoint string) GatewayListKeysClient { - return GatewayListKeysClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewGatewayListKeysClientWithBaseURI(api environments.Api) (*GatewayListKeysClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "gatewaylistkeys", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating GatewayListKeysClient: %+v", err) } + + return &GatewayListKeysClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2022-08-01/gatewaylistkeys/method_gatewaylistkeys.go b/resource-manager/apimanagement/2022-08-01/gatewaylistkeys/method_gatewaylistkeys.go new file mode 100644 index 00000000000..8fc1104a3b3 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/gatewaylistkeys/method_gatewaylistkeys.go @@ -0,0 +1,52 @@ +package gatewaylistkeys + +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 GatewayListKeysOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *GatewayKeysContract +} + +// GatewayListKeys ... +func (c GatewayListKeysClient) GatewayListKeys(ctx context.Context, id GatewayId) (result GatewayListKeysOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/listKeys", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + if err = resp.Unmarshal(&result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2022-08-01/gatewaylistkeys/method_gatewaylistkeys_autorest.go b/resource-manager/apimanagement/2022-08-01/gatewaylistkeys/method_gatewaylistkeys_autorest.go deleted file mode 100644 index 3ad468fa9f9..00000000000 --- a/resource-manager/apimanagement/2022-08-01/gatewaylistkeys/method_gatewaylistkeys_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package gatewaylistkeys - -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 GatewayListKeysOperationResponse struct { - HttpResponse *http.Response - Model *GatewayKeysContract -} - -// GatewayListKeys ... -func (c GatewayListKeysClient) GatewayListKeys(ctx context.Context, id GatewayId) (result GatewayListKeysOperationResponse, err error) { - req, err := c.preparerForGatewayListKeys(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "gatewaylistkeys.GatewayListKeysClient", "GatewayListKeys", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "gatewaylistkeys.GatewayListKeysClient", "GatewayListKeys", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGatewayListKeys(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "gatewaylistkeys.GatewayListKeysClient", "GatewayListKeys", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGatewayListKeys prepares the GatewayListKeys request. -func (c GatewayListKeysClient) preparerForGatewayListKeys(ctx context.Context, id GatewayId) (*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/listKeys", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGatewayListKeys handles the response to the GatewayListKeys request. The method always -// closes the http.Response Body. -func (c GatewayListKeysClient) responderForGatewayListKeys(resp *http.Response) (result GatewayListKeysOperationResponse, 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/apimanagement/2022-08-01/gatewayregeneratekey/client.go b/resource-manager/apimanagement/2022-08-01/gatewayregeneratekey/client.go index 68eee704676..53b506f50c1 100644 --- a/resource-manager/apimanagement/2022-08-01/gatewayregeneratekey/client.go +++ b/resource-manager/apimanagement/2022-08-01/gatewayregeneratekey/client.go @@ -1,18 +1,26 @@ package gatewayregeneratekey -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 GatewayRegenerateKeyClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewGatewayRegenerateKeyClientWithBaseURI(endpoint string) GatewayRegenerateKeyClient { - return GatewayRegenerateKeyClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewGatewayRegenerateKeyClientWithBaseURI(api environments.Api) (*GatewayRegenerateKeyClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "gatewayregeneratekey", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating GatewayRegenerateKeyClient: %+v", err) } + + return &GatewayRegenerateKeyClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2022-08-01/gatewayregeneratekey/constants.go b/resource-manager/apimanagement/2022-08-01/gatewayregeneratekey/constants.go index e69fb786bb4..f8762636760 100644 --- a/resource-manager/apimanagement/2022-08-01/gatewayregeneratekey/constants.go +++ b/resource-manager/apimanagement/2022-08-01/gatewayregeneratekey/constants.go @@ -1,6 +1,10 @@ package gatewayregeneratekey -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 PossibleValuesForKeyType() []string { } } +func (s *KeyType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseKeyType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseKeyType(input string) (*KeyType, error) { vals := map[string]KeyType{ "primary": KeyTypePrimary, diff --git a/resource-manager/apimanagement/2022-08-01/gatewayregeneratekey/method_gatewayregeneratekey.go b/resource-manager/apimanagement/2022-08-01/gatewayregeneratekey/method_gatewayregeneratekey.go new file mode 100644 index 00000000000..8783e036af9 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/gatewayregeneratekey/method_gatewayregeneratekey.go @@ -0,0 +1,51 @@ +package gatewayregeneratekey + +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 GatewayRegenerateKeyOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// GatewayRegenerateKey ... +func (c GatewayRegenerateKeyClient) GatewayRegenerateKey(ctx context.Context, id GatewayId, input GatewayKeyRegenerationRequestContract) (result GatewayRegenerateKeyOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/regenerateKey", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2022-08-01/gatewayregeneratekey/method_gatewayregeneratekey_autorest.go b/resource-manager/apimanagement/2022-08-01/gatewayregeneratekey/method_gatewayregeneratekey_autorest.go deleted file mode 100644 index 944a561ab8b..00000000000 --- a/resource-manager/apimanagement/2022-08-01/gatewayregeneratekey/method_gatewayregeneratekey_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package gatewayregeneratekey - -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 GatewayRegenerateKeyOperationResponse struct { - HttpResponse *http.Response -} - -// GatewayRegenerateKey ... -func (c GatewayRegenerateKeyClient) GatewayRegenerateKey(ctx context.Context, id GatewayId, input GatewayKeyRegenerationRequestContract) (result GatewayRegenerateKeyOperationResponse, err error) { - req, err := c.preparerForGatewayRegenerateKey(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "gatewayregeneratekey.GatewayRegenerateKeyClient", "GatewayRegenerateKey", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "gatewayregeneratekey.GatewayRegenerateKeyClient", "GatewayRegenerateKey", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGatewayRegenerateKey(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "gatewayregeneratekey.GatewayRegenerateKeyClient", "GatewayRegenerateKey", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGatewayRegenerateKey prepares the GatewayRegenerateKey request. -func (c GatewayRegenerateKeyClient) preparerForGatewayRegenerateKey(ctx context.Context, id GatewayId, input GatewayKeyRegenerationRequestContract) (*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/regenerateKey", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGatewayRegenerateKey handles the response to the GatewayRegenerateKey request. The method always -// closes the http.Response Body. -func (c GatewayRegenerateKeyClient) responderForGatewayRegenerateKey(resp *http.Response) (result GatewayRegenerateKeyOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2022-08-01/graphqlapiresolver/client.go b/resource-manager/apimanagement/2022-08-01/graphqlapiresolver/client.go index dbfd2a175f4..5d12ac74c7b 100644 --- a/resource-manager/apimanagement/2022-08-01/graphqlapiresolver/client.go +++ b/resource-manager/apimanagement/2022-08-01/graphqlapiresolver/client.go @@ -1,18 +1,26 @@ package graphqlapiresolver -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 GraphQLApiResolverClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewGraphQLApiResolverClientWithBaseURI(endpoint string) GraphQLApiResolverClient { - return GraphQLApiResolverClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewGraphQLApiResolverClientWithBaseURI(api environments.Api) (*GraphQLApiResolverClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "graphqlapiresolver", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating GraphQLApiResolverClient: %+v", err) } + + return &GraphQLApiResolverClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2022-08-01/graphqlapiresolver/method_createorupdate.go b/resource-manager/apimanagement/2022-08-01/graphqlapiresolver/method_createorupdate.go new file mode 100644 index 00000000000..12e81075cb8 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/graphqlapiresolver/method_createorupdate.go @@ -0,0 +1,85 @@ +package graphqlapiresolver + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ResolverContract +} + +type CreateOrUpdateOperationOptions struct { + IfMatch *string +} + +func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { + return CreateOrUpdateOperationOptions{} +} + +func (o CreateOrUpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o CreateOrUpdateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o CreateOrUpdateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// CreateOrUpdate ... +func (c GraphQLApiResolverClient) CreateOrUpdate(ctx context.Context, id ResolverId, input ResolverContract, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + OptionsObject: options, + } + + 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/apimanagement/2022-08-01/graphqlapiresolver/method_createorupdate_autorest.go b/resource-manager/apimanagement/2022-08-01/graphqlapiresolver/method_createorupdate_autorest.go deleted file mode 100644 index 3c04d258ca6..00000000000 --- a/resource-manager/apimanagement/2022-08-01/graphqlapiresolver/method_createorupdate_autorest.go +++ /dev/null @@ -1,98 +0,0 @@ -package graphqlapiresolver - -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 *ResolverContract -} - -type CreateOrUpdateOperationOptions struct { - IfMatch *string -} - -func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { - return CreateOrUpdateOperationOptions{} -} - -func (o CreateOrUpdateOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o CreateOrUpdateOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// CreateOrUpdate ... -func (c GraphQLApiResolverClient) CreateOrUpdate(ctx context.Context, id ResolverId, input ResolverContract, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdate(ctx, id, input, options) - if err != nil { - err = autorest.NewErrorWithError(err, "graphqlapiresolver.GraphQLApiResolverClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "graphqlapiresolver.GraphQLApiResolverClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCreateOrUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "graphqlapiresolver.GraphQLApiResolverClient", "CreateOrUpdate", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCreateOrUpdate prepares the CreateOrUpdate request. -func (c GraphQLApiResolverClient) preparerForCreateOrUpdate(ctx context.Context, id ResolverId, input ResolverContract, options CreateOrUpdateOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - 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 GraphQLApiResolverClient) responderForCreateOrUpdate(resp *http.Response) (result CreateOrUpdateOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2022-08-01/graphqlapiresolver/method_delete.go b/resource-manager/apimanagement/2022-08-01/graphqlapiresolver/method_delete.go new file mode 100644 index 00000000000..8cc0fdc47a5 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/graphqlapiresolver/method_delete.go @@ -0,0 +1,76 @@ +package graphqlapiresolver + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +type DeleteOperationOptions struct { + IfMatch *string +} + +func DefaultDeleteOperationOptions() DeleteOperationOptions { + return DeleteOperationOptions{} +} + +func (o DeleteOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o DeleteOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o DeleteOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// Delete ... +func (c GraphQLApiResolverClient) Delete(ctx context.Context, id ResolverId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2022-08-01/graphqlapiresolver/method_delete_autorest.go b/resource-manager/apimanagement/2022-08-01/graphqlapiresolver/method_delete_autorest.go deleted file mode 100644 index 5e13100b737..00000000000 --- a/resource-manager/apimanagement/2022-08-01/graphqlapiresolver/method_delete_autorest.go +++ /dev/null @@ -1,95 +0,0 @@ -package graphqlapiresolver - -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 DeleteOperationResponse struct { - HttpResponse *http.Response -} - -type DeleteOperationOptions struct { - IfMatch *string -} - -func DefaultDeleteOperationOptions() DeleteOperationOptions { - return DeleteOperationOptions{} -} - -func (o DeleteOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o DeleteOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// Delete ... -func (c GraphQLApiResolverClient) Delete(ctx context.Context, id ResolverId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { - req, err := c.preparerForDelete(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "graphqlapiresolver.GraphQLApiResolverClient", "Delete", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "graphqlapiresolver.GraphQLApiResolverClient", "Delete", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForDelete(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "graphqlapiresolver.GraphQLApiResolverClient", "Delete", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForDelete prepares the Delete request. -func (c GraphQLApiResolverClient) preparerForDelete(ctx context.Context, id ResolverId, options DeleteOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForDelete handles the response to the Delete request. The method always -// closes the http.Response Body. -func (c GraphQLApiResolverClient) responderForDelete(resp *http.Response) (result DeleteOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2022-08-01/graphqlapiresolver/method_get.go b/resource-manager/apimanagement/2022-08-01/graphqlapiresolver/method_get.go new file mode 100644 index 00000000000..bf75697111f --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/graphqlapiresolver/method_get.go @@ -0,0 +1,51 @@ +package graphqlapiresolver + +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 *ResolverContract +} + +// Get ... +func (c GraphQLApiResolverClient) Get(ctx context.Context, id ResolverId) (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/apimanagement/2022-08-01/graphqlapiresolver/method_get_autorest.go b/resource-manager/apimanagement/2022-08-01/graphqlapiresolver/method_get_autorest.go deleted file mode 100644 index 38d04eb19b8..00000000000 --- a/resource-manager/apimanagement/2022-08-01/graphqlapiresolver/method_get_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package graphqlapiresolver - -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 *ResolverContract -} - -// Get ... -func (c GraphQLApiResolverClient) Get(ctx context.Context, id ResolverId) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "graphqlapiresolver.GraphQLApiResolverClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "graphqlapiresolver.GraphQLApiResolverClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "graphqlapiresolver.GraphQLApiResolverClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c GraphQLApiResolverClient) preparerForGet(ctx context.Context, id ResolverId) (*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 GraphQLApiResolverClient) 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/apimanagement/2022-08-01/graphqlapiresolver/method_getentitytag.go b/resource-manager/apimanagement/2022-08-01/graphqlapiresolver/method_getentitytag.go new file mode 100644 index 00000000000..8b234a108a8 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/graphqlapiresolver/method_getentitytag.go @@ -0,0 +1,46 @@ +package graphqlapiresolver + +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 GetEntityTagOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// GetEntityTag ... +func (c GraphQLApiResolverClient) GetEntityTag(ctx context.Context, id ResolverId) (result GetEntityTagOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodHead, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2022-08-01/graphqlapiresolver/method_getentitytag_autorest.go b/resource-manager/apimanagement/2022-08-01/graphqlapiresolver/method_getentitytag_autorest.go deleted file mode 100644 index 5776112824d..00000000000 --- a/resource-manager/apimanagement/2022-08-01/graphqlapiresolver/method_getentitytag_autorest.go +++ /dev/null @@ -1,66 +0,0 @@ -package graphqlapiresolver - -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 GetEntityTagOperationResponse struct { - HttpResponse *http.Response -} - -// GetEntityTag ... -func (c GraphQLApiResolverClient) GetEntityTag(ctx context.Context, id ResolverId) (result GetEntityTagOperationResponse, err error) { - req, err := c.preparerForGetEntityTag(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "graphqlapiresolver.GraphQLApiResolverClient", "GetEntityTag", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "graphqlapiresolver.GraphQLApiResolverClient", "GetEntityTag", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetEntityTag(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "graphqlapiresolver.GraphQLApiResolverClient", "GetEntityTag", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetEntityTag prepares the GetEntityTag request. -func (c GraphQLApiResolverClient) preparerForGetEntityTag(ctx context.Context, id ResolverId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsHead(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetEntityTag handles the response to the GetEntityTag request. The method always -// closes the http.Response Body. -func (c GraphQLApiResolverClient) responderForGetEntityTag(resp *http.Response) (result GetEntityTagOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2022-08-01/graphqlapiresolver/method_listbyapi.go b/resource-manager/apimanagement/2022-08-01/graphqlapiresolver/method_listbyapi.go new file mode 100644 index 00000000000..2b2b84c7958 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/graphqlapiresolver/method_listbyapi.go @@ -0,0 +1,125 @@ +package graphqlapiresolver + +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 ListByApiOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ResolverContract +} + +type ListByApiCompleteResult struct { + Items []ResolverContract +} + +type ListByApiOperationOptions struct { + Filter *string + Skip *int64 + Top *int64 +} + +func DefaultListByApiOperationOptions() ListByApiOperationOptions { + return ListByApiOperationOptions{} +} + +func (o ListByApiOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListByApiOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListByApiOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.Skip != nil { + out.Append("$skip", fmt.Sprintf("%v", *o.Skip)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +// ListByApi ... +func (c GraphQLApiResolverClient) ListByApi(ctx context.Context, id ApiId, options ListByApiOperationOptions) (result ListByApiOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/resolvers", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ResolverContract `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByApiComplete retrieves all the results into a single object +func (c GraphQLApiResolverClient) ListByApiComplete(ctx context.Context, id ApiId, options ListByApiOperationOptions) (ListByApiCompleteResult, error) { + return c.ListByApiCompleteMatchingPredicate(ctx, id, options, ResolverContractOperationPredicate{}) +} + +// ListByApiCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c GraphQLApiResolverClient) ListByApiCompleteMatchingPredicate(ctx context.Context, id ApiId, options ListByApiOperationOptions, predicate ResolverContractOperationPredicate) (result ListByApiCompleteResult, err error) { + items := make([]ResolverContract, 0) + + resp, err := c.ListByApi(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByApiCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/apimanagement/2022-08-01/graphqlapiresolver/method_listbyapi_autorest.go b/resource-manager/apimanagement/2022-08-01/graphqlapiresolver/method_listbyapi_autorest.go deleted file mode 100644 index 737fd0e185f..00000000000 --- a/resource-manager/apimanagement/2022-08-01/graphqlapiresolver/method_listbyapi_autorest.go +++ /dev/null @@ -1,225 +0,0 @@ -package graphqlapiresolver - -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 ListByApiOperationResponse struct { - HttpResponse *http.Response - Model *[]ResolverContract - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListByApiOperationResponse, error) -} - -type ListByApiCompleteResult struct { - Items []ResolverContract -} - -func (r ListByApiOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListByApiOperationResponse) LoadMore(ctx context.Context) (resp ListByApiOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -type ListByApiOperationOptions struct { - Filter *string - Skip *int64 - Top *int64 -} - -func DefaultListByApiOperationOptions() ListByApiOperationOptions { - return ListByApiOperationOptions{} -} - -func (o ListByApiOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o ListByApiOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Filter != nil { - out["$filter"] = *o.Filter - } - - if o.Skip != nil { - out["$skip"] = *o.Skip - } - - if o.Top != nil { - out["$top"] = *o.Top - } - - return out -} - -// ListByApi ... -func (c GraphQLApiResolverClient) ListByApi(ctx context.Context, id ApiId, options ListByApiOperationOptions) (resp ListByApiOperationResponse, err error) { - req, err := c.preparerForListByApi(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "graphqlapiresolver.GraphQLApiResolverClient", "ListByApi", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "graphqlapiresolver.GraphQLApiResolverClient", "ListByApi", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListByApi(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "graphqlapiresolver.GraphQLApiResolverClient", "ListByApi", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListByApi prepares the ListByApi request. -func (c GraphQLApiResolverClient) preparerForListByApi(ctx context.Context, id ApiId, options ListByApiOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/resolvers", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListByApiWithNextLink prepares the ListByApi request with the given nextLink token. -func (c GraphQLApiResolverClient) preparerForListByApiWithNextLink(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)) -} - -// responderForListByApi handles the response to the ListByApi request. The method always -// closes the http.Response Body. -func (c GraphQLApiResolverClient) responderForListByApi(resp *http.Response) (result ListByApiOperationResponse, err error) { - type page struct { - Values []ResolverContract `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 ListByApiOperationResponse, err error) { - req, err := c.preparerForListByApiWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "graphqlapiresolver.GraphQLApiResolverClient", "ListByApi", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "graphqlapiresolver.GraphQLApiResolverClient", "ListByApi", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByApi(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "graphqlapiresolver.GraphQLApiResolverClient", "ListByApi", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListByApiComplete retrieves all of the results into a single object -func (c GraphQLApiResolverClient) ListByApiComplete(ctx context.Context, id ApiId, options ListByApiOperationOptions) (ListByApiCompleteResult, error) { - return c.ListByApiCompleteMatchingPredicate(ctx, id, options, ResolverContractOperationPredicate{}) -} - -// ListByApiCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c GraphQLApiResolverClient) ListByApiCompleteMatchingPredicate(ctx context.Context, id ApiId, options ListByApiOperationOptions, predicate ResolverContractOperationPredicate) (resp ListByApiCompleteResult, err error) { - items := make([]ResolverContract, 0) - - page, err := c.ListByApi(ctx, id, options) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListByApiCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/apimanagement/2022-08-01/graphqlapiresolver/method_update.go b/resource-manager/apimanagement/2022-08-01/graphqlapiresolver/method_update.go new file mode 100644 index 00000000000..e7fdfb45c02 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/graphqlapiresolver/method_update.go @@ -0,0 +1,84 @@ +package graphqlapiresolver + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ResolverContract +} + +type UpdateOperationOptions struct { + IfMatch *string +} + +func DefaultUpdateOperationOptions() UpdateOperationOptions { + return UpdateOperationOptions{} +} + +func (o UpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o UpdateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o UpdateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// Update ... +func (c GraphQLApiResolverClient) Update(ctx context.Context, id ResolverId, input ResolverUpdateContract, options UpdateOperationOptions) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + OptionsObject: options, + } + + 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/apimanagement/2022-08-01/graphqlapiresolver/method_update_autorest.go b/resource-manager/apimanagement/2022-08-01/graphqlapiresolver/method_update_autorest.go deleted file mode 100644 index 2efaa46ef89..00000000000 --- a/resource-manager/apimanagement/2022-08-01/graphqlapiresolver/method_update_autorest.go +++ /dev/null @@ -1,98 +0,0 @@ -package graphqlapiresolver - -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 *ResolverContract -} - -type UpdateOperationOptions struct { - IfMatch *string -} - -func DefaultUpdateOperationOptions() UpdateOperationOptions { - return UpdateOperationOptions{} -} - -func (o UpdateOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o UpdateOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// Update ... -func (c GraphQLApiResolverClient) Update(ctx context.Context, id ResolverId, input ResolverUpdateContract, options UpdateOperationOptions) (result UpdateOperationResponse, err error) { - req, err := c.preparerForUpdate(ctx, id, input, options) - if err != nil { - err = autorest.NewErrorWithError(err, "graphqlapiresolver.GraphQLApiResolverClient", "Update", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "graphqlapiresolver.GraphQLApiResolverClient", "Update", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "graphqlapiresolver.GraphQLApiResolverClient", "Update", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForUpdate prepares the Update request. -func (c GraphQLApiResolverClient) preparerForUpdate(ctx context.Context, id ResolverId, input ResolverUpdateContract, options UpdateOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPatch(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - 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 GraphQLApiResolverClient) 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/apimanagement/2022-08-01/graphqlapiresolverpolicy/client.go b/resource-manager/apimanagement/2022-08-01/graphqlapiresolverpolicy/client.go index e2de745a777..0c33bcc03ee 100644 --- a/resource-manager/apimanagement/2022-08-01/graphqlapiresolverpolicy/client.go +++ b/resource-manager/apimanagement/2022-08-01/graphqlapiresolverpolicy/client.go @@ -1,18 +1,26 @@ package graphqlapiresolverpolicy -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 GraphQLApiResolverPolicyClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewGraphQLApiResolverPolicyClientWithBaseURI(endpoint string) GraphQLApiResolverPolicyClient { - return GraphQLApiResolverPolicyClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewGraphQLApiResolverPolicyClientWithBaseURI(api environments.Api) (*GraphQLApiResolverPolicyClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "graphqlapiresolverpolicy", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating GraphQLApiResolverPolicyClient: %+v", err) } + + return &GraphQLApiResolverPolicyClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2022-08-01/graphqlapiresolverpolicy/constants.go b/resource-manager/apimanagement/2022-08-01/graphqlapiresolverpolicy/constants.go index c234bd2e482..dac91618621 100644 --- a/resource-manager/apimanagement/2022-08-01/graphqlapiresolverpolicy/constants.go +++ b/resource-manager/apimanagement/2022-08-01/graphqlapiresolverpolicy/constants.go @@ -1,6 +1,10 @@ package graphqlapiresolverpolicy -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 PossibleValuesForPolicyContentFormat() []string { } } +func (s *PolicyContentFormat) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePolicyContentFormat(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parsePolicyContentFormat(input string) (*PolicyContentFormat, error) { vals := map[string]PolicyContentFormat{ "rawxml": PolicyContentFormatRawxml, @@ -53,6 +70,19 @@ func PossibleValuesForPolicyExportFormat() []string { } } +func (s *PolicyExportFormat) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePolicyExportFormat(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parsePolicyExportFormat(input string) (*PolicyExportFormat, error) { vals := map[string]PolicyExportFormat{ "rawxml": PolicyExportFormatRawxml, diff --git a/resource-manager/apimanagement/2022-08-01/graphqlapiresolverpolicy/method_createorupdate.go b/resource-manager/apimanagement/2022-08-01/graphqlapiresolverpolicy/method_createorupdate.go new file mode 100644 index 00000000000..5ec63ae65a4 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/graphqlapiresolverpolicy/method_createorupdate.go @@ -0,0 +1,85 @@ +package graphqlapiresolverpolicy + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PolicyContract +} + +type CreateOrUpdateOperationOptions struct { + IfMatch *string +} + +func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { + return CreateOrUpdateOperationOptions{} +} + +func (o CreateOrUpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o CreateOrUpdateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o CreateOrUpdateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// CreateOrUpdate ... +func (c GraphQLApiResolverPolicyClient) CreateOrUpdate(ctx context.Context, id ResolverId, input PolicyContract, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/policies/policy", id.ID()), + OptionsObject: options, + } + + 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/apimanagement/2022-08-01/graphqlapiresolverpolicy/method_createorupdate_autorest.go b/resource-manager/apimanagement/2022-08-01/graphqlapiresolverpolicy/method_createorupdate_autorest.go deleted file mode 100644 index b0684a787af..00000000000 --- a/resource-manager/apimanagement/2022-08-01/graphqlapiresolverpolicy/method_createorupdate_autorest.go +++ /dev/null @@ -1,99 +0,0 @@ -package graphqlapiresolverpolicy - -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 CreateOrUpdateOperationResponse struct { - HttpResponse *http.Response - Model *PolicyContract -} - -type CreateOrUpdateOperationOptions struct { - IfMatch *string -} - -func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { - return CreateOrUpdateOperationOptions{} -} - -func (o CreateOrUpdateOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o CreateOrUpdateOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// CreateOrUpdate ... -func (c GraphQLApiResolverPolicyClient) CreateOrUpdate(ctx context.Context, id ResolverId, input PolicyContract, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdate(ctx, id, input, options) - if err != nil { - err = autorest.NewErrorWithError(err, "graphqlapiresolverpolicy.GraphQLApiResolverPolicyClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "graphqlapiresolverpolicy.GraphQLApiResolverPolicyClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCreateOrUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "graphqlapiresolverpolicy.GraphQLApiResolverPolicyClient", "CreateOrUpdate", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCreateOrUpdate prepares the CreateOrUpdate request. -func (c GraphQLApiResolverPolicyClient) preparerForCreateOrUpdate(ctx context.Context, id ResolverId, input PolicyContract, options CreateOrUpdateOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/policies/policy", 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 GraphQLApiResolverPolicyClient) responderForCreateOrUpdate(resp *http.Response) (result CreateOrUpdateOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2022-08-01/graphqlapiresolverpolicy/method_delete.go b/resource-manager/apimanagement/2022-08-01/graphqlapiresolverpolicy/method_delete.go new file mode 100644 index 00000000000..5e547dd0eb1 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/graphqlapiresolverpolicy/method_delete.go @@ -0,0 +1,76 @@ +package graphqlapiresolverpolicy + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +type DeleteOperationOptions struct { + IfMatch *string +} + +func DefaultDeleteOperationOptions() DeleteOperationOptions { + return DeleteOperationOptions{} +} + +func (o DeleteOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o DeleteOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o DeleteOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// Delete ... +func (c GraphQLApiResolverPolicyClient) Delete(ctx context.Context, id ResolverId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: fmt.Sprintf("%s/policies/policy", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2022-08-01/graphqlapiresolverpolicy/method_delete_autorest.go b/resource-manager/apimanagement/2022-08-01/graphqlapiresolverpolicy/method_delete_autorest.go deleted file mode 100644 index 97c2c5cc21d..00000000000 --- a/resource-manager/apimanagement/2022-08-01/graphqlapiresolverpolicy/method_delete_autorest.go +++ /dev/null @@ -1,96 +0,0 @@ -package graphqlapiresolverpolicy - -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 DeleteOperationResponse struct { - HttpResponse *http.Response -} - -type DeleteOperationOptions struct { - IfMatch *string -} - -func DefaultDeleteOperationOptions() DeleteOperationOptions { - return DeleteOperationOptions{} -} - -func (o DeleteOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o DeleteOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// Delete ... -func (c GraphQLApiResolverPolicyClient) Delete(ctx context.Context, id ResolverId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { - req, err := c.preparerForDelete(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "graphqlapiresolverpolicy.GraphQLApiResolverPolicyClient", "Delete", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "graphqlapiresolverpolicy.GraphQLApiResolverPolicyClient", "Delete", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForDelete(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "graphqlapiresolverpolicy.GraphQLApiResolverPolicyClient", "Delete", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForDelete prepares the Delete request. -func (c GraphQLApiResolverPolicyClient) preparerForDelete(ctx context.Context, id ResolverId, options DeleteOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/policies/policy", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForDelete handles the response to the Delete request. The method always -// closes the http.Response Body. -func (c GraphQLApiResolverPolicyClient) responderForDelete(resp *http.Response) (result DeleteOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2022-08-01/graphqlapiresolverpolicy/method_get.go b/resource-manager/apimanagement/2022-08-01/graphqlapiresolverpolicy/method_get.go new file mode 100644 index 00000000000..ceda2268db8 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/graphqlapiresolverpolicy/method_get.go @@ -0,0 +1,80 @@ +package graphqlapiresolverpolicy + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PolicyContract +} + +type GetOperationOptions struct { + Format *PolicyExportFormat +} + +func DefaultGetOperationOptions() GetOperationOptions { + return GetOperationOptions{} +} + +func (o GetOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o GetOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o GetOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Format != nil { + out.Append("format", fmt.Sprintf("%v", *o.Format)) + } + return &out +} + +// Get ... +func (c GraphQLApiResolverPolicyClient) Get(ctx context.Context, id ResolverId, options GetOperationOptions) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/policies/policy", id.ID()), + OptionsObject: options, + } + + 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/apimanagement/2022-08-01/graphqlapiresolverpolicy/method_get_autorest.go b/resource-manager/apimanagement/2022-08-01/graphqlapiresolverpolicy/method_get_autorest.go deleted file mode 100644 index d65ead5108c..00000000000 --- a/resource-manager/apimanagement/2022-08-01/graphqlapiresolverpolicy/method_get_autorest.go +++ /dev/null @@ -1,98 +0,0 @@ -package graphqlapiresolverpolicy - -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 GetOperationResponse struct { - HttpResponse *http.Response - Model *PolicyContract -} - -type GetOperationOptions struct { - Format *PolicyExportFormat -} - -func DefaultGetOperationOptions() GetOperationOptions { - return GetOperationOptions{} -} - -func (o GetOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o GetOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Format != nil { - out["format"] = *o.Format - } - - return out -} - -// Get ... -func (c GraphQLApiResolverPolicyClient) Get(ctx context.Context, id ResolverId, options GetOperationOptions) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "graphqlapiresolverpolicy.GraphQLApiResolverPolicyClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "graphqlapiresolverpolicy.GraphQLApiResolverPolicyClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "graphqlapiresolverpolicy.GraphQLApiResolverPolicyClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c GraphQLApiResolverPolicyClient) preparerForGet(ctx context.Context, id ResolverId, options GetOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/policies/policy", 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 GraphQLApiResolverPolicyClient) 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/apimanagement/2022-08-01/graphqlapiresolverpolicy/method_getentitytag.go b/resource-manager/apimanagement/2022-08-01/graphqlapiresolverpolicy/method_getentitytag.go new file mode 100644 index 00000000000..74dcf82b122 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/graphqlapiresolverpolicy/method_getentitytag.go @@ -0,0 +1,47 @@ +package graphqlapiresolverpolicy + +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 GetEntityTagOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// GetEntityTag ... +func (c GraphQLApiResolverPolicyClient) GetEntityTag(ctx context.Context, id ResolverId) (result GetEntityTagOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodHead, + Path: fmt.Sprintf("%s/policies/policy", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2022-08-01/graphqlapiresolverpolicy/method_getentitytag_autorest.go b/resource-manager/apimanagement/2022-08-01/graphqlapiresolverpolicy/method_getentitytag_autorest.go deleted file mode 100644 index 7fb3886277f..00000000000 --- a/resource-manager/apimanagement/2022-08-01/graphqlapiresolverpolicy/method_getentitytag_autorest.go +++ /dev/null @@ -1,67 +0,0 @@ -package graphqlapiresolverpolicy - -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 GetEntityTagOperationResponse struct { - HttpResponse *http.Response -} - -// GetEntityTag ... -func (c GraphQLApiResolverPolicyClient) GetEntityTag(ctx context.Context, id ResolverId) (result GetEntityTagOperationResponse, err error) { - req, err := c.preparerForGetEntityTag(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "graphqlapiresolverpolicy.GraphQLApiResolverPolicyClient", "GetEntityTag", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "graphqlapiresolverpolicy.GraphQLApiResolverPolicyClient", "GetEntityTag", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetEntityTag(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "graphqlapiresolverpolicy.GraphQLApiResolverPolicyClient", "GetEntityTag", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetEntityTag prepares the GetEntityTag request. -func (c GraphQLApiResolverPolicyClient) preparerForGetEntityTag(ctx context.Context, id ResolverId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsHead(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/policies/policy", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetEntityTag handles the response to the GetEntityTag request. The method always -// closes the http.Response Body. -func (c GraphQLApiResolverPolicyClient) responderForGetEntityTag(resp *http.Response) (result GetEntityTagOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2022-08-01/graphqlapiresolverpolicy/method_listbyresolver.go b/resource-manager/apimanagement/2022-08-01/graphqlapiresolverpolicy/method_listbyresolver.go new file mode 100644 index 00000000000..e9465a9790e --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/graphqlapiresolverpolicy/method_listbyresolver.go @@ -0,0 +1,89 @@ +package graphqlapiresolverpolicy + +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 ListByResolverOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]PolicyContract +} + +type ListByResolverCompleteResult struct { + Items []PolicyContract +} + +// ListByResolver ... +func (c GraphQLApiResolverPolicyClient) ListByResolver(ctx context.Context, id ResolverId) (result ListByResolverOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/policies", 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 *[]PolicyContract `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByResolverComplete retrieves all the results into a single object +func (c GraphQLApiResolverPolicyClient) ListByResolverComplete(ctx context.Context, id ResolverId) (ListByResolverCompleteResult, error) { + return c.ListByResolverCompleteMatchingPredicate(ctx, id, PolicyContractOperationPredicate{}) +} + +// ListByResolverCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c GraphQLApiResolverPolicyClient) ListByResolverCompleteMatchingPredicate(ctx context.Context, id ResolverId, predicate PolicyContractOperationPredicate) (result ListByResolverCompleteResult, err error) { + items := make([]PolicyContract, 0) + + resp, err := c.ListByResolver(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 = ListByResolverCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/apimanagement/2022-08-01/graphqlapiresolverpolicy/method_listbyresolver_autorest.go b/resource-manager/apimanagement/2022-08-01/graphqlapiresolverpolicy/method_listbyresolver_autorest.go deleted file mode 100644 index 8d4b2ce62f5..00000000000 --- a/resource-manager/apimanagement/2022-08-01/graphqlapiresolverpolicy/method_listbyresolver_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package graphqlapiresolverpolicy - -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 ListByResolverOperationResponse struct { - HttpResponse *http.Response - Model *[]PolicyContract - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListByResolverOperationResponse, error) -} - -type ListByResolverCompleteResult struct { - Items []PolicyContract -} - -func (r ListByResolverOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListByResolverOperationResponse) LoadMore(ctx context.Context) (resp ListByResolverOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListByResolver ... -func (c GraphQLApiResolverPolicyClient) ListByResolver(ctx context.Context, id ResolverId) (resp ListByResolverOperationResponse, err error) { - req, err := c.preparerForListByResolver(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "graphqlapiresolverpolicy.GraphQLApiResolverPolicyClient", "ListByResolver", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "graphqlapiresolverpolicy.GraphQLApiResolverPolicyClient", "ListByResolver", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListByResolver(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "graphqlapiresolverpolicy.GraphQLApiResolverPolicyClient", "ListByResolver", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListByResolver prepares the ListByResolver request. -func (c GraphQLApiResolverPolicyClient) preparerForListByResolver(ctx context.Context, id ResolverId) (*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/policies", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListByResolverWithNextLink prepares the ListByResolver request with the given nextLink token. -func (c GraphQLApiResolverPolicyClient) preparerForListByResolverWithNextLink(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)) -} - -// responderForListByResolver handles the response to the ListByResolver request. The method always -// closes the http.Response Body. -func (c GraphQLApiResolverPolicyClient) responderForListByResolver(resp *http.Response) (result ListByResolverOperationResponse, err error) { - type page struct { - Values []PolicyContract `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 ListByResolverOperationResponse, err error) { - req, err := c.preparerForListByResolverWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "graphqlapiresolverpolicy.GraphQLApiResolverPolicyClient", "ListByResolver", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "graphqlapiresolverpolicy.GraphQLApiResolverPolicyClient", "ListByResolver", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByResolver(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "graphqlapiresolverpolicy.GraphQLApiResolverPolicyClient", "ListByResolver", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListByResolverComplete retrieves all of the results into a single object -func (c GraphQLApiResolverPolicyClient) ListByResolverComplete(ctx context.Context, id ResolverId) (ListByResolverCompleteResult, error) { - return c.ListByResolverCompleteMatchingPredicate(ctx, id, PolicyContractOperationPredicate{}) -} - -// ListByResolverCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c GraphQLApiResolverPolicyClient) ListByResolverCompleteMatchingPredicate(ctx context.Context, id ResolverId, predicate PolicyContractOperationPredicate) (resp ListByResolverCompleteResult, err error) { - items := make([]PolicyContract, 0) - - page, err := c.ListByResolver(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 := ListByResolverCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/apimanagement/2022-08-01/group/client.go b/resource-manager/apimanagement/2022-08-01/group/client.go index 78b8515c749..8103ac936d5 100644 --- a/resource-manager/apimanagement/2022-08-01/group/client.go +++ b/resource-manager/apimanagement/2022-08-01/group/client.go @@ -1,18 +1,26 @@ package group -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 GroupClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewGroupClientWithBaseURI(endpoint string) GroupClient { - return GroupClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewGroupClientWithBaseURI(api environments.Api) (*GroupClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "group", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating GroupClient: %+v", err) } + + return &GroupClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2022-08-01/group/constants.go b/resource-manager/apimanagement/2022-08-01/group/constants.go index a4fc43f47e7..1cda5dadcaf 100644 --- a/resource-manager/apimanagement/2022-08-01/group/constants.go +++ b/resource-manager/apimanagement/2022-08-01/group/constants.go @@ -1,6 +1,10 @@ package group -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 PossibleValuesForGroupType() []string { } } +func (s *GroupType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseGroupType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseGroupType(input string) (*GroupType, error) { vals := map[string]GroupType{ "custom": GroupTypeCustom, diff --git a/resource-manager/apimanagement/2022-08-01/group/method_createorupdate.go b/resource-manager/apimanagement/2022-08-01/group/method_createorupdate.go new file mode 100644 index 00000000000..c7c3873d667 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/group/method_createorupdate.go @@ -0,0 +1,85 @@ +package group + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *GroupContract +} + +type CreateOrUpdateOperationOptions struct { + IfMatch *string +} + +func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { + return CreateOrUpdateOperationOptions{} +} + +func (o CreateOrUpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o CreateOrUpdateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o CreateOrUpdateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// CreateOrUpdate ... +func (c GroupClient) CreateOrUpdate(ctx context.Context, id GroupId, input GroupCreateParameters, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + OptionsObject: options, + } + + 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/apimanagement/2022-08-01/group/method_createorupdate_autorest.go b/resource-manager/apimanagement/2022-08-01/group/method_createorupdate_autorest.go deleted file mode 100644 index 17bbc0cae9b..00000000000 --- a/resource-manager/apimanagement/2022-08-01/group/method_createorupdate_autorest.go +++ /dev/null @@ -1,98 +0,0 @@ -package group - -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 *GroupContract -} - -type CreateOrUpdateOperationOptions struct { - IfMatch *string -} - -func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { - return CreateOrUpdateOperationOptions{} -} - -func (o CreateOrUpdateOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o CreateOrUpdateOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// CreateOrUpdate ... -func (c GroupClient) CreateOrUpdate(ctx context.Context, id GroupId, input GroupCreateParameters, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdate(ctx, id, input, options) - if err != nil { - err = autorest.NewErrorWithError(err, "group.GroupClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "group.GroupClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCreateOrUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "group.GroupClient", "CreateOrUpdate", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCreateOrUpdate prepares the CreateOrUpdate request. -func (c GroupClient) preparerForCreateOrUpdate(ctx context.Context, id GroupId, input GroupCreateParameters, options CreateOrUpdateOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - 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 GroupClient) responderForCreateOrUpdate(resp *http.Response) (result CreateOrUpdateOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2022-08-01/group/method_delete.go b/resource-manager/apimanagement/2022-08-01/group/method_delete.go new file mode 100644 index 00000000000..8bd332e45a2 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/group/method_delete.go @@ -0,0 +1,76 @@ +package group + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +type DeleteOperationOptions struct { + IfMatch *string +} + +func DefaultDeleteOperationOptions() DeleteOperationOptions { + return DeleteOperationOptions{} +} + +func (o DeleteOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o DeleteOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o DeleteOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// Delete ... +func (c GroupClient) Delete(ctx context.Context, id GroupId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2022-08-01/group/method_delete_autorest.go b/resource-manager/apimanagement/2022-08-01/group/method_delete_autorest.go deleted file mode 100644 index 9abfbd05611..00000000000 --- a/resource-manager/apimanagement/2022-08-01/group/method_delete_autorest.go +++ /dev/null @@ -1,95 +0,0 @@ -package group - -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 DeleteOperationResponse struct { - HttpResponse *http.Response -} - -type DeleteOperationOptions struct { - IfMatch *string -} - -func DefaultDeleteOperationOptions() DeleteOperationOptions { - return DeleteOperationOptions{} -} - -func (o DeleteOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o DeleteOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// Delete ... -func (c GroupClient) Delete(ctx context.Context, id GroupId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { - req, err := c.preparerForDelete(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "group.GroupClient", "Delete", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "group.GroupClient", "Delete", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForDelete(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "group.GroupClient", "Delete", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForDelete prepares the Delete request. -func (c GroupClient) preparerForDelete(ctx context.Context, id GroupId, options DeleteOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForDelete handles the response to the Delete request. The method always -// closes the http.Response Body. -func (c GroupClient) responderForDelete(resp *http.Response) (result DeleteOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2022-08-01/group/method_get.go b/resource-manager/apimanagement/2022-08-01/group/method_get.go new file mode 100644 index 00000000000..4dbbc0759e2 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/group/method_get.go @@ -0,0 +1,51 @@ +package group + +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 *GroupContract +} + +// Get ... +func (c GroupClient) Get(ctx context.Context, id GroupId) (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/apimanagement/2022-08-01/group/method_get_autorest.go b/resource-manager/apimanagement/2022-08-01/group/method_get_autorest.go deleted file mode 100644 index bb3e3b2d619..00000000000 --- a/resource-manager/apimanagement/2022-08-01/group/method_get_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package group - -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 *GroupContract -} - -// Get ... -func (c GroupClient) Get(ctx context.Context, id GroupId) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "group.GroupClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "group.GroupClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "group.GroupClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c GroupClient) preparerForGet(ctx context.Context, id GroupId) (*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 GroupClient) 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/apimanagement/2022-08-01/group/method_getentitytag.go b/resource-manager/apimanagement/2022-08-01/group/method_getentitytag.go new file mode 100644 index 00000000000..e6ee5a9ba2d --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/group/method_getentitytag.go @@ -0,0 +1,46 @@ +package group + +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 GetEntityTagOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// GetEntityTag ... +func (c GroupClient) GetEntityTag(ctx context.Context, id GroupId) (result GetEntityTagOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodHead, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2022-08-01/group/method_getentitytag_autorest.go b/resource-manager/apimanagement/2022-08-01/group/method_getentitytag_autorest.go deleted file mode 100644 index 3dca8de39a0..00000000000 --- a/resource-manager/apimanagement/2022-08-01/group/method_getentitytag_autorest.go +++ /dev/null @@ -1,66 +0,0 @@ -package group - -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 GetEntityTagOperationResponse struct { - HttpResponse *http.Response -} - -// GetEntityTag ... -func (c GroupClient) GetEntityTag(ctx context.Context, id GroupId) (result GetEntityTagOperationResponse, err error) { - req, err := c.preparerForGetEntityTag(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "group.GroupClient", "GetEntityTag", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "group.GroupClient", "GetEntityTag", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetEntityTag(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "group.GroupClient", "GetEntityTag", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetEntityTag prepares the GetEntityTag request. -func (c GroupClient) preparerForGetEntityTag(ctx context.Context, id GroupId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsHead(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetEntityTag handles the response to the GetEntityTag request. The method always -// closes the http.Response Body. -func (c GroupClient) responderForGetEntityTag(resp *http.Response) (result GetEntityTagOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2022-08-01/group/method_listbyservice.go b/resource-manager/apimanagement/2022-08-01/group/method_listbyservice.go new file mode 100644 index 00000000000..080778877db --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/group/method_listbyservice.go @@ -0,0 +1,125 @@ +package group + +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 ListByServiceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]GroupContract +} + +type ListByServiceCompleteResult struct { + Items []GroupContract +} + +type ListByServiceOperationOptions struct { + Filter *string + Skip *int64 + Top *int64 +} + +func DefaultListByServiceOperationOptions() ListByServiceOperationOptions { + return ListByServiceOperationOptions{} +} + +func (o ListByServiceOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListByServiceOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListByServiceOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.Skip != nil { + out.Append("$skip", fmt.Sprintf("%v", *o.Skip)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +// ListByService ... +func (c GroupClient) ListByService(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (result ListByServiceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/groups", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]GroupContract `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByServiceComplete retrieves all the results into a single object +func (c GroupClient) ListByServiceComplete(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (ListByServiceCompleteResult, error) { + return c.ListByServiceCompleteMatchingPredicate(ctx, id, options, GroupContractOperationPredicate{}) +} + +// ListByServiceCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c GroupClient) ListByServiceCompleteMatchingPredicate(ctx context.Context, id ServiceId, options ListByServiceOperationOptions, predicate GroupContractOperationPredicate) (result ListByServiceCompleteResult, err error) { + items := make([]GroupContract, 0) + + resp, err := c.ListByService(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByServiceCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/apimanagement/2022-08-01/group/method_listbyservice_autorest.go b/resource-manager/apimanagement/2022-08-01/group/method_listbyservice_autorest.go deleted file mode 100644 index f2981bb97a5..00000000000 --- a/resource-manager/apimanagement/2022-08-01/group/method_listbyservice_autorest.go +++ /dev/null @@ -1,225 +0,0 @@ -package group - -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 ListByServiceOperationResponse struct { - HttpResponse *http.Response - Model *[]GroupContract - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListByServiceOperationResponse, error) -} - -type ListByServiceCompleteResult struct { - Items []GroupContract -} - -func (r ListByServiceOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListByServiceOperationResponse) LoadMore(ctx context.Context) (resp ListByServiceOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -type ListByServiceOperationOptions struct { - Filter *string - Skip *int64 - Top *int64 -} - -func DefaultListByServiceOperationOptions() ListByServiceOperationOptions { - return ListByServiceOperationOptions{} -} - -func (o ListByServiceOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o ListByServiceOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Filter != nil { - out["$filter"] = *o.Filter - } - - if o.Skip != nil { - out["$skip"] = *o.Skip - } - - if o.Top != nil { - out["$top"] = *o.Top - } - - return out -} - -// ListByService ... -func (c GroupClient) ListByService(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (resp ListByServiceOperationResponse, err error) { - req, err := c.preparerForListByService(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "group.GroupClient", "ListByService", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "group.GroupClient", "ListByService", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListByService(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "group.GroupClient", "ListByService", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListByService prepares the ListByService request. -func (c GroupClient) preparerForListByService(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/groups", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListByServiceWithNextLink prepares the ListByService request with the given nextLink token. -func (c GroupClient) preparerForListByServiceWithNextLink(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)) -} - -// responderForListByService handles the response to the ListByService request. The method always -// closes the http.Response Body. -func (c GroupClient) responderForListByService(resp *http.Response) (result ListByServiceOperationResponse, err error) { - type page struct { - Values []GroupContract `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 ListByServiceOperationResponse, err error) { - req, err := c.preparerForListByServiceWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "group.GroupClient", "ListByService", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "group.GroupClient", "ListByService", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByService(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "group.GroupClient", "ListByService", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListByServiceComplete retrieves all of the results into a single object -func (c GroupClient) ListByServiceComplete(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (ListByServiceCompleteResult, error) { - return c.ListByServiceCompleteMatchingPredicate(ctx, id, options, GroupContractOperationPredicate{}) -} - -// ListByServiceCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c GroupClient) ListByServiceCompleteMatchingPredicate(ctx context.Context, id ServiceId, options ListByServiceOperationOptions, predicate GroupContractOperationPredicate) (resp ListByServiceCompleteResult, err error) { - items := make([]GroupContract, 0) - - page, err := c.ListByService(ctx, id, options) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListByServiceCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/apimanagement/2022-08-01/group/method_update.go b/resource-manager/apimanagement/2022-08-01/group/method_update.go new file mode 100644 index 00000000000..8ef4191a0f2 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/group/method_update.go @@ -0,0 +1,84 @@ +package group + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *GroupContract +} + +type UpdateOperationOptions struct { + IfMatch *string +} + +func DefaultUpdateOperationOptions() UpdateOperationOptions { + return UpdateOperationOptions{} +} + +func (o UpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o UpdateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o UpdateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// Update ... +func (c GroupClient) Update(ctx context.Context, id GroupId, input GroupUpdateParameters, options UpdateOperationOptions) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + OptionsObject: options, + } + + 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/apimanagement/2022-08-01/group/method_update_autorest.go b/resource-manager/apimanagement/2022-08-01/group/method_update_autorest.go deleted file mode 100644 index 09760546a0e..00000000000 --- a/resource-manager/apimanagement/2022-08-01/group/method_update_autorest.go +++ /dev/null @@ -1,98 +0,0 @@ -package group - -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 *GroupContract -} - -type UpdateOperationOptions struct { - IfMatch *string -} - -func DefaultUpdateOperationOptions() UpdateOperationOptions { - return UpdateOperationOptions{} -} - -func (o UpdateOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o UpdateOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// Update ... -func (c GroupClient) Update(ctx context.Context, id GroupId, input GroupUpdateParameters, options UpdateOperationOptions) (result UpdateOperationResponse, err error) { - req, err := c.preparerForUpdate(ctx, id, input, options) - if err != nil { - err = autorest.NewErrorWithError(err, "group.GroupClient", "Update", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "group.GroupClient", "Update", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "group.GroupClient", "Update", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForUpdate prepares the Update request. -func (c GroupClient) preparerForUpdate(ctx context.Context, id GroupId, input GroupUpdateParameters, options UpdateOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPatch(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - 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 GroupClient) 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/apimanagement/2022-08-01/groupuser/client.go b/resource-manager/apimanagement/2022-08-01/groupuser/client.go index ab4bea57574..83797d917e2 100644 --- a/resource-manager/apimanagement/2022-08-01/groupuser/client.go +++ b/resource-manager/apimanagement/2022-08-01/groupuser/client.go @@ -1,18 +1,26 @@ package groupuser -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 GroupUserClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewGroupUserClientWithBaseURI(endpoint string) GroupUserClient { - return GroupUserClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewGroupUserClientWithBaseURI(api environments.Api) (*GroupUserClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "groupuser", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating GroupUserClient: %+v", err) } + + return &GroupUserClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2022-08-01/groupuser/constants.go b/resource-manager/apimanagement/2022-08-01/groupuser/constants.go index 4023a21458d..520579fefd7 100644 --- a/resource-manager/apimanagement/2022-08-01/groupuser/constants.go +++ b/resource-manager/apimanagement/2022-08-01/groupuser/constants.go @@ -1,6 +1,10 @@ package groupuser -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 PossibleValuesForGroupType() []string { } } +func (s *GroupType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseGroupType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseGroupType(input string) (*GroupType, error) { vals := map[string]GroupType{ "custom": GroupTypeCustom, @@ -54,6 +71,19 @@ func PossibleValuesForUserState() []string { } } +func (s *UserState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseUserState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseUserState(input string) (*UserState, error) { vals := map[string]UserState{ "active": UserStateActive, diff --git a/resource-manager/apimanagement/2022-08-01/groupuser/method_checkentityexists.go b/resource-manager/apimanagement/2022-08-01/groupuser/method_checkentityexists.go new file mode 100644 index 00000000000..ecf5ac1f37b --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/groupuser/method_checkentityexists.go @@ -0,0 +1,46 @@ +package groupuser + +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 CheckEntityExistsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// CheckEntityExists ... +func (c GroupUserClient) CheckEntityExists(ctx context.Context, id GroupUserId) (result CheckEntityExistsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: http.MethodHead, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2022-08-01/groupuser/method_checkentityexists_autorest.go b/resource-manager/apimanagement/2022-08-01/groupuser/method_checkentityexists_autorest.go deleted file mode 100644 index 6c318ef5a01..00000000000 --- a/resource-manager/apimanagement/2022-08-01/groupuser/method_checkentityexists_autorest.go +++ /dev/null @@ -1,66 +0,0 @@ -package groupuser - -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 CheckEntityExistsOperationResponse struct { - HttpResponse *http.Response -} - -// CheckEntityExists ... -func (c GroupUserClient) CheckEntityExists(ctx context.Context, id GroupUserId) (result CheckEntityExistsOperationResponse, err error) { - req, err := c.preparerForCheckEntityExists(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "groupuser.GroupUserClient", "CheckEntityExists", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "groupuser.GroupUserClient", "CheckEntityExists", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCheckEntityExists(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "groupuser.GroupUserClient", "CheckEntityExists", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCheckEntityExists prepares the CheckEntityExists request. -func (c GroupUserClient) preparerForCheckEntityExists(ctx context.Context, id GroupUserId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsHead(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForCheckEntityExists handles the response to the CheckEntityExists request. The method always -// closes the http.Response Body. -func (c GroupUserClient) responderForCheckEntityExists(resp *http.Response) (result CheckEntityExistsOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2022-08-01/groupuser/method_create.go b/resource-manager/apimanagement/2022-08-01/groupuser/method_create.go new file mode 100644 index 00000000000..b13b301f403 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/groupuser/method_create.go @@ -0,0 +1,52 @@ +package groupuser + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *UserContract +} + +// Create ... +func (c GroupUserClient) Create(ctx context.Context, id GroupUserId) (result CreateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + 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/apimanagement/2022-08-01/groupuser/method_create_autorest.go b/resource-manager/apimanagement/2022-08-01/groupuser/method_create_autorest.go deleted file mode 100644 index bc34063331f..00000000000 --- a/resource-manager/apimanagement/2022-08-01/groupuser/method_create_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package groupuser - -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 CreateOperationResponse struct { - HttpResponse *http.Response - Model *UserContract -} - -// Create ... -func (c GroupUserClient) Create(ctx context.Context, id GroupUserId) (result CreateOperationResponse, err error) { - req, err := c.preparerForCreate(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "groupuser.GroupUserClient", "Create", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "groupuser.GroupUserClient", "Create", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCreate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "groupuser.GroupUserClient", "Create", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCreate prepares the Create request. -func (c GroupUserClient) preparerForCreate(ctx context.Context, id GroupUserId) (*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.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForCreate handles the response to the Create request. The method always -// closes the http.Response Body. -func (c GroupUserClient) responderForCreate(resp *http.Response) (result CreateOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2022-08-01/groupuser/method_delete.go b/resource-manager/apimanagement/2022-08-01/groupuser/method_delete.go new file mode 100644 index 00000000000..e8513f36120 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/groupuser/method_delete.go @@ -0,0 +1,47 @@ +package groupuser + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c GroupUserClient) Delete(ctx context.Context, id GroupUserId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2022-08-01/groupuser/method_delete_autorest.go b/resource-manager/apimanagement/2022-08-01/groupuser/method_delete_autorest.go deleted file mode 100644 index 26cb84da7d4..00000000000 --- a/resource-manager/apimanagement/2022-08-01/groupuser/method_delete_autorest.go +++ /dev/null @@ -1,66 +0,0 @@ -package groupuser - -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 DeleteOperationResponse struct { - HttpResponse *http.Response -} - -// Delete ... -func (c GroupUserClient) Delete(ctx context.Context, id GroupUserId) (result DeleteOperationResponse, err error) { - req, err := c.preparerForDelete(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "groupuser.GroupUserClient", "Delete", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "groupuser.GroupUserClient", "Delete", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForDelete(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "groupuser.GroupUserClient", "Delete", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForDelete prepares the Delete request. -func (c GroupUserClient) preparerForDelete(ctx context.Context, id GroupUserId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForDelete handles the response to the Delete request. The method always -// closes the http.Response Body. -func (c GroupUserClient) responderForDelete(resp *http.Response) (result DeleteOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2022-08-01/groupuser/method_list.go b/resource-manager/apimanagement/2022-08-01/groupuser/method_list.go new file mode 100644 index 00000000000..0f87bb365b1 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/groupuser/method_list.go @@ -0,0 +1,125 @@ +package groupuser + +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 *[]UserContract +} + +type ListCompleteResult struct { + Items []UserContract +} + +type ListOperationOptions struct { + Filter *string + Skip *int64 + Top *int64 +} + +func DefaultListOperationOptions() ListOperationOptions { + return ListOperationOptions{} +} + +func (o ListOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.Skip != nil { + out.Append("$skip", fmt.Sprintf("%v", *o.Skip)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +// List ... +func (c GroupUserClient) List(ctx context.Context, id GroupId, options ListOperationOptions) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/users", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]UserContract `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 GroupUserClient) ListComplete(ctx context.Context, id GroupId, options ListOperationOptions) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, options, UserContractOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c GroupUserClient) ListCompleteMatchingPredicate(ctx context.Context, id GroupId, options ListOperationOptions, predicate UserContractOperationPredicate) (result ListCompleteResult, err error) { + items := make([]UserContract, 0) + + resp, err := c.List(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/apimanagement/2022-08-01/groupuser/method_list_autorest.go b/resource-manager/apimanagement/2022-08-01/groupuser/method_list_autorest.go deleted file mode 100644 index 92652a7a09f..00000000000 --- a/resource-manager/apimanagement/2022-08-01/groupuser/method_list_autorest.go +++ /dev/null @@ -1,225 +0,0 @@ -package groupuser - -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 *[]UserContract - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListOperationResponse, error) -} - -type ListCompleteResult struct { - Items []UserContract -} - -func (r ListOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListOperationResponse) LoadMore(ctx context.Context) (resp ListOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -type ListOperationOptions struct { - Filter *string - Skip *int64 - Top *int64 -} - -func DefaultListOperationOptions() ListOperationOptions { - return ListOperationOptions{} -} - -func (o ListOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o ListOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Filter != nil { - out["$filter"] = *o.Filter - } - - if o.Skip != nil { - out["$skip"] = *o.Skip - } - - if o.Top != nil { - out["$top"] = *o.Top - } - - return out -} - -// List ... -func (c GroupUserClient) List(ctx context.Context, id GroupId, options ListOperationOptions) (resp ListOperationResponse, err error) { - req, err := c.preparerForList(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "groupuser.GroupUserClient", "List", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "groupuser.GroupUserClient", "List", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForList(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "groupuser.GroupUserClient", "List", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForList prepares the List request. -func (c GroupUserClient) preparerForList(ctx context.Context, id GroupId, options ListOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/users", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListWithNextLink prepares the List request with the given nextLink token. -func (c GroupUserClient) 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 GroupUserClient) responderForList(resp *http.Response) (result ListOperationResponse, err error) { - type page struct { - Values []UserContract `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, "groupuser.GroupUserClient", "List", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "groupuser.GroupUserClient", "List", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForList(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "groupuser.GroupUserClient", "List", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListComplete retrieves all of the results into a single object -func (c GroupUserClient) ListComplete(ctx context.Context, id GroupId, options ListOperationOptions) (ListCompleteResult, error) { - return c.ListCompleteMatchingPredicate(ctx, id, options, UserContractOperationPredicate{}) -} - -// ListCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c GroupUserClient) ListCompleteMatchingPredicate(ctx context.Context, id GroupId, options ListOperationOptions, predicate UserContractOperationPredicate) (resp ListCompleteResult, err error) { - items := make([]UserContract, 0) - - page, err := c.List(ctx, id, options) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/apimanagement/2022-08-01/identityprovider/client.go b/resource-manager/apimanagement/2022-08-01/identityprovider/client.go index 72328783c91..c29923f5737 100644 --- a/resource-manager/apimanagement/2022-08-01/identityprovider/client.go +++ b/resource-manager/apimanagement/2022-08-01/identityprovider/client.go @@ -1,18 +1,26 @@ package identityprovider -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 IdentityProviderClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewIdentityProviderClientWithBaseURI(endpoint string) IdentityProviderClient { - return IdentityProviderClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewIdentityProviderClientWithBaseURI(api environments.Api) (*IdentityProviderClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "identityprovider", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating IdentityProviderClient: %+v", err) } + + return &IdentityProviderClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2022-08-01/identityprovider/constants.go b/resource-manager/apimanagement/2022-08-01/identityprovider/constants.go index dbcc693e57a..d96fcd03253 100644 --- a/resource-manager/apimanagement/2022-08-01/identityprovider/constants.go +++ b/resource-manager/apimanagement/2022-08-01/identityprovider/constants.go @@ -1,6 +1,10 @@ package identityprovider -import "strings" +import ( + "encoding/json" + "fmt" + "strings" +) // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See NOTICE.txt in the project root for license information. @@ -27,6 +31,19 @@ func PossibleValuesForIdentityProviderType() []string { } } +func (s *IdentityProviderType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseIdentityProviderType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseIdentityProviderType(input string) (*IdentityProviderType, error) { vals := map[string]IdentityProviderType{ "aad": IdentityProviderTypeAad, diff --git a/resource-manager/apimanagement/2022-08-01/identityprovider/method_createorupdate.go b/resource-manager/apimanagement/2022-08-01/identityprovider/method_createorupdate.go new file mode 100644 index 00000000000..7e7257ff801 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/identityprovider/method_createorupdate.go @@ -0,0 +1,85 @@ +package identityprovider + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *IdentityProviderContract +} + +type CreateOrUpdateOperationOptions struct { + IfMatch *string +} + +func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { + return CreateOrUpdateOperationOptions{} +} + +func (o CreateOrUpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o CreateOrUpdateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o CreateOrUpdateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// CreateOrUpdate ... +func (c IdentityProviderClient) CreateOrUpdate(ctx context.Context, id IdentityProviderId, input IdentityProviderCreateContract, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + OptionsObject: options, + } + + 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/apimanagement/2022-08-01/identityprovider/method_createorupdate_autorest.go b/resource-manager/apimanagement/2022-08-01/identityprovider/method_createorupdate_autorest.go deleted file mode 100644 index 01365a7baa9..00000000000 --- a/resource-manager/apimanagement/2022-08-01/identityprovider/method_createorupdate_autorest.go +++ /dev/null @@ -1,98 +0,0 @@ -package identityprovider - -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 *IdentityProviderContract -} - -type CreateOrUpdateOperationOptions struct { - IfMatch *string -} - -func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { - return CreateOrUpdateOperationOptions{} -} - -func (o CreateOrUpdateOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o CreateOrUpdateOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// CreateOrUpdate ... -func (c IdentityProviderClient) CreateOrUpdate(ctx context.Context, id IdentityProviderId, input IdentityProviderCreateContract, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdate(ctx, id, input, options) - if err != nil { - err = autorest.NewErrorWithError(err, "identityprovider.IdentityProviderClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "identityprovider.IdentityProviderClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCreateOrUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "identityprovider.IdentityProviderClient", "CreateOrUpdate", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCreateOrUpdate prepares the CreateOrUpdate request. -func (c IdentityProviderClient) preparerForCreateOrUpdate(ctx context.Context, id IdentityProviderId, input IdentityProviderCreateContract, options CreateOrUpdateOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - 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 IdentityProviderClient) responderForCreateOrUpdate(resp *http.Response) (result CreateOrUpdateOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2022-08-01/identityprovider/method_delete.go b/resource-manager/apimanagement/2022-08-01/identityprovider/method_delete.go new file mode 100644 index 00000000000..ff4f9cee7c4 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/identityprovider/method_delete.go @@ -0,0 +1,76 @@ +package identityprovider + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +type DeleteOperationOptions struct { + IfMatch *string +} + +func DefaultDeleteOperationOptions() DeleteOperationOptions { + return DeleteOperationOptions{} +} + +func (o DeleteOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o DeleteOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o DeleteOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// Delete ... +func (c IdentityProviderClient) Delete(ctx context.Context, id IdentityProviderId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2022-08-01/identityprovider/method_delete_autorest.go b/resource-manager/apimanagement/2022-08-01/identityprovider/method_delete_autorest.go deleted file mode 100644 index d65e64e44b4..00000000000 --- a/resource-manager/apimanagement/2022-08-01/identityprovider/method_delete_autorest.go +++ /dev/null @@ -1,95 +0,0 @@ -package identityprovider - -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 DeleteOperationResponse struct { - HttpResponse *http.Response -} - -type DeleteOperationOptions struct { - IfMatch *string -} - -func DefaultDeleteOperationOptions() DeleteOperationOptions { - return DeleteOperationOptions{} -} - -func (o DeleteOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o DeleteOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// Delete ... -func (c IdentityProviderClient) Delete(ctx context.Context, id IdentityProviderId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { - req, err := c.preparerForDelete(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "identityprovider.IdentityProviderClient", "Delete", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "identityprovider.IdentityProviderClient", "Delete", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForDelete(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "identityprovider.IdentityProviderClient", "Delete", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForDelete prepares the Delete request. -func (c IdentityProviderClient) preparerForDelete(ctx context.Context, id IdentityProviderId, options DeleteOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForDelete handles the response to the Delete request. The method always -// closes the http.Response Body. -func (c IdentityProviderClient) responderForDelete(resp *http.Response) (result DeleteOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2022-08-01/identityprovider/method_get.go b/resource-manager/apimanagement/2022-08-01/identityprovider/method_get.go new file mode 100644 index 00000000000..3ea0d912b93 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/identityprovider/method_get.go @@ -0,0 +1,51 @@ +package identityprovider + +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 *IdentityProviderContract +} + +// Get ... +func (c IdentityProviderClient) Get(ctx context.Context, id IdentityProviderId) (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/apimanagement/2022-08-01/identityprovider/method_get_autorest.go b/resource-manager/apimanagement/2022-08-01/identityprovider/method_get_autorest.go deleted file mode 100644 index 05ae191473a..00000000000 --- a/resource-manager/apimanagement/2022-08-01/identityprovider/method_get_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package identityprovider - -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 *IdentityProviderContract -} - -// Get ... -func (c IdentityProviderClient) Get(ctx context.Context, id IdentityProviderId) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "identityprovider.IdentityProviderClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "identityprovider.IdentityProviderClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "identityprovider.IdentityProviderClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c IdentityProviderClient) preparerForGet(ctx context.Context, id IdentityProviderId) (*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 IdentityProviderClient) 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/apimanagement/2022-08-01/identityprovider/method_getentitytag.go b/resource-manager/apimanagement/2022-08-01/identityprovider/method_getentitytag.go new file mode 100644 index 00000000000..626d199ac1f --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/identityprovider/method_getentitytag.go @@ -0,0 +1,46 @@ +package identityprovider + +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 GetEntityTagOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// GetEntityTag ... +func (c IdentityProviderClient) GetEntityTag(ctx context.Context, id IdentityProviderId) (result GetEntityTagOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodHead, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2022-08-01/identityprovider/method_getentitytag_autorest.go b/resource-manager/apimanagement/2022-08-01/identityprovider/method_getentitytag_autorest.go deleted file mode 100644 index 1df4d8b8805..00000000000 --- a/resource-manager/apimanagement/2022-08-01/identityprovider/method_getentitytag_autorest.go +++ /dev/null @@ -1,66 +0,0 @@ -package identityprovider - -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 GetEntityTagOperationResponse struct { - HttpResponse *http.Response -} - -// GetEntityTag ... -func (c IdentityProviderClient) GetEntityTag(ctx context.Context, id IdentityProviderId) (result GetEntityTagOperationResponse, err error) { - req, err := c.preparerForGetEntityTag(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "identityprovider.IdentityProviderClient", "GetEntityTag", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "identityprovider.IdentityProviderClient", "GetEntityTag", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetEntityTag(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "identityprovider.IdentityProviderClient", "GetEntityTag", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetEntityTag prepares the GetEntityTag request. -func (c IdentityProviderClient) preparerForGetEntityTag(ctx context.Context, id IdentityProviderId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsHead(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetEntityTag handles the response to the GetEntityTag request. The method always -// closes the http.Response Body. -func (c IdentityProviderClient) responderForGetEntityTag(resp *http.Response) (result GetEntityTagOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2022-08-01/identityprovider/method_listbyservice.go b/resource-manager/apimanagement/2022-08-01/identityprovider/method_listbyservice.go new file mode 100644 index 00000000000..881b7200016 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/identityprovider/method_listbyservice.go @@ -0,0 +1,89 @@ +package identityprovider + +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 ListByServiceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]IdentityProviderContract +} + +type ListByServiceCompleteResult struct { + Items []IdentityProviderContract +} + +// ListByService ... +func (c IdentityProviderClient) ListByService(ctx context.Context, id ServiceId) (result ListByServiceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/identityProviders", 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 *[]IdentityProviderContract `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByServiceComplete retrieves all the results into a single object +func (c IdentityProviderClient) ListByServiceComplete(ctx context.Context, id ServiceId) (ListByServiceCompleteResult, error) { + return c.ListByServiceCompleteMatchingPredicate(ctx, id, IdentityProviderContractOperationPredicate{}) +} + +// ListByServiceCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c IdentityProviderClient) ListByServiceCompleteMatchingPredicate(ctx context.Context, id ServiceId, predicate IdentityProviderContractOperationPredicate) (result ListByServiceCompleteResult, err error) { + items := make([]IdentityProviderContract, 0) + + resp, err := c.ListByService(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 = ListByServiceCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/apimanagement/2022-08-01/identityprovider/method_listbyservice_autorest.go b/resource-manager/apimanagement/2022-08-01/identityprovider/method_listbyservice_autorest.go deleted file mode 100644 index 993d95a854d..00000000000 --- a/resource-manager/apimanagement/2022-08-01/identityprovider/method_listbyservice_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package identityprovider - -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 ListByServiceOperationResponse struct { - HttpResponse *http.Response - Model *[]IdentityProviderContract - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListByServiceOperationResponse, error) -} - -type ListByServiceCompleteResult struct { - Items []IdentityProviderContract -} - -func (r ListByServiceOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListByServiceOperationResponse) LoadMore(ctx context.Context) (resp ListByServiceOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListByService ... -func (c IdentityProviderClient) ListByService(ctx context.Context, id ServiceId) (resp ListByServiceOperationResponse, err error) { - req, err := c.preparerForListByService(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "identityprovider.IdentityProviderClient", "ListByService", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "identityprovider.IdentityProviderClient", "ListByService", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListByService(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "identityprovider.IdentityProviderClient", "ListByService", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListByService prepares the ListByService request. -func (c IdentityProviderClient) preparerForListByService(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(fmt.Sprintf("%s/identityProviders", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListByServiceWithNextLink prepares the ListByService request with the given nextLink token. -func (c IdentityProviderClient) preparerForListByServiceWithNextLink(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)) -} - -// responderForListByService handles the response to the ListByService request. The method always -// closes the http.Response Body. -func (c IdentityProviderClient) responderForListByService(resp *http.Response) (result ListByServiceOperationResponse, err error) { - type page struct { - Values []IdentityProviderContract `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 ListByServiceOperationResponse, err error) { - req, err := c.preparerForListByServiceWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "identityprovider.IdentityProviderClient", "ListByService", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "identityprovider.IdentityProviderClient", "ListByService", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByService(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "identityprovider.IdentityProviderClient", "ListByService", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListByServiceComplete retrieves all of the results into a single object -func (c IdentityProviderClient) ListByServiceComplete(ctx context.Context, id ServiceId) (ListByServiceCompleteResult, error) { - return c.ListByServiceCompleteMatchingPredicate(ctx, id, IdentityProviderContractOperationPredicate{}) -} - -// ListByServiceCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c IdentityProviderClient) ListByServiceCompleteMatchingPredicate(ctx context.Context, id ServiceId, predicate IdentityProviderContractOperationPredicate) (resp ListByServiceCompleteResult, err error) { - items := make([]IdentityProviderContract, 0) - - page, err := c.ListByService(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 := ListByServiceCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/apimanagement/2022-08-01/identityprovider/method_listsecrets.go b/resource-manager/apimanagement/2022-08-01/identityprovider/method_listsecrets.go new file mode 100644 index 00000000000..bf808b63434 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/identityprovider/method_listsecrets.go @@ -0,0 +1,52 @@ +package identityprovider + +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 ListSecretsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ClientSecretContract +} + +// ListSecrets ... +func (c IdentityProviderClient) ListSecrets(ctx context.Context, id IdentityProviderId) (result ListSecretsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/listSecrets", 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/apimanagement/2022-08-01/identityprovider/method_listsecrets_autorest.go b/resource-manager/apimanagement/2022-08-01/identityprovider/method_listsecrets_autorest.go deleted file mode 100644 index 1e36cc02469..00000000000 --- a/resource-manager/apimanagement/2022-08-01/identityprovider/method_listsecrets_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package identityprovider - -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 ListSecretsOperationResponse struct { - HttpResponse *http.Response - Model *ClientSecretContract -} - -// ListSecrets ... -func (c IdentityProviderClient) ListSecrets(ctx context.Context, id IdentityProviderId) (result ListSecretsOperationResponse, err error) { - req, err := c.preparerForListSecrets(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "identityprovider.IdentityProviderClient", "ListSecrets", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "identityprovider.IdentityProviderClient", "ListSecrets", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListSecrets(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "identityprovider.IdentityProviderClient", "ListSecrets", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForListSecrets prepares the ListSecrets request. -func (c IdentityProviderClient) preparerForListSecrets(ctx context.Context, id IdentityProviderId) (*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/listSecrets", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListSecrets handles the response to the ListSecrets request. The method always -// closes the http.Response Body. -func (c IdentityProviderClient) responderForListSecrets(resp *http.Response) (result ListSecretsOperationResponse, 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/apimanagement/2022-08-01/identityprovider/method_update.go b/resource-manager/apimanagement/2022-08-01/identityprovider/method_update.go new file mode 100644 index 00000000000..9ac8eaebfa4 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/identityprovider/method_update.go @@ -0,0 +1,84 @@ +package identityprovider + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *IdentityProviderContract +} + +type UpdateOperationOptions struct { + IfMatch *string +} + +func DefaultUpdateOperationOptions() UpdateOperationOptions { + return UpdateOperationOptions{} +} + +func (o UpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o UpdateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o UpdateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// Update ... +func (c IdentityProviderClient) Update(ctx context.Context, id IdentityProviderId, input IdentityProviderUpdateParameters, options UpdateOperationOptions) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + OptionsObject: options, + } + + 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/apimanagement/2022-08-01/identityprovider/method_update_autorest.go b/resource-manager/apimanagement/2022-08-01/identityprovider/method_update_autorest.go deleted file mode 100644 index 0f1cbf0647f..00000000000 --- a/resource-manager/apimanagement/2022-08-01/identityprovider/method_update_autorest.go +++ /dev/null @@ -1,98 +0,0 @@ -package identityprovider - -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 *IdentityProviderContract -} - -type UpdateOperationOptions struct { - IfMatch *string -} - -func DefaultUpdateOperationOptions() UpdateOperationOptions { - return UpdateOperationOptions{} -} - -func (o UpdateOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o UpdateOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// Update ... -func (c IdentityProviderClient) Update(ctx context.Context, id IdentityProviderId, input IdentityProviderUpdateParameters, options UpdateOperationOptions) (result UpdateOperationResponse, err error) { - req, err := c.preparerForUpdate(ctx, id, input, options) - if err != nil { - err = autorest.NewErrorWithError(err, "identityprovider.IdentityProviderClient", "Update", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "identityprovider.IdentityProviderClient", "Update", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "identityprovider.IdentityProviderClient", "Update", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForUpdate prepares the Update request. -func (c IdentityProviderClient) preparerForUpdate(ctx context.Context, id IdentityProviderId, input IdentityProviderUpdateParameters, options UpdateOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPatch(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - 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 IdentityProviderClient) 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/apimanagement/2022-08-01/issue/client.go b/resource-manager/apimanagement/2022-08-01/issue/client.go index 973a74c9ec3..da86b4f1e45 100644 --- a/resource-manager/apimanagement/2022-08-01/issue/client.go +++ b/resource-manager/apimanagement/2022-08-01/issue/client.go @@ -1,18 +1,26 @@ package issue -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 IssueClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewIssueClientWithBaseURI(endpoint string) IssueClient { - return IssueClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewIssueClientWithBaseURI(api environments.Api) (*IssueClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "issue", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating IssueClient: %+v", err) } + + return &IssueClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2022-08-01/issue/constants.go b/resource-manager/apimanagement/2022-08-01/issue/constants.go index 837f3883c24..737222a81b0 100644 --- a/resource-manager/apimanagement/2022-08-01/issue/constants.go +++ b/resource-manager/apimanagement/2022-08-01/issue/constants.go @@ -1,6 +1,10 @@ package issue -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. @@ -25,6 +29,19 @@ func PossibleValuesForState() []string { } } +func (s *State) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseState(input string) (*State, error) { vals := map[string]State{ "closed": StateClosed, diff --git a/resource-manager/apimanagement/2022-08-01/issue/method_get.go b/resource-manager/apimanagement/2022-08-01/issue/method_get.go new file mode 100644 index 00000000000..d23f005d647 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/issue/method_get.go @@ -0,0 +1,51 @@ +package issue + +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 *IssueContract +} + +// Get ... +func (c IssueClient) Get(ctx context.Context, id IssueId) (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/apimanagement/2022-08-01/issue/method_get_autorest.go b/resource-manager/apimanagement/2022-08-01/issue/method_get_autorest.go deleted file mode 100644 index fbdc95d1081..00000000000 --- a/resource-manager/apimanagement/2022-08-01/issue/method_get_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package issue - -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 *IssueContract -} - -// Get ... -func (c IssueClient) Get(ctx context.Context, id IssueId) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "issue.IssueClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "issue.IssueClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "issue.IssueClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c IssueClient) preparerForGet(ctx context.Context, id IssueId) (*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 IssueClient) 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/apimanagement/2022-08-01/issue/method_listbyservice.go b/resource-manager/apimanagement/2022-08-01/issue/method_listbyservice.go new file mode 100644 index 00000000000..f18cb96e08c --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/issue/method_listbyservice.go @@ -0,0 +1,125 @@ +package issue + +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 ListByServiceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]IssueContract +} + +type ListByServiceCompleteResult struct { + Items []IssueContract +} + +type ListByServiceOperationOptions struct { + Filter *string + Skip *int64 + Top *int64 +} + +func DefaultListByServiceOperationOptions() ListByServiceOperationOptions { + return ListByServiceOperationOptions{} +} + +func (o ListByServiceOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListByServiceOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListByServiceOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.Skip != nil { + out.Append("$skip", fmt.Sprintf("%v", *o.Skip)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +// ListByService ... +func (c IssueClient) ListByService(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (result ListByServiceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/issues", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]IssueContract `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByServiceComplete retrieves all the results into a single object +func (c IssueClient) ListByServiceComplete(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (ListByServiceCompleteResult, error) { + return c.ListByServiceCompleteMatchingPredicate(ctx, id, options, IssueContractOperationPredicate{}) +} + +// ListByServiceCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c IssueClient) ListByServiceCompleteMatchingPredicate(ctx context.Context, id ServiceId, options ListByServiceOperationOptions, predicate IssueContractOperationPredicate) (result ListByServiceCompleteResult, err error) { + items := make([]IssueContract, 0) + + resp, err := c.ListByService(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByServiceCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/apimanagement/2022-08-01/issue/method_listbyservice_autorest.go b/resource-manager/apimanagement/2022-08-01/issue/method_listbyservice_autorest.go deleted file mode 100644 index c811024f3da..00000000000 --- a/resource-manager/apimanagement/2022-08-01/issue/method_listbyservice_autorest.go +++ /dev/null @@ -1,225 +0,0 @@ -package issue - -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 ListByServiceOperationResponse struct { - HttpResponse *http.Response - Model *[]IssueContract - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListByServiceOperationResponse, error) -} - -type ListByServiceCompleteResult struct { - Items []IssueContract -} - -func (r ListByServiceOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListByServiceOperationResponse) LoadMore(ctx context.Context) (resp ListByServiceOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -type ListByServiceOperationOptions struct { - Filter *string - Skip *int64 - Top *int64 -} - -func DefaultListByServiceOperationOptions() ListByServiceOperationOptions { - return ListByServiceOperationOptions{} -} - -func (o ListByServiceOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o ListByServiceOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Filter != nil { - out["$filter"] = *o.Filter - } - - if o.Skip != nil { - out["$skip"] = *o.Skip - } - - if o.Top != nil { - out["$top"] = *o.Top - } - - return out -} - -// ListByService ... -func (c IssueClient) ListByService(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (resp ListByServiceOperationResponse, err error) { - req, err := c.preparerForListByService(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "issue.IssueClient", "ListByService", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "issue.IssueClient", "ListByService", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListByService(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "issue.IssueClient", "ListByService", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListByService prepares the ListByService request. -func (c IssueClient) preparerForListByService(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/issues", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListByServiceWithNextLink prepares the ListByService request with the given nextLink token. -func (c IssueClient) preparerForListByServiceWithNextLink(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)) -} - -// responderForListByService handles the response to the ListByService request. The method always -// closes the http.Response Body. -func (c IssueClient) responderForListByService(resp *http.Response) (result ListByServiceOperationResponse, err error) { - type page struct { - Values []IssueContract `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 ListByServiceOperationResponse, err error) { - req, err := c.preparerForListByServiceWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "issue.IssueClient", "ListByService", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "issue.IssueClient", "ListByService", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByService(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "issue.IssueClient", "ListByService", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListByServiceComplete retrieves all of the results into a single object -func (c IssueClient) ListByServiceComplete(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (ListByServiceCompleteResult, error) { - return c.ListByServiceCompleteMatchingPredicate(ctx, id, options, IssueContractOperationPredicate{}) -} - -// ListByServiceCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c IssueClient) ListByServiceCompleteMatchingPredicate(ctx context.Context, id ServiceId, options ListByServiceOperationOptions, predicate IssueContractOperationPredicate) (resp ListByServiceCompleteResult, err error) { - items := make([]IssueContract, 0) - - page, err := c.ListByService(ctx, id, options) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListByServiceCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/apimanagement/2022-08-01/logger/client.go b/resource-manager/apimanagement/2022-08-01/logger/client.go index 35b0189b9e7..2e9c29e82cb 100644 --- a/resource-manager/apimanagement/2022-08-01/logger/client.go +++ b/resource-manager/apimanagement/2022-08-01/logger/client.go @@ -1,18 +1,26 @@ package logger -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 LoggerClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewLoggerClientWithBaseURI(endpoint string) LoggerClient { - return LoggerClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewLoggerClientWithBaseURI(api environments.Api) (*LoggerClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "logger", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating LoggerClient: %+v", err) } + + return &LoggerClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2022-08-01/logger/constants.go b/resource-manager/apimanagement/2022-08-01/logger/constants.go index cf45d74e056..0aa7cb68a3e 100644 --- a/resource-manager/apimanagement/2022-08-01/logger/constants.go +++ b/resource-manager/apimanagement/2022-08-01/logger/constants.go @@ -1,6 +1,10 @@ package logger -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 PossibleValuesForLoggerType() []string { } } +func (s *LoggerType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseLoggerType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseLoggerType(input string) (*LoggerType, error) { vals := map[string]LoggerType{ "applicationinsights": LoggerTypeApplicationInsights, diff --git a/resource-manager/apimanagement/2022-08-01/logger/method_createorupdate.go b/resource-manager/apimanagement/2022-08-01/logger/method_createorupdate.go new file mode 100644 index 00000000000..5afa3c7881e --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/logger/method_createorupdate.go @@ -0,0 +1,85 @@ +package logger + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *LoggerContract +} + +type CreateOrUpdateOperationOptions struct { + IfMatch *string +} + +func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { + return CreateOrUpdateOperationOptions{} +} + +func (o CreateOrUpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o CreateOrUpdateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o CreateOrUpdateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// CreateOrUpdate ... +func (c LoggerClient) CreateOrUpdate(ctx context.Context, id LoggerId, input LoggerContract, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + OptionsObject: options, + } + + 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/apimanagement/2022-08-01/logger/method_createorupdate_autorest.go b/resource-manager/apimanagement/2022-08-01/logger/method_createorupdate_autorest.go deleted file mode 100644 index 0575dfc04e6..00000000000 --- a/resource-manager/apimanagement/2022-08-01/logger/method_createorupdate_autorest.go +++ /dev/null @@ -1,98 +0,0 @@ -package logger - -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 *LoggerContract -} - -type CreateOrUpdateOperationOptions struct { - IfMatch *string -} - -func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { - return CreateOrUpdateOperationOptions{} -} - -func (o CreateOrUpdateOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o CreateOrUpdateOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// CreateOrUpdate ... -func (c LoggerClient) CreateOrUpdate(ctx context.Context, id LoggerId, input LoggerContract, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdate(ctx, id, input, options) - if err != nil { - err = autorest.NewErrorWithError(err, "logger.LoggerClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "logger.LoggerClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCreateOrUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "logger.LoggerClient", "CreateOrUpdate", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCreateOrUpdate prepares the CreateOrUpdate request. -func (c LoggerClient) preparerForCreateOrUpdate(ctx context.Context, id LoggerId, input LoggerContract, options CreateOrUpdateOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - 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 LoggerClient) responderForCreateOrUpdate(resp *http.Response) (result CreateOrUpdateOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2022-08-01/logger/method_delete.go b/resource-manager/apimanagement/2022-08-01/logger/method_delete.go new file mode 100644 index 00000000000..9a3b1b42ad9 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/logger/method_delete.go @@ -0,0 +1,76 @@ +package logger + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +type DeleteOperationOptions struct { + IfMatch *string +} + +func DefaultDeleteOperationOptions() DeleteOperationOptions { + return DeleteOperationOptions{} +} + +func (o DeleteOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o DeleteOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o DeleteOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// Delete ... +func (c LoggerClient) Delete(ctx context.Context, id LoggerId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2022-08-01/logger/method_delete_autorest.go b/resource-manager/apimanagement/2022-08-01/logger/method_delete_autorest.go deleted file mode 100644 index cdc22bf87cc..00000000000 --- a/resource-manager/apimanagement/2022-08-01/logger/method_delete_autorest.go +++ /dev/null @@ -1,95 +0,0 @@ -package logger - -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 DeleteOperationResponse struct { - HttpResponse *http.Response -} - -type DeleteOperationOptions struct { - IfMatch *string -} - -func DefaultDeleteOperationOptions() DeleteOperationOptions { - return DeleteOperationOptions{} -} - -func (o DeleteOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o DeleteOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// Delete ... -func (c LoggerClient) Delete(ctx context.Context, id LoggerId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { - req, err := c.preparerForDelete(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "logger.LoggerClient", "Delete", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "logger.LoggerClient", "Delete", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForDelete(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "logger.LoggerClient", "Delete", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForDelete prepares the Delete request. -func (c LoggerClient) preparerForDelete(ctx context.Context, id LoggerId, options DeleteOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForDelete handles the response to the Delete request. The method always -// closes the http.Response Body. -func (c LoggerClient) responderForDelete(resp *http.Response) (result DeleteOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2022-08-01/logger/method_get.go b/resource-manager/apimanagement/2022-08-01/logger/method_get.go new file mode 100644 index 00000000000..a755ecf8263 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/logger/method_get.go @@ -0,0 +1,51 @@ +package logger + +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 *LoggerContract +} + +// Get ... +func (c LoggerClient) Get(ctx context.Context, id LoggerId) (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/apimanagement/2022-08-01/logger/method_get_autorest.go b/resource-manager/apimanagement/2022-08-01/logger/method_get_autorest.go deleted file mode 100644 index 37e10193f3d..00000000000 --- a/resource-manager/apimanagement/2022-08-01/logger/method_get_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package logger - -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 *LoggerContract -} - -// Get ... -func (c LoggerClient) Get(ctx context.Context, id LoggerId) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "logger.LoggerClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "logger.LoggerClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "logger.LoggerClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c LoggerClient) preparerForGet(ctx context.Context, id LoggerId) (*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 LoggerClient) 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/apimanagement/2022-08-01/logger/method_getentitytag.go b/resource-manager/apimanagement/2022-08-01/logger/method_getentitytag.go new file mode 100644 index 00000000000..b65f6ac22bd --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/logger/method_getentitytag.go @@ -0,0 +1,46 @@ +package logger + +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 GetEntityTagOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// GetEntityTag ... +func (c LoggerClient) GetEntityTag(ctx context.Context, id LoggerId) (result GetEntityTagOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodHead, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2022-08-01/logger/method_getentitytag_autorest.go b/resource-manager/apimanagement/2022-08-01/logger/method_getentitytag_autorest.go deleted file mode 100644 index 4e2a41cb3a9..00000000000 --- a/resource-manager/apimanagement/2022-08-01/logger/method_getentitytag_autorest.go +++ /dev/null @@ -1,66 +0,0 @@ -package logger - -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 GetEntityTagOperationResponse struct { - HttpResponse *http.Response -} - -// GetEntityTag ... -func (c LoggerClient) GetEntityTag(ctx context.Context, id LoggerId) (result GetEntityTagOperationResponse, err error) { - req, err := c.preparerForGetEntityTag(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "logger.LoggerClient", "GetEntityTag", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "logger.LoggerClient", "GetEntityTag", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetEntityTag(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "logger.LoggerClient", "GetEntityTag", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetEntityTag prepares the GetEntityTag request. -func (c LoggerClient) preparerForGetEntityTag(ctx context.Context, id LoggerId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsHead(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetEntityTag handles the response to the GetEntityTag request. The method always -// closes the http.Response Body. -func (c LoggerClient) responderForGetEntityTag(resp *http.Response) (result GetEntityTagOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2022-08-01/logger/method_listbyservice.go b/resource-manager/apimanagement/2022-08-01/logger/method_listbyservice.go new file mode 100644 index 00000000000..6049c405eb8 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/logger/method_listbyservice.go @@ -0,0 +1,125 @@ +package logger + +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 ListByServiceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]LoggerContract +} + +type ListByServiceCompleteResult struct { + Items []LoggerContract +} + +type ListByServiceOperationOptions struct { + Filter *string + Skip *int64 + Top *int64 +} + +func DefaultListByServiceOperationOptions() ListByServiceOperationOptions { + return ListByServiceOperationOptions{} +} + +func (o ListByServiceOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListByServiceOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListByServiceOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.Skip != nil { + out.Append("$skip", fmt.Sprintf("%v", *o.Skip)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +// ListByService ... +func (c LoggerClient) ListByService(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (result ListByServiceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/loggers", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]LoggerContract `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByServiceComplete retrieves all the results into a single object +func (c LoggerClient) ListByServiceComplete(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (ListByServiceCompleteResult, error) { + return c.ListByServiceCompleteMatchingPredicate(ctx, id, options, LoggerContractOperationPredicate{}) +} + +// ListByServiceCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c LoggerClient) ListByServiceCompleteMatchingPredicate(ctx context.Context, id ServiceId, options ListByServiceOperationOptions, predicate LoggerContractOperationPredicate) (result ListByServiceCompleteResult, err error) { + items := make([]LoggerContract, 0) + + resp, err := c.ListByService(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByServiceCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/apimanagement/2022-08-01/logger/method_listbyservice_autorest.go b/resource-manager/apimanagement/2022-08-01/logger/method_listbyservice_autorest.go deleted file mode 100644 index 23f43bba9ca..00000000000 --- a/resource-manager/apimanagement/2022-08-01/logger/method_listbyservice_autorest.go +++ /dev/null @@ -1,225 +0,0 @@ -package logger - -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 ListByServiceOperationResponse struct { - HttpResponse *http.Response - Model *[]LoggerContract - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListByServiceOperationResponse, error) -} - -type ListByServiceCompleteResult struct { - Items []LoggerContract -} - -func (r ListByServiceOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListByServiceOperationResponse) LoadMore(ctx context.Context) (resp ListByServiceOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -type ListByServiceOperationOptions struct { - Filter *string - Skip *int64 - Top *int64 -} - -func DefaultListByServiceOperationOptions() ListByServiceOperationOptions { - return ListByServiceOperationOptions{} -} - -func (o ListByServiceOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o ListByServiceOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Filter != nil { - out["$filter"] = *o.Filter - } - - if o.Skip != nil { - out["$skip"] = *o.Skip - } - - if o.Top != nil { - out["$top"] = *o.Top - } - - return out -} - -// ListByService ... -func (c LoggerClient) ListByService(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (resp ListByServiceOperationResponse, err error) { - req, err := c.preparerForListByService(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "logger.LoggerClient", "ListByService", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "logger.LoggerClient", "ListByService", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListByService(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "logger.LoggerClient", "ListByService", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListByService prepares the ListByService request. -func (c LoggerClient) preparerForListByService(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/loggers", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListByServiceWithNextLink prepares the ListByService request with the given nextLink token. -func (c LoggerClient) preparerForListByServiceWithNextLink(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)) -} - -// responderForListByService handles the response to the ListByService request. The method always -// closes the http.Response Body. -func (c LoggerClient) responderForListByService(resp *http.Response) (result ListByServiceOperationResponse, err error) { - type page struct { - Values []LoggerContract `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 ListByServiceOperationResponse, err error) { - req, err := c.preparerForListByServiceWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "logger.LoggerClient", "ListByService", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "logger.LoggerClient", "ListByService", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByService(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "logger.LoggerClient", "ListByService", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListByServiceComplete retrieves all of the results into a single object -func (c LoggerClient) ListByServiceComplete(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (ListByServiceCompleteResult, error) { - return c.ListByServiceCompleteMatchingPredicate(ctx, id, options, LoggerContractOperationPredicate{}) -} - -// ListByServiceCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c LoggerClient) ListByServiceCompleteMatchingPredicate(ctx context.Context, id ServiceId, options ListByServiceOperationOptions, predicate LoggerContractOperationPredicate) (resp ListByServiceCompleteResult, err error) { - items := make([]LoggerContract, 0) - - page, err := c.ListByService(ctx, id, options) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListByServiceCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/apimanagement/2022-08-01/logger/method_update.go b/resource-manager/apimanagement/2022-08-01/logger/method_update.go new file mode 100644 index 00000000000..f7245ad9404 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/logger/method_update.go @@ -0,0 +1,84 @@ +package logger + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *LoggerContract +} + +type UpdateOperationOptions struct { + IfMatch *string +} + +func DefaultUpdateOperationOptions() UpdateOperationOptions { + return UpdateOperationOptions{} +} + +func (o UpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o UpdateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o UpdateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// Update ... +func (c LoggerClient) Update(ctx context.Context, id LoggerId, input LoggerUpdateContract, options UpdateOperationOptions) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + OptionsObject: options, + } + + 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/apimanagement/2022-08-01/logger/method_update_autorest.go b/resource-manager/apimanagement/2022-08-01/logger/method_update_autorest.go deleted file mode 100644 index 73a90ec1fbc..00000000000 --- a/resource-manager/apimanagement/2022-08-01/logger/method_update_autorest.go +++ /dev/null @@ -1,98 +0,0 @@ -package logger - -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 *LoggerContract -} - -type UpdateOperationOptions struct { - IfMatch *string -} - -func DefaultUpdateOperationOptions() UpdateOperationOptions { - return UpdateOperationOptions{} -} - -func (o UpdateOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o UpdateOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// Update ... -func (c LoggerClient) Update(ctx context.Context, id LoggerId, input LoggerUpdateContract, options UpdateOperationOptions) (result UpdateOperationResponse, err error) { - req, err := c.preparerForUpdate(ctx, id, input, options) - if err != nil { - err = autorest.NewErrorWithError(err, "logger.LoggerClient", "Update", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "logger.LoggerClient", "Update", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "logger.LoggerClient", "Update", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForUpdate prepares the Update request. -func (c LoggerClient) preparerForUpdate(ctx context.Context, id LoggerId, input LoggerUpdateContract, options UpdateOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPatch(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - 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 LoggerClient) 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/apimanagement/2022-08-01/namedvalue/client.go b/resource-manager/apimanagement/2022-08-01/namedvalue/client.go index 50c96afd343..e7f6f57c3c7 100644 --- a/resource-manager/apimanagement/2022-08-01/namedvalue/client.go +++ b/resource-manager/apimanagement/2022-08-01/namedvalue/client.go @@ -1,18 +1,26 @@ package namedvalue -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 NamedValueClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewNamedValueClientWithBaseURI(endpoint string) NamedValueClient { - return NamedValueClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewNamedValueClientWithBaseURI(api environments.Api) (*NamedValueClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "namedvalue", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating NamedValueClient: %+v", err) } + + return &NamedValueClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2022-08-01/namedvalue/method_createorupdate.go b/resource-manager/apimanagement/2022-08-01/namedvalue/method_createorupdate.go new file mode 100644 index 00000000000..09c8aa0bbe5 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/namedvalue/method_createorupdate.go @@ -0,0 +1,103 @@ +package namedvalue + +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 +} + +type CreateOrUpdateOperationOptions struct { + IfMatch *string +} + +func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { + return CreateOrUpdateOperationOptions{} +} + +func (o CreateOrUpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o CreateOrUpdateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o CreateOrUpdateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// CreateOrUpdate ... +func (c NamedValueClient) CreateOrUpdate(ctx context.Context, id NamedValueId, input NamedValueCreateContract, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + OptionsObject: options, + } + + 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 NamedValueClient) CreateOrUpdateThenPoll(ctx context.Context, id NamedValueId, input NamedValueCreateContract, options CreateOrUpdateOperationOptions) error { + result, err := c.CreateOrUpdate(ctx, id, input, options) + 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/apimanagement/2022-08-01/namedvalue/method_createorupdate_autorest.go b/resource-manager/apimanagement/2022-08-01/namedvalue/method_createorupdate_autorest.go deleted file mode 100644 index 7f838bb490b..00000000000 --- a/resource-manager/apimanagement/2022-08-01/namedvalue/method_createorupdate_autorest.go +++ /dev/null @@ -1,108 +0,0 @@ -package namedvalue - -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 -} - -type CreateOrUpdateOperationOptions struct { - IfMatch *string -} - -func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { - return CreateOrUpdateOperationOptions{} -} - -func (o CreateOrUpdateOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o CreateOrUpdateOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// CreateOrUpdate ... -func (c NamedValueClient) CreateOrUpdate(ctx context.Context, id NamedValueId, input NamedValueCreateContract, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdate(ctx, id, input, options) - if err != nil { - err = autorest.NewErrorWithError(err, "namedvalue.NamedValueClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result, err = c.senderForCreateOrUpdate(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "namedvalue.NamedValueClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed -func (c NamedValueClient) CreateOrUpdateThenPoll(ctx context.Context, id NamedValueId, input NamedValueCreateContract, options CreateOrUpdateOperationOptions) error { - result, err := c.CreateOrUpdate(ctx, id, input, options) - 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 NamedValueClient) preparerForCreateOrUpdate(ctx context.Context, id NamedValueId, input NamedValueCreateContract, options CreateOrUpdateOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - 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 NamedValueClient) 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/apimanagement/2022-08-01/namedvalue/method_delete.go b/resource-manager/apimanagement/2022-08-01/namedvalue/method_delete.go new file mode 100644 index 00000000000..82bbf62ac51 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/namedvalue/method_delete.go @@ -0,0 +1,76 @@ +package namedvalue + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +type DeleteOperationOptions struct { + IfMatch *string +} + +func DefaultDeleteOperationOptions() DeleteOperationOptions { + return DeleteOperationOptions{} +} + +func (o DeleteOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o DeleteOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o DeleteOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// Delete ... +func (c NamedValueClient) Delete(ctx context.Context, id NamedValueId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2022-08-01/namedvalue/method_delete_autorest.go b/resource-manager/apimanagement/2022-08-01/namedvalue/method_delete_autorest.go deleted file mode 100644 index da4a8178f35..00000000000 --- a/resource-manager/apimanagement/2022-08-01/namedvalue/method_delete_autorest.go +++ /dev/null @@ -1,95 +0,0 @@ -package namedvalue - -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 DeleteOperationResponse struct { - HttpResponse *http.Response -} - -type DeleteOperationOptions struct { - IfMatch *string -} - -func DefaultDeleteOperationOptions() DeleteOperationOptions { - return DeleteOperationOptions{} -} - -func (o DeleteOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o DeleteOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// Delete ... -func (c NamedValueClient) Delete(ctx context.Context, id NamedValueId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { - req, err := c.preparerForDelete(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "namedvalue.NamedValueClient", "Delete", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "namedvalue.NamedValueClient", "Delete", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForDelete(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "namedvalue.NamedValueClient", "Delete", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForDelete prepares the Delete request. -func (c NamedValueClient) preparerForDelete(ctx context.Context, id NamedValueId, options DeleteOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForDelete handles the response to the Delete request. The method always -// closes the http.Response Body. -func (c NamedValueClient) responderForDelete(resp *http.Response) (result DeleteOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2022-08-01/namedvalue/method_get.go b/resource-manager/apimanagement/2022-08-01/namedvalue/method_get.go new file mode 100644 index 00000000000..db6c7dc54e2 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/namedvalue/method_get.go @@ -0,0 +1,51 @@ +package namedvalue + +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 *NamedValueContract +} + +// Get ... +func (c NamedValueClient) Get(ctx context.Context, id NamedValueId) (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/apimanagement/2022-08-01/namedvalue/method_get_autorest.go b/resource-manager/apimanagement/2022-08-01/namedvalue/method_get_autorest.go deleted file mode 100644 index ce18c60cb5f..00000000000 --- a/resource-manager/apimanagement/2022-08-01/namedvalue/method_get_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package namedvalue - -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 *NamedValueContract -} - -// Get ... -func (c NamedValueClient) Get(ctx context.Context, id NamedValueId) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "namedvalue.NamedValueClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "namedvalue.NamedValueClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "namedvalue.NamedValueClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c NamedValueClient) preparerForGet(ctx context.Context, id NamedValueId) (*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 NamedValueClient) 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/apimanagement/2022-08-01/namedvalue/method_getentitytag.go b/resource-manager/apimanagement/2022-08-01/namedvalue/method_getentitytag.go new file mode 100644 index 00000000000..d292a66e0af --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/namedvalue/method_getentitytag.go @@ -0,0 +1,46 @@ +package namedvalue + +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 GetEntityTagOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// GetEntityTag ... +func (c NamedValueClient) GetEntityTag(ctx context.Context, id NamedValueId) (result GetEntityTagOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodHead, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2022-08-01/namedvalue/method_getentitytag_autorest.go b/resource-manager/apimanagement/2022-08-01/namedvalue/method_getentitytag_autorest.go deleted file mode 100644 index ac30709913d..00000000000 --- a/resource-manager/apimanagement/2022-08-01/namedvalue/method_getentitytag_autorest.go +++ /dev/null @@ -1,66 +0,0 @@ -package namedvalue - -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 GetEntityTagOperationResponse struct { - HttpResponse *http.Response -} - -// GetEntityTag ... -func (c NamedValueClient) GetEntityTag(ctx context.Context, id NamedValueId) (result GetEntityTagOperationResponse, err error) { - req, err := c.preparerForGetEntityTag(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "namedvalue.NamedValueClient", "GetEntityTag", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "namedvalue.NamedValueClient", "GetEntityTag", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetEntityTag(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "namedvalue.NamedValueClient", "GetEntityTag", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetEntityTag prepares the GetEntityTag request. -func (c NamedValueClient) preparerForGetEntityTag(ctx context.Context, id NamedValueId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsHead(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetEntityTag handles the response to the GetEntityTag request. The method always -// closes the http.Response Body. -func (c NamedValueClient) responderForGetEntityTag(resp *http.Response) (result GetEntityTagOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2022-08-01/namedvalue/method_listbyservice.go b/resource-manager/apimanagement/2022-08-01/namedvalue/method_listbyservice.go new file mode 100644 index 00000000000..ebb1b6b4849 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/namedvalue/method_listbyservice.go @@ -0,0 +1,129 @@ +package namedvalue + +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 ListByServiceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]NamedValueContract +} + +type ListByServiceCompleteResult struct { + Items []NamedValueContract +} + +type ListByServiceOperationOptions struct { + Filter *string + IsKeyVaultRefreshFailed *bool + Skip *int64 + Top *int64 +} + +func DefaultListByServiceOperationOptions() ListByServiceOperationOptions { + return ListByServiceOperationOptions{} +} + +func (o ListByServiceOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListByServiceOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListByServiceOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.IsKeyVaultRefreshFailed != nil { + out.Append("isKeyVaultRefreshFailed", fmt.Sprintf("%v", *o.IsKeyVaultRefreshFailed)) + } + if o.Skip != nil { + out.Append("$skip", fmt.Sprintf("%v", *o.Skip)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +// ListByService ... +func (c NamedValueClient) ListByService(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (result ListByServiceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/namedValues", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]NamedValueContract `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByServiceComplete retrieves all the results into a single object +func (c NamedValueClient) ListByServiceComplete(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (ListByServiceCompleteResult, error) { + return c.ListByServiceCompleteMatchingPredicate(ctx, id, options, NamedValueContractOperationPredicate{}) +} + +// ListByServiceCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c NamedValueClient) ListByServiceCompleteMatchingPredicate(ctx context.Context, id ServiceId, options ListByServiceOperationOptions, predicate NamedValueContractOperationPredicate) (result ListByServiceCompleteResult, err error) { + items := make([]NamedValueContract, 0) + + resp, err := c.ListByService(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByServiceCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/apimanagement/2022-08-01/namedvalue/method_listbyservice_autorest.go b/resource-manager/apimanagement/2022-08-01/namedvalue/method_listbyservice_autorest.go deleted file mode 100644 index cbfcd1b0b7b..00000000000 --- a/resource-manager/apimanagement/2022-08-01/namedvalue/method_listbyservice_autorest.go +++ /dev/null @@ -1,230 +0,0 @@ -package namedvalue - -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 ListByServiceOperationResponse struct { - HttpResponse *http.Response - Model *[]NamedValueContract - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListByServiceOperationResponse, error) -} - -type ListByServiceCompleteResult struct { - Items []NamedValueContract -} - -func (r ListByServiceOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListByServiceOperationResponse) LoadMore(ctx context.Context) (resp ListByServiceOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -type ListByServiceOperationOptions struct { - Filter *string - IsKeyVaultRefreshFailed *bool - Skip *int64 - Top *int64 -} - -func DefaultListByServiceOperationOptions() ListByServiceOperationOptions { - return ListByServiceOperationOptions{} -} - -func (o ListByServiceOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o ListByServiceOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Filter != nil { - out["$filter"] = *o.Filter - } - - if o.IsKeyVaultRefreshFailed != nil { - out["isKeyVaultRefreshFailed"] = *o.IsKeyVaultRefreshFailed - } - - if o.Skip != nil { - out["$skip"] = *o.Skip - } - - if o.Top != nil { - out["$top"] = *o.Top - } - - return out -} - -// ListByService ... -func (c NamedValueClient) ListByService(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (resp ListByServiceOperationResponse, err error) { - req, err := c.preparerForListByService(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "namedvalue.NamedValueClient", "ListByService", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "namedvalue.NamedValueClient", "ListByService", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListByService(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "namedvalue.NamedValueClient", "ListByService", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListByService prepares the ListByService request. -func (c NamedValueClient) preparerForListByService(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/namedValues", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListByServiceWithNextLink prepares the ListByService request with the given nextLink token. -func (c NamedValueClient) preparerForListByServiceWithNextLink(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)) -} - -// responderForListByService handles the response to the ListByService request. The method always -// closes the http.Response Body. -func (c NamedValueClient) responderForListByService(resp *http.Response) (result ListByServiceOperationResponse, err error) { - type page struct { - Values []NamedValueContract `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 ListByServiceOperationResponse, err error) { - req, err := c.preparerForListByServiceWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "namedvalue.NamedValueClient", "ListByService", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "namedvalue.NamedValueClient", "ListByService", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByService(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "namedvalue.NamedValueClient", "ListByService", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListByServiceComplete retrieves all of the results into a single object -func (c NamedValueClient) ListByServiceComplete(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (ListByServiceCompleteResult, error) { - return c.ListByServiceCompleteMatchingPredicate(ctx, id, options, NamedValueContractOperationPredicate{}) -} - -// ListByServiceCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c NamedValueClient) ListByServiceCompleteMatchingPredicate(ctx context.Context, id ServiceId, options ListByServiceOperationOptions, predicate NamedValueContractOperationPredicate) (resp ListByServiceCompleteResult, err error) { - items := make([]NamedValueContract, 0) - - page, err := c.ListByService(ctx, id, options) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListByServiceCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/apimanagement/2022-08-01/namedvalue/method_listvalue.go b/resource-manager/apimanagement/2022-08-01/namedvalue/method_listvalue.go new file mode 100644 index 00000000000..4dbf0997989 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/namedvalue/method_listvalue.go @@ -0,0 +1,52 @@ +package namedvalue + +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 ListValueOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *NamedValueSecretContract +} + +// ListValue ... +func (c NamedValueClient) ListValue(ctx context.Context, id NamedValueId) (result ListValueOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/listValue", 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/apimanagement/2022-08-01/namedvalue/method_listvalue_autorest.go b/resource-manager/apimanagement/2022-08-01/namedvalue/method_listvalue_autorest.go deleted file mode 100644 index 0370e762206..00000000000 --- a/resource-manager/apimanagement/2022-08-01/namedvalue/method_listvalue_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package namedvalue - -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 ListValueOperationResponse struct { - HttpResponse *http.Response - Model *NamedValueSecretContract -} - -// ListValue ... -func (c NamedValueClient) ListValue(ctx context.Context, id NamedValueId) (result ListValueOperationResponse, err error) { - req, err := c.preparerForListValue(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "namedvalue.NamedValueClient", "ListValue", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "namedvalue.NamedValueClient", "ListValue", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListValue(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "namedvalue.NamedValueClient", "ListValue", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForListValue prepares the ListValue request. -func (c NamedValueClient) preparerForListValue(ctx context.Context, id NamedValueId) (*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/listValue", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListValue handles the response to the ListValue request. The method always -// closes the http.Response Body. -func (c NamedValueClient) responderForListValue(resp *http.Response) (result ListValueOperationResponse, 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/apimanagement/2022-08-01/namedvalue/method_refreshsecret.go b/resource-manager/apimanagement/2022-08-01/namedvalue/method_refreshsecret.go new file mode 100644 index 00000000000..0dd3a006aec --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/namedvalue/method_refreshsecret.go @@ -0,0 +1,70 @@ +package namedvalue + +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 RefreshSecretOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// RefreshSecret ... +func (c NamedValueClient) RefreshSecret(ctx context.Context, id NamedValueId) (result RefreshSecretOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/refreshSecret", 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 +} + +// RefreshSecretThenPoll performs RefreshSecret then polls until it's completed +func (c NamedValueClient) RefreshSecretThenPoll(ctx context.Context, id NamedValueId) error { + result, err := c.RefreshSecret(ctx, id) + if err != nil { + return fmt.Errorf("performing RefreshSecret: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after RefreshSecret: %+v", err) + } + + return nil +} diff --git a/resource-manager/apimanagement/2022-08-01/namedvalue/method_refreshsecret_autorest.go b/resource-manager/apimanagement/2022-08-01/namedvalue/method_refreshsecret_autorest.go deleted file mode 100644 index 7574f5aaaf5..00000000000 --- a/resource-manager/apimanagement/2022-08-01/namedvalue/method_refreshsecret_autorest.go +++ /dev/null @@ -1,78 +0,0 @@ -package namedvalue - -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 RefreshSecretOperationResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// RefreshSecret ... -func (c NamedValueClient) RefreshSecret(ctx context.Context, id NamedValueId) (result RefreshSecretOperationResponse, err error) { - req, err := c.preparerForRefreshSecret(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "namedvalue.NamedValueClient", "RefreshSecret", nil, "Failure preparing request") - return - } - - result, err = c.senderForRefreshSecret(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "namedvalue.NamedValueClient", "RefreshSecret", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// RefreshSecretThenPoll performs RefreshSecret then polls until it's completed -func (c NamedValueClient) RefreshSecretThenPoll(ctx context.Context, id NamedValueId) error { - result, err := c.RefreshSecret(ctx, id) - if err != nil { - return fmt.Errorf("performing RefreshSecret: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after RefreshSecret: %+v", err) - } - - return nil -} - -// preparerForRefreshSecret prepares the RefreshSecret request. -func (c NamedValueClient) preparerForRefreshSecret(ctx context.Context, id NamedValueId) (*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/refreshSecret", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForRefreshSecret sends the RefreshSecret request. The method will close the -// http.Response Body if it receives an error. -func (c NamedValueClient) senderForRefreshSecret(ctx context.Context, req *http.Request) (future RefreshSecretOperationResponse, 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/apimanagement/2022-08-01/namedvalue/method_update.go b/resource-manager/apimanagement/2022-08-01/namedvalue/method_update.go new file mode 100644 index 00000000000..83793e803c7 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/namedvalue/method_update.go @@ -0,0 +1,102 @@ +package namedvalue + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +type UpdateOperationOptions struct { + IfMatch *string +} + +func DefaultUpdateOperationOptions() UpdateOperationOptions { + return UpdateOperationOptions{} +} + +func (o UpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o UpdateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o UpdateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// Update ... +func (c NamedValueClient) Update(ctx context.Context, id NamedValueId, input NamedValueUpdateParameters, options UpdateOperationOptions) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// UpdateThenPoll performs Update then polls until it's completed +func (c NamedValueClient) UpdateThenPoll(ctx context.Context, id NamedValueId, input NamedValueUpdateParameters, options UpdateOperationOptions) error { + result, err := c.Update(ctx, id, input, options) + if err != nil { + return fmt.Errorf("performing Update: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Update: %+v", err) + } + + return nil +} diff --git a/resource-manager/apimanagement/2022-08-01/namedvalue/method_update_autorest.go b/resource-manager/apimanagement/2022-08-01/namedvalue/method_update_autorest.go deleted file mode 100644 index 9de4e8a7883..00000000000 --- a/resource-manager/apimanagement/2022-08-01/namedvalue/method_update_autorest.go +++ /dev/null @@ -1,108 +0,0 @@ -package namedvalue - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type UpdateOperationResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -type UpdateOperationOptions struct { - IfMatch *string -} - -func DefaultUpdateOperationOptions() UpdateOperationOptions { - return UpdateOperationOptions{} -} - -func (o UpdateOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o UpdateOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// Update ... -func (c NamedValueClient) Update(ctx context.Context, id NamedValueId, input NamedValueUpdateParameters, options UpdateOperationOptions) (result UpdateOperationResponse, err error) { - req, err := c.preparerForUpdate(ctx, id, input, options) - if err != nil { - err = autorest.NewErrorWithError(err, "namedvalue.NamedValueClient", "Update", nil, "Failure preparing request") - return - } - - result, err = c.senderForUpdate(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "namedvalue.NamedValueClient", "Update", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// UpdateThenPoll performs Update then polls until it's completed -func (c NamedValueClient) UpdateThenPoll(ctx context.Context, id NamedValueId, input NamedValueUpdateParameters, options UpdateOperationOptions) error { - result, err := c.Update(ctx, id, input, options) - if err != nil { - return fmt.Errorf("performing Update: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after Update: %+v", err) - } - - return nil -} - -// preparerForUpdate prepares the Update request. -func (c NamedValueClient) preparerForUpdate(ctx context.Context, id NamedValueId, input NamedValueUpdateParameters, options UpdateOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPatch(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForUpdate sends the Update request. The method will close the -// http.Response Body if it receives an error. -func (c NamedValueClient) senderForUpdate(ctx context.Context, req *http.Request) (future UpdateOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/apimanagement/2022-08-01/networkstatus/client.go b/resource-manager/apimanagement/2022-08-01/networkstatus/client.go index 7d6f9215235..029c8296963 100644 --- a/resource-manager/apimanagement/2022-08-01/networkstatus/client.go +++ b/resource-manager/apimanagement/2022-08-01/networkstatus/client.go @@ -1,18 +1,26 @@ package networkstatus -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 NetworkStatusClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewNetworkStatusClientWithBaseURI(endpoint string) NetworkStatusClient { - return NetworkStatusClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewNetworkStatusClientWithBaseURI(api environments.Api) (*NetworkStatusClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "networkstatus", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating NetworkStatusClient: %+v", err) } + + return &NetworkStatusClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2022-08-01/networkstatus/constants.go b/resource-manager/apimanagement/2022-08-01/networkstatus/constants.go index fe5f4ceaf1c..caf05ed6a2c 100644 --- a/resource-manager/apimanagement/2022-08-01/networkstatus/constants.go +++ b/resource-manager/apimanagement/2022-08-01/networkstatus/constants.go @@ -1,6 +1,10 @@ package networkstatus -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 PossibleValuesForConnectivityStatusType() []string { } } +func (s *ConnectivityStatusType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseConnectivityStatusType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseConnectivityStatusType(input string) (*ConnectivityStatusType, error) { vals := map[string]ConnectivityStatusType{ "failure": ConnectivityStatusTypeFailure, diff --git a/resource-manager/apimanagement/2022-08-01/networkstatus/method_listbylocation.go b/resource-manager/apimanagement/2022-08-01/networkstatus/method_listbylocation.go new file mode 100644 index 00000000000..040ec0de64d --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/networkstatus/method_listbylocation.go @@ -0,0 +1,52 @@ +package networkstatus + +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 ListByLocationOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *NetworkStatusContract +} + +// ListByLocation ... +func (c NetworkStatusClient) ListByLocation(ctx context.Context, id LocationId) (result ListByLocationOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/networkstatus", 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/apimanagement/2022-08-01/networkstatus/method_listbylocation_autorest.go b/resource-manager/apimanagement/2022-08-01/networkstatus/method_listbylocation_autorest.go deleted file mode 100644 index bd98a6e965e..00000000000 --- a/resource-manager/apimanagement/2022-08-01/networkstatus/method_listbylocation_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package networkstatus - -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 ListByLocationOperationResponse struct { - HttpResponse *http.Response - Model *NetworkStatusContract -} - -// ListByLocation ... -func (c NetworkStatusClient) ListByLocation(ctx context.Context, id LocationId) (result ListByLocationOperationResponse, err error) { - req, err := c.preparerForListByLocation(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "networkstatus.NetworkStatusClient", "ListByLocation", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "networkstatus.NetworkStatusClient", "ListByLocation", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByLocation(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "networkstatus.NetworkStatusClient", "ListByLocation", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForListByLocation prepares the ListByLocation request. -func (c NetworkStatusClient) preparerForListByLocation(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/networkstatus", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListByLocation handles the response to the ListByLocation request. The method always -// closes the http.Response Body. -func (c NetworkStatusClient) responderForListByLocation(resp *http.Response) (result ListByLocationOperationResponse, 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/apimanagement/2022-08-01/networkstatus/method_listbyservice.go b/resource-manager/apimanagement/2022-08-01/networkstatus/method_listbyservice.go new file mode 100644 index 00000000000..509a1b2da91 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/networkstatus/method_listbyservice.go @@ -0,0 +1,52 @@ +package networkstatus + +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 ListByServiceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]NetworkStatusContractByLocation +} + +// ListByService ... +func (c NetworkStatusClient) ListByService(ctx context.Context, id ServiceId) (result ListByServiceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/networkstatus", 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/apimanagement/2022-08-01/networkstatus/method_listbyservice_autorest.go b/resource-manager/apimanagement/2022-08-01/networkstatus/method_listbyservice_autorest.go deleted file mode 100644 index e5f374af6e0..00000000000 --- a/resource-manager/apimanagement/2022-08-01/networkstatus/method_listbyservice_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package networkstatus - -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 ListByServiceOperationResponse struct { - HttpResponse *http.Response - Model *[]NetworkStatusContractByLocation -} - -// ListByService ... -func (c NetworkStatusClient) ListByService(ctx context.Context, id ServiceId) (result ListByServiceOperationResponse, err error) { - req, err := c.preparerForListByService(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "networkstatus.NetworkStatusClient", "ListByService", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "networkstatus.NetworkStatusClient", "ListByService", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByService(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "networkstatus.NetworkStatusClient", "ListByService", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForListByService prepares the ListByService request. -func (c NetworkStatusClient) preparerForListByService(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(fmt.Sprintf("%s/networkstatus", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListByService handles the response to the ListByService request. The method always -// closes the http.Response Body. -func (c NetworkStatusClient) responderForListByService(resp *http.Response) (result ListByServiceOperationResponse, 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/apimanagement/2022-08-01/notification/client.go b/resource-manager/apimanagement/2022-08-01/notification/client.go index 090f6db749d..3d20bbeb2ef 100644 --- a/resource-manager/apimanagement/2022-08-01/notification/client.go +++ b/resource-manager/apimanagement/2022-08-01/notification/client.go @@ -1,18 +1,26 @@ package notification -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 NotificationClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewNotificationClientWithBaseURI(endpoint string) NotificationClient { - return NotificationClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewNotificationClientWithBaseURI(api environments.Api) (*NotificationClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "notification", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating NotificationClient: %+v", err) } + + return &NotificationClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2022-08-01/notification/constants.go b/resource-manager/apimanagement/2022-08-01/notification/constants.go index e4c9332d3bd..28634a3bb8e 100644 --- a/resource-manager/apimanagement/2022-08-01/notification/constants.go +++ b/resource-manager/apimanagement/2022-08-01/notification/constants.go @@ -1,6 +1,10 @@ package notification -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. @@ -29,6 +33,19 @@ func PossibleValuesForNotificationName() []string { } } +func (s *NotificationName) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNotificationName(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseNotificationName(input string) (*NotificationName, error) { vals := map[string]NotificationName{ "accountclosedpublisher": NotificationNameAccountClosedPublisher, diff --git a/resource-manager/apimanagement/2022-08-01/notification/method_createorupdate.go b/resource-manager/apimanagement/2022-08-01/notification/method_createorupdate.go new file mode 100644 index 00000000000..f1f56dbe3ba --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/notification/method_createorupdate.go @@ -0,0 +1,80 @@ +package notification + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *NotificationContract +} + +type CreateOrUpdateOperationOptions struct { + IfMatch *string +} + +func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { + return CreateOrUpdateOperationOptions{} +} + +func (o CreateOrUpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o CreateOrUpdateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o CreateOrUpdateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// CreateOrUpdate ... +func (c NotificationClient) CreateOrUpdate(ctx context.Context, id NotificationId, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + OptionsObject: options, + } + + 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/apimanagement/2022-08-01/notification/method_createorupdate_autorest.go b/resource-manager/apimanagement/2022-08-01/notification/method_createorupdate_autorest.go deleted file mode 100644 index 129cedaaadd..00000000000 --- a/resource-manager/apimanagement/2022-08-01/notification/method_createorupdate_autorest.go +++ /dev/null @@ -1,97 +0,0 @@ -package notification - -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 *NotificationContract -} - -type CreateOrUpdateOperationOptions struct { - IfMatch *string -} - -func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { - return CreateOrUpdateOperationOptions{} -} - -func (o CreateOrUpdateOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o CreateOrUpdateOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// CreateOrUpdate ... -func (c NotificationClient) CreateOrUpdate(ctx context.Context, id NotificationId, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdate(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "notification.NotificationClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "notification.NotificationClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCreateOrUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "notification.NotificationClient", "CreateOrUpdate", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCreateOrUpdate prepares the CreateOrUpdate request. -func (c NotificationClient) preparerForCreateOrUpdate(ctx context.Context, id NotificationId, options CreateOrUpdateOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(id.ID()), - 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 NotificationClient) 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/apimanagement/2022-08-01/notification/method_get.go b/resource-manager/apimanagement/2022-08-01/notification/method_get.go new file mode 100644 index 00000000000..a5f0293b824 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/notification/method_get.go @@ -0,0 +1,51 @@ +package notification + +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 *NotificationContract +} + +// Get ... +func (c NotificationClient) Get(ctx context.Context, id NotificationId) (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/apimanagement/2022-08-01/notification/method_get_autorest.go b/resource-manager/apimanagement/2022-08-01/notification/method_get_autorest.go deleted file mode 100644 index 1290bcc6685..00000000000 --- a/resource-manager/apimanagement/2022-08-01/notification/method_get_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package notification - -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 *NotificationContract -} - -// Get ... -func (c NotificationClient) Get(ctx context.Context, id NotificationId) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "notification.NotificationClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "notification.NotificationClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "notification.NotificationClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c NotificationClient) preparerForGet(ctx context.Context, id NotificationId) (*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 NotificationClient) 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/apimanagement/2022-08-01/notification/method_listbyservice.go b/resource-manager/apimanagement/2022-08-01/notification/method_listbyservice.go new file mode 100644 index 00000000000..ec6e29b47c6 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/notification/method_listbyservice.go @@ -0,0 +1,121 @@ +package notification + +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 ListByServiceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]NotificationContract +} + +type ListByServiceCompleteResult struct { + Items []NotificationContract +} + +type ListByServiceOperationOptions struct { + Skip *int64 + Top *int64 +} + +func DefaultListByServiceOperationOptions() ListByServiceOperationOptions { + return ListByServiceOperationOptions{} +} + +func (o ListByServiceOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListByServiceOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListByServiceOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Skip != nil { + out.Append("$skip", fmt.Sprintf("%v", *o.Skip)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +// ListByService ... +func (c NotificationClient) ListByService(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (result ListByServiceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/notifications", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]NotificationContract `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByServiceComplete retrieves all the results into a single object +func (c NotificationClient) ListByServiceComplete(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (ListByServiceCompleteResult, error) { + return c.ListByServiceCompleteMatchingPredicate(ctx, id, options, NotificationContractOperationPredicate{}) +} + +// ListByServiceCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c NotificationClient) ListByServiceCompleteMatchingPredicate(ctx context.Context, id ServiceId, options ListByServiceOperationOptions, predicate NotificationContractOperationPredicate) (result ListByServiceCompleteResult, err error) { + items := make([]NotificationContract, 0) + + resp, err := c.ListByService(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByServiceCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/apimanagement/2022-08-01/notification/method_listbyservice_autorest.go b/resource-manager/apimanagement/2022-08-01/notification/method_listbyservice_autorest.go deleted file mode 100644 index d439d198b0c..00000000000 --- a/resource-manager/apimanagement/2022-08-01/notification/method_listbyservice_autorest.go +++ /dev/null @@ -1,220 +0,0 @@ -package notification - -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 ListByServiceOperationResponse struct { - HttpResponse *http.Response - Model *[]NotificationContract - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListByServiceOperationResponse, error) -} - -type ListByServiceCompleteResult struct { - Items []NotificationContract -} - -func (r ListByServiceOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListByServiceOperationResponse) LoadMore(ctx context.Context) (resp ListByServiceOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -type ListByServiceOperationOptions struct { - Skip *int64 - Top *int64 -} - -func DefaultListByServiceOperationOptions() ListByServiceOperationOptions { - return ListByServiceOperationOptions{} -} - -func (o ListByServiceOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o ListByServiceOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Skip != nil { - out["$skip"] = *o.Skip - } - - if o.Top != nil { - out["$top"] = *o.Top - } - - return out -} - -// ListByService ... -func (c NotificationClient) ListByService(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (resp ListByServiceOperationResponse, err error) { - req, err := c.preparerForListByService(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "notification.NotificationClient", "ListByService", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "notification.NotificationClient", "ListByService", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListByService(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "notification.NotificationClient", "ListByService", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListByService prepares the ListByService request. -func (c NotificationClient) preparerForListByService(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/notifications", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListByServiceWithNextLink prepares the ListByService request with the given nextLink token. -func (c NotificationClient) preparerForListByServiceWithNextLink(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)) -} - -// responderForListByService handles the response to the ListByService request. The method always -// closes the http.Response Body. -func (c NotificationClient) responderForListByService(resp *http.Response) (result ListByServiceOperationResponse, err error) { - type page struct { - Values []NotificationContract `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 ListByServiceOperationResponse, err error) { - req, err := c.preparerForListByServiceWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "notification.NotificationClient", "ListByService", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "notification.NotificationClient", "ListByService", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByService(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "notification.NotificationClient", "ListByService", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListByServiceComplete retrieves all of the results into a single object -func (c NotificationClient) ListByServiceComplete(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (ListByServiceCompleteResult, error) { - return c.ListByServiceCompleteMatchingPredicate(ctx, id, options, NotificationContractOperationPredicate{}) -} - -// ListByServiceCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c NotificationClient) ListByServiceCompleteMatchingPredicate(ctx context.Context, id ServiceId, options ListByServiceOperationOptions, predicate NotificationContractOperationPredicate) (resp ListByServiceCompleteResult, err error) { - items := make([]NotificationContract, 0) - - page, err := c.ListByService(ctx, id, options) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListByServiceCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/apimanagement/2022-08-01/notificationrecipientemail/client.go b/resource-manager/apimanagement/2022-08-01/notificationrecipientemail/client.go index 6f974759762..9479afea2f0 100644 --- a/resource-manager/apimanagement/2022-08-01/notificationrecipientemail/client.go +++ b/resource-manager/apimanagement/2022-08-01/notificationrecipientemail/client.go @@ -1,18 +1,26 @@ package notificationrecipientemail -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 NotificationRecipientEmailClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewNotificationRecipientEmailClientWithBaseURI(endpoint string) NotificationRecipientEmailClient { - return NotificationRecipientEmailClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewNotificationRecipientEmailClientWithBaseURI(api environments.Api) (*NotificationRecipientEmailClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "notificationrecipientemail", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating NotificationRecipientEmailClient: %+v", err) } + + return &NotificationRecipientEmailClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2022-08-01/notificationrecipientemail/constants.go b/resource-manager/apimanagement/2022-08-01/notificationrecipientemail/constants.go index e48b9eee0a2..85940aee54e 100644 --- a/resource-manager/apimanagement/2022-08-01/notificationrecipientemail/constants.go +++ b/resource-manager/apimanagement/2022-08-01/notificationrecipientemail/constants.go @@ -1,6 +1,10 @@ package notificationrecipientemail -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. @@ -29,6 +33,19 @@ func PossibleValuesForNotificationName() []string { } } +func (s *NotificationName) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNotificationName(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseNotificationName(input string) (*NotificationName, error) { vals := map[string]NotificationName{ "accountclosedpublisher": NotificationNameAccountClosedPublisher, diff --git a/resource-manager/apimanagement/2022-08-01/notificationrecipientemail/method_checkentityexists.go b/resource-manager/apimanagement/2022-08-01/notificationrecipientemail/method_checkentityexists.go new file mode 100644 index 00000000000..acddee29b82 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/notificationrecipientemail/method_checkentityexists.go @@ -0,0 +1,46 @@ +package notificationrecipientemail + +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 CheckEntityExistsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// CheckEntityExists ... +func (c NotificationRecipientEmailClient) CheckEntityExists(ctx context.Context, id RecipientEmailId) (result CheckEntityExistsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: http.MethodHead, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2022-08-01/notificationrecipientemail/method_checkentityexists_autorest.go b/resource-manager/apimanagement/2022-08-01/notificationrecipientemail/method_checkentityexists_autorest.go deleted file mode 100644 index da1fef7c04b..00000000000 --- a/resource-manager/apimanagement/2022-08-01/notificationrecipientemail/method_checkentityexists_autorest.go +++ /dev/null @@ -1,66 +0,0 @@ -package notificationrecipientemail - -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 CheckEntityExistsOperationResponse struct { - HttpResponse *http.Response -} - -// CheckEntityExists ... -func (c NotificationRecipientEmailClient) CheckEntityExists(ctx context.Context, id RecipientEmailId) (result CheckEntityExistsOperationResponse, err error) { - req, err := c.preparerForCheckEntityExists(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "notificationrecipientemail.NotificationRecipientEmailClient", "CheckEntityExists", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "notificationrecipientemail.NotificationRecipientEmailClient", "CheckEntityExists", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCheckEntityExists(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "notificationrecipientemail.NotificationRecipientEmailClient", "CheckEntityExists", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCheckEntityExists prepares the CheckEntityExists request. -func (c NotificationRecipientEmailClient) preparerForCheckEntityExists(ctx context.Context, id RecipientEmailId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsHead(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForCheckEntityExists handles the response to the CheckEntityExists request. The method always -// closes the http.Response Body. -func (c NotificationRecipientEmailClient) responderForCheckEntityExists(resp *http.Response) (result CheckEntityExistsOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2022-08-01/notificationrecipientemail/method_createorupdate.go b/resource-manager/apimanagement/2022-08-01/notificationrecipientemail/method_createorupdate.go new file mode 100644 index 00000000000..076065b12a4 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/notificationrecipientemail/method_createorupdate.go @@ -0,0 +1,52 @@ +package notificationrecipientemail + +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 *RecipientEmailContract +} + +// CreateOrUpdate ... +func (c NotificationRecipientEmailClient) CreateOrUpdate(ctx context.Context, id RecipientEmailId) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + 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/apimanagement/2022-08-01/notificationrecipientemail/method_createorupdate_autorest.go b/resource-manager/apimanagement/2022-08-01/notificationrecipientemail/method_createorupdate_autorest.go deleted file mode 100644 index 54e5266a7f4..00000000000 --- a/resource-manager/apimanagement/2022-08-01/notificationrecipientemail/method_createorupdate_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package notificationrecipientemail - -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 *RecipientEmailContract -} - -// CreateOrUpdate ... -func (c NotificationRecipientEmailClient) CreateOrUpdate(ctx context.Context, id RecipientEmailId) (result CreateOrUpdateOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdate(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "notificationrecipientemail.NotificationRecipientEmailClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "notificationrecipientemail.NotificationRecipientEmailClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCreateOrUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "notificationrecipientemail.NotificationRecipientEmailClient", "CreateOrUpdate", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCreateOrUpdate prepares the CreateOrUpdate request. -func (c NotificationRecipientEmailClient) preparerForCreateOrUpdate(ctx context.Context, id RecipientEmailId) (*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.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 NotificationRecipientEmailClient) responderForCreateOrUpdate(resp *http.Response) (result CreateOrUpdateOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2022-08-01/notificationrecipientemail/method_delete.go b/resource-manager/apimanagement/2022-08-01/notificationrecipientemail/method_delete.go new file mode 100644 index 00000000000..083dbc0417f --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/notificationrecipientemail/method_delete.go @@ -0,0 +1,47 @@ +package notificationrecipientemail + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c NotificationRecipientEmailClient) Delete(ctx context.Context, id RecipientEmailId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2022-08-01/notificationrecipientemail/method_delete_autorest.go b/resource-manager/apimanagement/2022-08-01/notificationrecipientemail/method_delete_autorest.go deleted file mode 100644 index c38e5d32b20..00000000000 --- a/resource-manager/apimanagement/2022-08-01/notificationrecipientemail/method_delete_autorest.go +++ /dev/null @@ -1,66 +0,0 @@ -package notificationrecipientemail - -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 DeleteOperationResponse struct { - HttpResponse *http.Response -} - -// Delete ... -func (c NotificationRecipientEmailClient) Delete(ctx context.Context, id RecipientEmailId) (result DeleteOperationResponse, err error) { - req, err := c.preparerForDelete(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "notificationrecipientemail.NotificationRecipientEmailClient", "Delete", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "notificationrecipientemail.NotificationRecipientEmailClient", "Delete", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForDelete(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "notificationrecipientemail.NotificationRecipientEmailClient", "Delete", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForDelete prepares the Delete request. -func (c NotificationRecipientEmailClient) preparerForDelete(ctx context.Context, id RecipientEmailId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForDelete handles the response to the Delete request. The method always -// closes the http.Response Body. -func (c NotificationRecipientEmailClient) responderForDelete(resp *http.Response) (result DeleteOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2022-08-01/notificationrecipientemail/method_listbynotification.go b/resource-manager/apimanagement/2022-08-01/notificationrecipientemail/method_listbynotification.go new file mode 100644 index 00000000000..091cf193ce9 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/notificationrecipientemail/method_listbynotification.go @@ -0,0 +1,52 @@ +package notificationrecipientemail + +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 ListByNotificationOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *RecipientEmailCollection +} + +// ListByNotification ... +func (c NotificationRecipientEmailClient) ListByNotification(ctx context.Context, id NotificationId) (result ListByNotificationOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/recipientEmails", 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/apimanagement/2022-08-01/notificationrecipientemail/method_listbynotification_autorest.go b/resource-manager/apimanagement/2022-08-01/notificationrecipientemail/method_listbynotification_autorest.go deleted file mode 100644 index c694b327a26..00000000000 --- a/resource-manager/apimanagement/2022-08-01/notificationrecipientemail/method_listbynotification_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package notificationrecipientemail - -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 ListByNotificationOperationResponse struct { - HttpResponse *http.Response - Model *RecipientEmailCollection -} - -// ListByNotification ... -func (c NotificationRecipientEmailClient) ListByNotification(ctx context.Context, id NotificationId) (result ListByNotificationOperationResponse, err error) { - req, err := c.preparerForListByNotification(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "notificationrecipientemail.NotificationRecipientEmailClient", "ListByNotification", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "notificationrecipientemail.NotificationRecipientEmailClient", "ListByNotification", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByNotification(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "notificationrecipientemail.NotificationRecipientEmailClient", "ListByNotification", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForListByNotification prepares the ListByNotification request. -func (c NotificationRecipientEmailClient) preparerForListByNotification(ctx context.Context, id NotificationId) (*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/recipientEmails", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListByNotification handles the response to the ListByNotification request. The method always -// closes the http.Response Body. -func (c NotificationRecipientEmailClient) responderForListByNotification(resp *http.Response) (result ListByNotificationOperationResponse, 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/apimanagement/2022-08-01/notificationrecipientuser/client.go b/resource-manager/apimanagement/2022-08-01/notificationrecipientuser/client.go index ee1917a9307..8d6c753120f 100644 --- a/resource-manager/apimanagement/2022-08-01/notificationrecipientuser/client.go +++ b/resource-manager/apimanagement/2022-08-01/notificationrecipientuser/client.go @@ -1,18 +1,26 @@ package notificationrecipientuser -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 NotificationRecipientUserClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewNotificationRecipientUserClientWithBaseURI(endpoint string) NotificationRecipientUserClient { - return NotificationRecipientUserClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewNotificationRecipientUserClientWithBaseURI(api environments.Api) (*NotificationRecipientUserClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "notificationrecipientuser", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating NotificationRecipientUserClient: %+v", err) } + + return &NotificationRecipientUserClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2022-08-01/notificationrecipientuser/constants.go b/resource-manager/apimanagement/2022-08-01/notificationrecipientuser/constants.go index 32178bd55a0..879dbf85c44 100644 --- a/resource-manager/apimanagement/2022-08-01/notificationrecipientuser/constants.go +++ b/resource-manager/apimanagement/2022-08-01/notificationrecipientuser/constants.go @@ -1,6 +1,10 @@ package notificationrecipientuser -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. @@ -29,6 +33,19 @@ func PossibleValuesForNotificationName() []string { } } +func (s *NotificationName) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNotificationName(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseNotificationName(input string) (*NotificationName, error) { vals := map[string]NotificationName{ "accountclosedpublisher": NotificationNameAccountClosedPublisher, diff --git a/resource-manager/apimanagement/2022-08-01/notificationrecipientuser/method_checkentityexists.go b/resource-manager/apimanagement/2022-08-01/notificationrecipientuser/method_checkentityexists.go new file mode 100644 index 00000000000..baae87b86d1 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/notificationrecipientuser/method_checkentityexists.go @@ -0,0 +1,46 @@ +package notificationrecipientuser + +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 CheckEntityExistsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// CheckEntityExists ... +func (c NotificationRecipientUserClient) CheckEntityExists(ctx context.Context, id RecipientUserId) (result CheckEntityExistsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: http.MethodHead, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2022-08-01/notificationrecipientuser/method_checkentityexists_autorest.go b/resource-manager/apimanagement/2022-08-01/notificationrecipientuser/method_checkentityexists_autorest.go deleted file mode 100644 index ddfad8eeecb..00000000000 --- a/resource-manager/apimanagement/2022-08-01/notificationrecipientuser/method_checkentityexists_autorest.go +++ /dev/null @@ -1,66 +0,0 @@ -package notificationrecipientuser - -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 CheckEntityExistsOperationResponse struct { - HttpResponse *http.Response -} - -// CheckEntityExists ... -func (c NotificationRecipientUserClient) CheckEntityExists(ctx context.Context, id RecipientUserId) (result CheckEntityExistsOperationResponse, err error) { - req, err := c.preparerForCheckEntityExists(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "notificationrecipientuser.NotificationRecipientUserClient", "CheckEntityExists", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "notificationrecipientuser.NotificationRecipientUserClient", "CheckEntityExists", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCheckEntityExists(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "notificationrecipientuser.NotificationRecipientUserClient", "CheckEntityExists", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCheckEntityExists prepares the CheckEntityExists request. -func (c NotificationRecipientUserClient) preparerForCheckEntityExists(ctx context.Context, id RecipientUserId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsHead(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForCheckEntityExists handles the response to the CheckEntityExists request. The method always -// closes the http.Response Body. -func (c NotificationRecipientUserClient) responderForCheckEntityExists(resp *http.Response) (result CheckEntityExistsOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2022-08-01/notificationrecipientuser/method_createorupdate.go b/resource-manager/apimanagement/2022-08-01/notificationrecipientuser/method_createorupdate.go new file mode 100644 index 00000000000..a9b12b60ca8 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/notificationrecipientuser/method_createorupdate.go @@ -0,0 +1,52 @@ +package notificationrecipientuser + +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 *RecipientUserContract +} + +// CreateOrUpdate ... +func (c NotificationRecipientUserClient) CreateOrUpdate(ctx context.Context, id RecipientUserId) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + 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/apimanagement/2022-08-01/notificationrecipientuser/method_createorupdate_autorest.go b/resource-manager/apimanagement/2022-08-01/notificationrecipientuser/method_createorupdate_autorest.go deleted file mode 100644 index 3c013a3fa62..00000000000 --- a/resource-manager/apimanagement/2022-08-01/notificationrecipientuser/method_createorupdate_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package notificationrecipientuser - -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 *RecipientUserContract -} - -// CreateOrUpdate ... -func (c NotificationRecipientUserClient) CreateOrUpdate(ctx context.Context, id RecipientUserId) (result CreateOrUpdateOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdate(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "notificationrecipientuser.NotificationRecipientUserClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "notificationrecipientuser.NotificationRecipientUserClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCreateOrUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "notificationrecipientuser.NotificationRecipientUserClient", "CreateOrUpdate", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCreateOrUpdate prepares the CreateOrUpdate request. -func (c NotificationRecipientUserClient) preparerForCreateOrUpdate(ctx context.Context, id RecipientUserId) (*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.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 NotificationRecipientUserClient) responderForCreateOrUpdate(resp *http.Response) (result CreateOrUpdateOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2022-08-01/notificationrecipientuser/method_delete.go b/resource-manager/apimanagement/2022-08-01/notificationrecipientuser/method_delete.go new file mode 100644 index 00000000000..d0bf672da2e --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/notificationrecipientuser/method_delete.go @@ -0,0 +1,47 @@ +package notificationrecipientuser + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c NotificationRecipientUserClient) Delete(ctx context.Context, id RecipientUserId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2022-08-01/notificationrecipientuser/method_delete_autorest.go b/resource-manager/apimanagement/2022-08-01/notificationrecipientuser/method_delete_autorest.go deleted file mode 100644 index 808cdd48ac5..00000000000 --- a/resource-manager/apimanagement/2022-08-01/notificationrecipientuser/method_delete_autorest.go +++ /dev/null @@ -1,66 +0,0 @@ -package notificationrecipientuser - -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 DeleteOperationResponse struct { - HttpResponse *http.Response -} - -// Delete ... -func (c NotificationRecipientUserClient) Delete(ctx context.Context, id RecipientUserId) (result DeleteOperationResponse, err error) { - req, err := c.preparerForDelete(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "notificationrecipientuser.NotificationRecipientUserClient", "Delete", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "notificationrecipientuser.NotificationRecipientUserClient", "Delete", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForDelete(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "notificationrecipientuser.NotificationRecipientUserClient", "Delete", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForDelete prepares the Delete request. -func (c NotificationRecipientUserClient) preparerForDelete(ctx context.Context, id RecipientUserId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForDelete handles the response to the Delete request. The method always -// closes the http.Response Body. -func (c NotificationRecipientUserClient) responderForDelete(resp *http.Response) (result DeleteOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2022-08-01/notificationrecipientuser/method_listbynotification.go b/resource-manager/apimanagement/2022-08-01/notificationrecipientuser/method_listbynotification.go new file mode 100644 index 00000000000..bfe4badf1f5 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/notificationrecipientuser/method_listbynotification.go @@ -0,0 +1,52 @@ +package notificationrecipientuser + +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 ListByNotificationOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *RecipientUserCollection +} + +// ListByNotification ... +func (c NotificationRecipientUserClient) ListByNotification(ctx context.Context, id NotificationId) (result ListByNotificationOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/recipientUsers", 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/apimanagement/2022-08-01/notificationrecipientuser/method_listbynotification_autorest.go b/resource-manager/apimanagement/2022-08-01/notificationrecipientuser/method_listbynotification_autorest.go deleted file mode 100644 index adefe67aec1..00000000000 --- a/resource-manager/apimanagement/2022-08-01/notificationrecipientuser/method_listbynotification_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package notificationrecipientuser - -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 ListByNotificationOperationResponse struct { - HttpResponse *http.Response - Model *RecipientUserCollection -} - -// ListByNotification ... -func (c NotificationRecipientUserClient) ListByNotification(ctx context.Context, id NotificationId) (result ListByNotificationOperationResponse, err error) { - req, err := c.preparerForListByNotification(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "notificationrecipientuser.NotificationRecipientUserClient", "ListByNotification", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "notificationrecipientuser.NotificationRecipientUserClient", "ListByNotification", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByNotification(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "notificationrecipientuser.NotificationRecipientUserClient", "ListByNotification", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForListByNotification prepares the ListByNotification request. -func (c NotificationRecipientUserClient) preparerForListByNotification(ctx context.Context, id NotificationId) (*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/recipientUsers", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListByNotification handles the response to the ListByNotification request. The method always -// closes the http.Response Body. -func (c NotificationRecipientUserClient) responderForListByNotification(resp *http.Response) (result ListByNotificationOperationResponse, 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/apimanagement/2022-08-01/openidconnectprovider/client.go b/resource-manager/apimanagement/2022-08-01/openidconnectprovider/client.go index 6e9956e13eb..f8cd6dda463 100644 --- a/resource-manager/apimanagement/2022-08-01/openidconnectprovider/client.go +++ b/resource-manager/apimanagement/2022-08-01/openidconnectprovider/client.go @@ -1,18 +1,26 @@ package openidconnectprovider -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 OpenidConnectProviderClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewOpenidConnectProviderClientWithBaseURI(endpoint string) OpenidConnectProviderClient { - return OpenidConnectProviderClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewOpenidConnectProviderClientWithBaseURI(api environments.Api) (*OpenidConnectProviderClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "openidconnectprovider", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating OpenidConnectProviderClient: %+v", err) } + + return &OpenidConnectProviderClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2022-08-01/openidconnectprovider/method_createorupdate.go b/resource-manager/apimanagement/2022-08-01/openidconnectprovider/method_createorupdate.go new file mode 100644 index 00000000000..022112dd8ee --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/openidconnectprovider/method_createorupdate.go @@ -0,0 +1,85 @@ +package openidconnectprovider + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *OpenidConnectProviderContract +} + +type CreateOrUpdateOperationOptions struct { + IfMatch *string +} + +func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { + return CreateOrUpdateOperationOptions{} +} + +func (o CreateOrUpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o CreateOrUpdateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o CreateOrUpdateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// CreateOrUpdate ... +func (c OpenidConnectProviderClient) CreateOrUpdate(ctx context.Context, id OpenidConnectProviderId, input OpenidConnectProviderContract, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + OptionsObject: options, + } + + 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/apimanagement/2022-08-01/openidconnectprovider/method_createorupdate_autorest.go b/resource-manager/apimanagement/2022-08-01/openidconnectprovider/method_createorupdate_autorest.go deleted file mode 100644 index 4dc253d0cac..00000000000 --- a/resource-manager/apimanagement/2022-08-01/openidconnectprovider/method_createorupdate_autorest.go +++ /dev/null @@ -1,98 +0,0 @@ -package openidconnectprovider - -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 *OpenidConnectProviderContract -} - -type CreateOrUpdateOperationOptions struct { - IfMatch *string -} - -func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { - return CreateOrUpdateOperationOptions{} -} - -func (o CreateOrUpdateOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o CreateOrUpdateOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// CreateOrUpdate ... -func (c OpenidConnectProviderClient) CreateOrUpdate(ctx context.Context, id OpenidConnectProviderId, input OpenidConnectProviderContract, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdate(ctx, id, input, options) - if err != nil { - err = autorest.NewErrorWithError(err, "openidconnectprovider.OpenidConnectProviderClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "openidconnectprovider.OpenidConnectProviderClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCreateOrUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "openidconnectprovider.OpenidConnectProviderClient", "CreateOrUpdate", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCreateOrUpdate prepares the CreateOrUpdate request. -func (c OpenidConnectProviderClient) preparerForCreateOrUpdate(ctx context.Context, id OpenidConnectProviderId, input OpenidConnectProviderContract, options CreateOrUpdateOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - 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 OpenidConnectProviderClient) responderForCreateOrUpdate(resp *http.Response) (result CreateOrUpdateOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2022-08-01/openidconnectprovider/method_delete.go b/resource-manager/apimanagement/2022-08-01/openidconnectprovider/method_delete.go new file mode 100644 index 00000000000..dd6f6bbf9c4 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/openidconnectprovider/method_delete.go @@ -0,0 +1,76 @@ +package openidconnectprovider + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +type DeleteOperationOptions struct { + IfMatch *string +} + +func DefaultDeleteOperationOptions() DeleteOperationOptions { + return DeleteOperationOptions{} +} + +func (o DeleteOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o DeleteOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o DeleteOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// Delete ... +func (c OpenidConnectProviderClient) Delete(ctx context.Context, id OpenidConnectProviderId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2022-08-01/openidconnectprovider/method_delete_autorest.go b/resource-manager/apimanagement/2022-08-01/openidconnectprovider/method_delete_autorest.go deleted file mode 100644 index e8d831f0dbf..00000000000 --- a/resource-manager/apimanagement/2022-08-01/openidconnectprovider/method_delete_autorest.go +++ /dev/null @@ -1,95 +0,0 @@ -package openidconnectprovider - -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 DeleteOperationResponse struct { - HttpResponse *http.Response -} - -type DeleteOperationOptions struct { - IfMatch *string -} - -func DefaultDeleteOperationOptions() DeleteOperationOptions { - return DeleteOperationOptions{} -} - -func (o DeleteOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o DeleteOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// Delete ... -func (c OpenidConnectProviderClient) Delete(ctx context.Context, id OpenidConnectProviderId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { - req, err := c.preparerForDelete(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "openidconnectprovider.OpenidConnectProviderClient", "Delete", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "openidconnectprovider.OpenidConnectProviderClient", "Delete", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForDelete(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "openidconnectprovider.OpenidConnectProviderClient", "Delete", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForDelete prepares the Delete request. -func (c OpenidConnectProviderClient) preparerForDelete(ctx context.Context, id OpenidConnectProviderId, options DeleteOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForDelete handles the response to the Delete request. The method always -// closes the http.Response Body. -func (c OpenidConnectProviderClient) responderForDelete(resp *http.Response) (result DeleteOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2022-08-01/openidconnectprovider/method_get.go b/resource-manager/apimanagement/2022-08-01/openidconnectprovider/method_get.go new file mode 100644 index 00000000000..25939c8a1ce --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/openidconnectprovider/method_get.go @@ -0,0 +1,51 @@ +package openidconnectprovider + +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 *OpenidConnectProviderContract +} + +// Get ... +func (c OpenidConnectProviderClient) Get(ctx context.Context, id OpenidConnectProviderId) (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/apimanagement/2022-08-01/openidconnectprovider/method_get_autorest.go b/resource-manager/apimanagement/2022-08-01/openidconnectprovider/method_get_autorest.go deleted file mode 100644 index b7d07f681e5..00000000000 --- a/resource-manager/apimanagement/2022-08-01/openidconnectprovider/method_get_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package openidconnectprovider - -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 *OpenidConnectProviderContract -} - -// Get ... -func (c OpenidConnectProviderClient) Get(ctx context.Context, id OpenidConnectProviderId) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "openidconnectprovider.OpenidConnectProviderClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "openidconnectprovider.OpenidConnectProviderClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "openidconnectprovider.OpenidConnectProviderClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c OpenidConnectProviderClient) preparerForGet(ctx context.Context, id OpenidConnectProviderId) (*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 OpenidConnectProviderClient) 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/apimanagement/2022-08-01/openidconnectprovider/method_getentitytag.go b/resource-manager/apimanagement/2022-08-01/openidconnectprovider/method_getentitytag.go new file mode 100644 index 00000000000..3f411d67cae --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/openidconnectprovider/method_getentitytag.go @@ -0,0 +1,46 @@ +package openidconnectprovider + +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 GetEntityTagOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// GetEntityTag ... +func (c OpenidConnectProviderClient) GetEntityTag(ctx context.Context, id OpenidConnectProviderId) (result GetEntityTagOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodHead, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2022-08-01/openidconnectprovider/method_getentitytag_autorest.go b/resource-manager/apimanagement/2022-08-01/openidconnectprovider/method_getentitytag_autorest.go deleted file mode 100644 index 02fdba1af30..00000000000 --- a/resource-manager/apimanagement/2022-08-01/openidconnectprovider/method_getentitytag_autorest.go +++ /dev/null @@ -1,66 +0,0 @@ -package openidconnectprovider - -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 GetEntityTagOperationResponse struct { - HttpResponse *http.Response -} - -// GetEntityTag ... -func (c OpenidConnectProviderClient) GetEntityTag(ctx context.Context, id OpenidConnectProviderId) (result GetEntityTagOperationResponse, err error) { - req, err := c.preparerForGetEntityTag(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "openidconnectprovider.OpenidConnectProviderClient", "GetEntityTag", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "openidconnectprovider.OpenidConnectProviderClient", "GetEntityTag", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetEntityTag(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "openidconnectprovider.OpenidConnectProviderClient", "GetEntityTag", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetEntityTag prepares the GetEntityTag request. -func (c OpenidConnectProviderClient) preparerForGetEntityTag(ctx context.Context, id OpenidConnectProviderId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsHead(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetEntityTag handles the response to the GetEntityTag request. The method always -// closes the http.Response Body. -func (c OpenidConnectProviderClient) responderForGetEntityTag(resp *http.Response) (result GetEntityTagOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2022-08-01/openidconnectprovider/method_listbyservice.go b/resource-manager/apimanagement/2022-08-01/openidconnectprovider/method_listbyservice.go new file mode 100644 index 00000000000..42ba42327c5 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/openidconnectprovider/method_listbyservice.go @@ -0,0 +1,125 @@ +package openidconnectprovider + +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 ListByServiceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]OpenidConnectProviderContract +} + +type ListByServiceCompleteResult struct { + Items []OpenidConnectProviderContract +} + +type ListByServiceOperationOptions struct { + Filter *string + Skip *int64 + Top *int64 +} + +func DefaultListByServiceOperationOptions() ListByServiceOperationOptions { + return ListByServiceOperationOptions{} +} + +func (o ListByServiceOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListByServiceOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListByServiceOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.Skip != nil { + out.Append("$skip", fmt.Sprintf("%v", *o.Skip)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +// ListByService ... +func (c OpenidConnectProviderClient) ListByService(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (result ListByServiceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/openidConnectProviders", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]OpenidConnectProviderContract `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByServiceComplete retrieves all the results into a single object +func (c OpenidConnectProviderClient) ListByServiceComplete(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (ListByServiceCompleteResult, error) { + return c.ListByServiceCompleteMatchingPredicate(ctx, id, options, OpenidConnectProviderContractOperationPredicate{}) +} + +// ListByServiceCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c OpenidConnectProviderClient) ListByServiceCompleteMatchingPredicate(ctx context.Context, id ServiceId, options ListByServiceOperationOptions, predicate OpenidConnectProviderContractOperationPredicate) (result ListByServiceCompleteResult, err error) { + items := make([]OpenidConnectProviderContract, 0) + + resp, err := c.ListByService(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByServiceCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/apimanagement/2022-08-01/openidconnectprovider/method_listbyservice_autorest.go b/resource-manager/apimanagement/2022-08-01/openidconnectprovider/method_listbyservice_autorest.go deleted file mode 100644 index e84f3a32000..00000000000 --- a/resource-manager/apimanagement/2022-08-01/openidconnectprovider/method_listbyservice_autorest.go +++ /dev/null @@ -1,225 +0,0 @@ -package openidconnectprovider - -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 ListByServiceOperationResponse struct { - HttpResponse *http.Response - Model *[]OpenidConnectProviderContract - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListByServiceOperationResponse, error) -} - -type ListByServiceCompleteResult struct { - Items []OpenidConnectProviderContract -} - -func (r ListByServiceOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListByServiceOperationResponse) LoadMore(ctx context.Context) (resp ListByServiceOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -type ListByServiceOperationOptions struct { - Filter *string - Skip *int64 - Top *int64 -} - -func DefaultListByServiceOperationOptions() ListByServiceOperationOptions { - return ListByServiceOperationOptions{} -} - -func (o ListByServiceOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o ListByServiceOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Filter != nil { - out["$filter"] = *o.Filter - } - - if o.Skip != nil { - out["$skip"] = *o.Skip - } - - if o.Top != nil { - out["$top"] = *o.Top - } - - return out -} - -// ListByService ... -func (c OpenidConnectProviderClient) ListByService(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (resp ListByServiceOperationResponse, err error) { - req, err := c.preparerForListByService(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "openidconnectprovider.OpenidConnectProviderClient", "ListByService", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "openidconnectprovider.OpenidConnectProviderClient", "ListByService", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListByService(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "openidconnectprovider.OpenidConnectProviderClient", "ListByService", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListByService prepares the ListByService request. -func (c OpenidConnectProviderClient) preparerForListByService(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/openidConnectProviders", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListByServiceWithNextLink prepares the ListByService request with the given nextLink token. -func (c OpenidConnectProviderClient) preparerForListByServiceWithNextLink(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)) -} - -// responderForListByService handles the response to the ListByService request. The method always -// closes the http.Response Body. -func (c OpenidConnectProviderClient) responderForListByService(resp *http.Response) (result ListByServiceOperationResponse, err error) { - type page struct { - Values []OpenidConnectProviderContract `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 ListByServiceOperationResponse, err error) { - req, err := c.preparerForListByServiceWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "openidconnectprovider.OpenidConnectProviderClient", "ListByService", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "openidconnectprovider.OpenidConnectProviderClient", "ListByService", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByService(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "openidconnectprovider.OpenidConnectProviderClient", "ListByService", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListByServiceComplete retrieves all of the results into a single object -func (c OpenidConnectProviderClient) ListByServiceComplete(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (ListByServiceCompleteResult, error) { - return c.ListByServiceCompleteMatchingPredicate(ctx, id, options, OpenidConnectProviderContractOperationPredicate{}) -} - -// ListByServiceCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c OpenidConnectProviderClient) ListByServiceCompleteMatchingPredicate(ctx context.Context, id ServiceId, options ListByServiceOperationOptions, predicate OpenidConnectProviderContractOperationPredicate) (resp ListByServiceCompleteResult, err error) { - items := make([]OpenidConnectProviderContract, 0) - - page, err := c.ListByService(ctx, id, options) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListByServiceCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/apimanagement/2022-08-01/openidconnectprovider/method_listsecrets.go b/resource-manager/apimanagement/2022-08-01/openidconnectprovider/method_listsecrets.go new file mode 100644 index 00000000000..d05b3d3c365 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/openidconnectprovider/method_listsecrets.go @@ -0,0 +1,52 @@ +package openidconnectprovider + +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 ListSecretsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ClientSecretContract +} + +// ListSecrets ... +func (c OpenidConnectProviderClient) ListSecrets(ctx context.Context, id OpenidConnectProviderId) (result ListSecretsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/listSecrets", 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/apimanagement/2022-08-01/openidconnectprovider/method_listsecrets_autorest.go b/resource-manager/apimanagement/2022-08-01/openidconnectprovider/method_listsecrets_autorest.go deleted file mode 100644 index df2556cf4f3..00000000000 --- a/resource-manager/apimanagement/2022-08-01/openidconnectprovider/method_listsecrets_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package openidconnectprovider - -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 ListSecretsOperationResponse struct { - HttpResponse *http.Response - Model *ClientSecretContract -} - -// ListSecrets ... -func (c OpenidConnectProviderClient) ListSecrets(ctx context.Context, id OpenidConnectProviderId) (result ListSecretsOperationResponse, err error) { - req, err := c.preparerForListSecrets(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "openidconnectprovider.OpenidConnectProviderClient", "ListSecrets", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "openidconnectprovider.OpenidConnectProviderClient", "ListSecrets", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListSecrets(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "openidconnectprovider.OpenidConnectProviderClient", "ListSecrets", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForListSecrets prepares the ListSecrets request. -func (c OpenidConnectProviderClient) preparerForListSecrets(ctx context.Context, id OpenidConnectProviderId) (*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/listSecrets", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListSecrets handles the response to the ListSecrets request. The method always -// closes the http.Response Body. -func (c OpenidConnectProviderClient) responderForListSecrets(resp *http.Response) (result ListSecretsOperationResponse, 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/apimanagement/2022-08-01/openidconnectprovider/method_update.go b/resource-manager/apimanagement/2022-08-01/openidconnectprovider/method_update.go new file mode 100644 index 00000000000..5b2402019c0 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/openidconnectprovider/method_update.go @@ -0,0 +1,84 @@ +package openidconnectprovider + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *OpenidConnectProviderContract +} + +type UpdateOperationOptions struct { + IfMatch *string +} + +func DefaultUpdateOperationOptions() UpdateOperationOptions { + return UpdateOperationOptions{} +} + +func (o UpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o UpdateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o UpdateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// Update ... +func (c OpenidConnectProviderClient) Update(ctx context.Context, id OpenidConnectProviderId, input OpenidConnectProviderUpdateContract, options UpdateOperationOptions) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + OptionsObject: options, + } + + 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/apimanagement/2022-08-01/openidconnectprovider/method_update_autorest.go b/resource-manager/apimanagement/2022-08-01/openidconnectprovider/method_update_autorest.go deleted file mode 100644 index 5f1845c884d..00000000000 --- a/resource-manager/apimanagement/2022-08-01/openidconnectprovider/method_update_autorest.go +++ /dev/null @@ -1,98 +0,0 @@ -package openidconnectprovider - -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 *OpenidConnectProviderContract -} - -type UpdateOperationOptions struct { - IfMatch *string -} - -func DefaultUpdateOperationOptions() UpdateOperationOptions { - return UpdateOperationOptions{} -} - -func (o UpdateOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o UpdateOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// Update ... -func (c OpenidConnectProviderClient) Update(ctx context.Context, id OpenidConnectProviderId, input OpenidConnectProviderUpdateContract, options UpdateOperationOptions) (result UpdateOperationResponse, err error) { - req, err := c.preparerForUpdate(ctx, id, input, options) - if err != nil { - err = autorest.NewErrorWithError(err, "openidconnectprovider.OpenidConnectProviderClient", "Update", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "openidconnectprovider.OpenidConnectProviderClient", "Update", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "openidconnectprovider.OpenidConnectProviderClient", "Update", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForUpdate prepares the Update request. -func (c OpenidConnectProviderClient) preparerForUpdate(ctx context.Context, id OpenidConnectProviderId, input OpenidConnectProviderUpdateContract, options UpdateOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPatch(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - 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 OpenidConnectProviderClient) 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/apimanagement/2022-08-01/outboundnetworkdependenciesendpoints/client.go b/resource-manager/apimanagement/2022-08-01/outboundnetworkdependenciesendpoints/client.go index 22c16a831a4..bdf407b2056 100644 --- a/resource-manager/apimanagement/2022-08-01/outboundnetworkdependenciesendpoints/client.go +++ b/resource-manager/apimanagement/2022-08-01/outboundnetworkdependenciesendpoints/client.go @@ -1,18 +1,26 @@ package outboundnetworkdependenciesendpoints -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 OutboundNetworkDependenciesEndpointsClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewOutboundNetworkDependenciesEndpointsClientWithBaseURI(endpoint string) OutboundNetworkDependenciesEndpointsClient { - return OutboundNetworkDependenciesEndpointsClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewOutboundNetworkDependenciesEndpointsClientWithBaseURI(api environments.Api) (*OutboundNetworkDependenciesEndpointsClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "outboundnetworkdependenciesendpoints", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating OutboundNetworkDependenciesEndpointsClient: %+v", err) } + + return &OutboundNetworkDependenciesEndpointsClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2022-08-01/outboundnetworkdependenciesendpoints/method_listbyservice.go b/resource-manager/apimanagement/2022-08-01/outboundnetworkdependenciesendpoints/method_listbyservice.go new file mode 100644 index 00000000000..32234f6b430 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/outboundnetworkdependenciesendpoints/method_listbyservice.go @@ -0,0 +1,52 @@ +package outboundnetworkdependenciesendpoints + +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 ListByServiceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *OutboundEnvironmentEndpointList +} + +// ListByService ... +func (c OutboundNetworkDependenciesEndpointsClient) ListByService(ctx context.Context, id ServiceId) (result ListByServiceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/outboundNetworkDependenciesEndpoints", 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/apimanagement/2022-08-01/outboundnetworkdependenciesendpoints/method_listbyservice_autorest.go b/resource-manager/apimanagement/2022-08-01/outboundnetworkdependenciesendpoints/method_listbyservice_autorest.go deleted file mode 100644 index 6c0aaf4214b..00000000000 --- a/resource-manager/apimanagement/2022-08-01/outboundnetworkdependenciesendpoints/method_listbyservice_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package outboundnetworkdependenciesendpoints - -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 ListByServiceOperationResponse struct { - HttpResponse *http.Response - Model *OutboundEnvironmentEndpointList -} - -// ListByService ... -func (c OutboundNetworkDependenciesEndpointsClient) ListByService(ctx context.Context, id ServiceId) (result ListByServiceOperationResponse, err error) { - req, err := c.preparerForListByService(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "outboundnetworkdependenciesendpoints.OutboundNetworkDependenciesEndpointsClient", "ListByService", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "outboundnetworkdependenciesendpoints.OutboundNetworkDependenciesEndpointsClient", "ListByService", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByService(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "outboundnetworkdependenciesendpoints.OutboundNetworkDependenciesEndpointsClient", "ListByService", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForListByService prepares the ListByService request. -func (c OutboundNetworkDependenciesEndpointsClient) preparerForListByService(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(fmt.Sprintf("%s/outboundNetworkDependenciesEndpoints", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListByService handles the response to the ListByService request. The method always -// closes the http.Response Body. -func (c OutboundNetworkDependenciesEndpointsClient) responderForListByService(resp *http.Response) (result ListByServiceOperationResponse, 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/apimanagement/2022-08-01/performconnectivitycheck/client.go b/resource-manager/apimanagement/2022-08-01/performconnectivitycheck/client.go index 9ad3cc36b7c..691170c7239 100644 --- a/resource-manager/apimanagement/2022-08-01/performconnectivitycheck/client.go +++ b/resource-manager/apimanagement/2022-08-01/performconnectivitycheck/client.go @@ -1,18 +1,26 @@ package performconnectivitycheck -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 PerformConnectivityCheckClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewPerformConnectivityCheckClientWithBaseURI(endpoint string) PerformConnectivityCheckClient { - return PerformConnectivityCheckClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewPerformConnectivityCheckClientWithBaseURI(api environments.Api) (*PerformConnectivityCheckClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "performconnectivitycheck", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating PerformConnectivityCheckClient: %+v", err) } + + return &PerformConnectivityCheckClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2022-08-01/performconnectivitycheck/constants.go b/resource-manager/apimanagement/2022-08-01/performconnectivitycheck/constants.go index 9bf9ce98491..df0ed03802b 100644 --- a/resource-manager/apimanagement/2022-08-01/performconnectivitycheck/constants.go +++ b/resource-manager/apimanagement/2022-08-01/performconnectivitycheck/constants.go @@ -1,6 +1,10 @@ package performconnectivitycheck -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 PossibleValuesForConnectionStatus() []string { } } +func (s *ConnectionStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseConnectionStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseConnectionStatus(input string) (*ConnectionStatus, error) { vals := map[string]ConnectionStatus{ "connected": ConnectionStatusConnected, @@ -55,6 +72,19 @@ func PossibleValuesForConnectivityCheckProtocol() []string { } } +func (s *ConnectivityCheckProtocol) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseConnectivityCheckProtocol(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseConnectivityCheckProtocol(input string) (*ConnectivityCheckProtocol, error) { vals := map[string]ConnectivityCheckProtocol{ "http": ConnectivityCheckProtocolHTTP, @@ -98,6 +128,19 @@ func PossibleValuesForIssueType() []string { } } +func (s *IssueType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseIssueType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseIssueType(input string) (*IssueType, error) { vals := map[string]IssueType{ "agentstopped": IssueTypeAgentStopped, @@ -133,6 +176,19 @@ func PossibleValuesForMethod() []string { } } +func (s *Method) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseMethod(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseMethod(input string) (*Method, error) { vals := map[string]Method{ "get": MethodGET, @@ -163,6 +219,19 @@ func PossibleValuesForOrigin() []string { } } +func (s *Origin) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseOrigin(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseOrigin(input string) (*Origin, error) { vals := map[string]Origin{ "inbound": OriginInbound, @@ -190,6 +259,19 @@ func PossibleValuesForPreferredIPVersion() []string { } } +func (s *PreferredIPVersion) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePreferredIPVersion(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parsePreferredIPVersion(input string) (*PreferredIPVersion, error) { vals := map[string]PreferredIPVersion{ "ipv4": PreferredIPVersionIPvFour, @@ -217,6 +299,19 @@ func PossibleValuesForSeverity() []string { } } +func (s *Severity) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSeverity(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseSeverity(input string) (*Severity, error) { vals := map[string]Severity{ "error": SeverityError, diff --git a/resource-manager/apimanagement/2022-08-01/performconnectivitycheck/method_async.go b/resource-manager/apimanagement/2022-08-01/performconnectivitycheck/method_async.go new file mode 100644 index 00000000000..ecb7574e628 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/performconnectivitycheck/method_async.go @@ -0,0 +1,74 @@ +package performconnectivitycheck + +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 AsyncOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Async ... +func (c PerformConnectivityCheckClient) Async(ctx context.Context, id ServiceId, input ConnectivityCheckRequest) (result AsyncOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/connectivityCheck", 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 +} + +// AsyncThenPoll performs Async then polls until it's completed +func (c PerformConnectivityCheckClient) AsyncThenPoll(ctx context.Context, id ServiceId, input ConnectivityCheckRequest) error { + result, err := c.Async(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Async: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Async: %+v", err) + } + + return nil +} diff --git a/resource-manager/apimanagement/2022-08-01/performconnectivitycheck/method_async_autorest.go b/resource-manager/apimanagement/2022-08-01/performconnectivitycheck/method_async_autorest.go deleted file mode 100644 index a2c486cc975..00000000000 --- a/resource-manager/apimanagement/2022-08-01/performconnectivitycheck/method_async_autorest.go +++ /dev/null @@ -1,79 +0,0 @@ -package performconnectivitycheck - -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 AsyncOperationResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// Async ... -func (c PerformConnectivityCheckClient) Async(ctx context.Context, id ServiceId, input ConnectivityCheckRequest) (result AsyncOperationResponse, err error) { - req, err := c.preparerForAsync(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "performconnectivitycheck.PerformConnectivityCheckClient", "Async", nil, "Failure preparing request") - return - } - - result, err = c.senderForAsync(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "performconnectivitycheck.PerformConnectivityCheckClient", "Async", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// AsyncThenPoll performs Async then polls until it's completed -func (c PerformConnectivityCheckClient) AsyncThenPoll(ctx context.Context, id ServiceId, input ConnectivityCheckRequest) error { - result, err := c.Async(ctx, id, input) - if err != nil { - return fmt.Errorf("performing Async: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after Async: %+v", err) - } - - return nil -} - -// preparerForAsync prepares the Async request. -func (c PerformConnectivityCheckClient) preparerForAsync(ctx context.Context, id ServiceId, input ConnectivityCheckRequest) (*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/connectivityCheck", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForAsync sends the Async request. The method will close the -// http.Response Body if it receives an error. -func (c PerformConnectivityCheckClient) senderForAsync(ctx context.Context, req *http.Request) (future AsyncOperationResponse, 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/apimanagement/2022-08-01/policy/client.go b/resource-manager/apimanagement/2022-08-01/policy/client.go index 100ea9be74e..609e5fa0964 100644 --- a/resource-manager/apimanagement/2022-08-01/policy/client.go +++ b/resource-manager/apimanagement/2022-08-01/policy/client.go @@ -1,18 +1,26 @@ package policy -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 PolicyClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewPolicyClientWithBaseURI(endpoint string) PolicyClient { - return PolicyClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewPolicyClientWithBaseURI(api environments.Api) (*PolicyClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "policy", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating PolicyClient: %+v", err) } + + return &PolicyClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2022-08-01/policy/constants.go b/resource-manager/apimanagement/2022-08-01/policy/constants.go index d347a3402e1..10a4650a395 100644 --- a/resource-manager/apimanagement/2022-08-01/policy/constants.go +++ b/resource-manager/apimanagement/2022-08-01/policy/constants.go @@ -1,6 +1,10 @@ package policy -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 PossibleValuesForPolicyContentFormat() []string { } } +func (s *PolicyContentFormat) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePolicyContentFormat(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parsePolicyContentFormat(input string) (*PolicyContentFormat, error) { vals := map[string]PolicyContentFormat{ "rawxml": PolicyContentFormatRawxml, @@ -53,6 +70,19 @@ func PossibleValuesForPolicyExportFormat() []string { } } +func (s *PolicyExportFormat) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePolicyExportFormat(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parsePolicyExportFormat(input string) (*PolicyExportFormat, error) { vals := map[string]PolicyExportFormat{ "rawxml": PolicyExportFormatRawxml, diff --git a/resource-manager/apimanagement/2022-08-01/policy/method_createorupdate.go b/resource-manager/apimanagement/2022-08-01/policy/method_createorupdate.go new file mode 100644 index 00000000000..0303d637d5e --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/policy/method_createorupdate.go @@ -0,0 +1,85 @@ +package policy + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PolicyContract +} + +type CreateOrUpdateOperationOptions struct { + IfMatch *string +} + +func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { + return CreateOrUpdateOperationOptions{} +} + +func (o CreateOrUpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o CreateOrUpdateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o CreateOrUpdateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// CreateOrUpdate ... +func (c PolicyClient) CreateOrUpdate(ctx context.Context, id ServiceId, input PolicyContract, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/policies/policy", id.ID()), + OptionsObject: options, + } + + 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/apimanagement/2022-08-01/policy/method_createorupdate_autorest.go b/resource-manager/apimanagement/2022-08-01/policy/method_createorupdate_autorest.go deleted file mode 100644 index 6891db3acdb..00000000000 --- a/resource-manager/apimanagement/2022-08-01/policy/method_createorupdate_autorest.go +++ /dev/null @@ -1,99 +0,0 @@ -package policy - -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 CreateOrUpdateOperationResponse struct { - HttpResponse *http.Response - Model *PolicyContract -} - -type CreateOrUpdateOperationOptions struct { - IfMatch *string -} - -func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { - return CreateOrUpdateOperationOptions{} -} - -func (o CreateOrUpdateOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o CreateOrUpdateOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// CreateOrUpdate ... -func (c PolicyClient) CreateOrUpdate(ctx context.Context, id ServiceId, input PolicyContract, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdate(ctx, id, input, options) - if err != nil { - err = autorest.NewErrorWithError(err, "policy.PolicyClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "policy.PolicyClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCreateOrUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "policy.PolicyClient", "CreateOrUpdate", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCreateOrUpdate prepares the CreateOrUpdate request. -func (c PolicyClient) preparerForCreateOrUpdate(ctx context.Context, id ServiceId, input PolicyContract, options CreateOrUpdateOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/policies/policy", 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 PolicyClient) responderForCreateOrUpdate(resp *http.Response) (result CreateOrUpdateOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2022-08-01/policy/method_delete.go b/resource-manager/apimanagement/2022-08-01/policy/method_delete.go new file mode 100644 index 00000000000..4ddd78e13cb --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/policy/method_delete.go @@ -0,0 +1,76 @@ +package policy + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +type DeleteOperationOptions struct { + IfMatch *string +} + +func DefaultDeleteOperationOptions() DeleteOperationOptions { + return DeleteOperationOptions{} +} + +func (o DeleteOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o DeleteOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o DeleteOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// Delete ... +func (c PolicyClient) Delete(ctx context.Context, id ServiceId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: fmt.Sprintf("%s/policies/policy", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2022-08-01/policy/method_delete_autorest.go b/resource-manager/apimanagement/2022-08-01/policy/method_delete_autorest.go deleted file mode 100644 index 48c0e129f41..00000000000 --- a/resource-manager/apimanagement/2022-08-01/policy/method_delete_autorest.go +++ /dev/null @@ -1,96 +0,0 @@ -package policy - -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 DeleteOperationResponse struct { - HttpResponse *http.Response -} - -type DeleteOperationOptions struct { - IfMatch *string -} - -func DefaultDeleteOperationOptions() DeleteOperationOptions { - return DeleteOperationOptions{} -} - -func (o DeleteOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o DeleteOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// Delete ... -func (c PolicyClient) Delete(ctx context.Context, id ServiceId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { - req, err := c.preparerForDelete(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "policy.PolicyClient", "Delete", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "policy.PolicyClient", "Delete", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForDelete(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "policy.PolicyClient", "Delete", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForDelete prepares the Delete request. -func (c PolicyClient) preparerForDelete(ctx context.Context, id ServiceId, options DeleteOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/policies/policy", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForDelete handles the response to the Delete request. The method always -// closes the http.Response Body. -func (c PolicyClient) responderForDelete(resp *http.Response) (result DeleteOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2022-08-01/policy/method_get.go b/resource-manager/apimanagement/2022-08-01/policy/method_get.go new file mode 100644 index 00000000000..829e84ff74d --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/policy/method_get.go @@ -0,0 +1,80 @@ +package policy + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PolicyContract +} + +type GetOperationOptions struct { + Format *PolicyExportFormat +} + +func DefaultGetOperationOptions() GetOperationOptions { + return GetOperationOptions{} +} + +func (o GetOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o GetOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o GetOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Format != nil { + out.Append("format", fmt.Sprintf("%v", *o.Format)) + } + return &out +} + +// Get ... +func (c PolicyClient) Get(ctx context.Context, id ServiceId, options GetOperationOptions) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/policies/policy", id.ID()), + OptionsObject: options, + } + + 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/apimanagement/2022-08-01/policy/method_get_autorest.go b/resource-manager/apimanagement/2022-08-01/policy/method_get_autorest.go deleted file mode 100644 index 5b1f10a4714..00000000000 --- a/resource-manager/apimanagement/2022-08-01/policy/method_get_autorest.go +++ /dev/null @@ -1,98 +0,0 @@ -package policy - -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 GetOperationResponse struct { - HttpResponse *http.Response - Model *PolicyContract -} - -type GetOperationOptions struct { - Format *PolicyExportFormat -} - -func DefaultGetOperationOptions() GetOperationOptions { - return GetOperationOptions{} -} - -func (o GetOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o GetOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Format != nil { - out["format"] = *o.Format - } - - return out -} - -// Get ... -func (c PolicyClient) Get(ctx context.Context, id ServiceId, options GetOperationOptions) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "policy.PolicyClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "policy.PolicyClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "policy.PolicyClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c PolicyClient) preparerForGet(ctx context.Context, id ServiceId, options GetOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/policies/policy", 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 PolicyClient) 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/apimanagement/2022-08-01/policy/method_getentitytag.go b/resource-manager/apimanagement/2022-08-01/policy/method_getentitytag.go new file mode 100644 index 00000000000..d8575a5f4ca --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/policy/method_getentitytag.go @@ -0,0 +1,47 @@ +package policy + +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 GetEntityTagOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// GetEntityTag ... +func (c PolicyClient) GetEntityTag(ctx context.Context, id ServiceId) (result GetEntityTagOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodHead, + Path: fmt.Sprintf("%s/policies/policy", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2022-08-01/policy/method_getentitytag_autorest.go b/resource-manager/apimanagement/2022-08-01/policy/method_getentitytag_autorest.go deleted file mode 100644 index 40957baa188..00000000000 --- a/resource-manager/apimanagement/2022-08-01/policy/method_getentitytag_autorest.go +++ /dev/null @@ -1,67 +0,0 @@ -package policy - -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 GetEntityTagOperationResponse struct { - HttpResponse *http.Response -} - -// GetEntityTag ... -func (c PolicyClient) GetEntityTag(ctx context.Context, id ServiceId) (result GetEntityTagOperationResponse, err error) { - req, err := c.preparerForGetEntityTag(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "policy.PolicyClient", "GetEntityTag", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "policy.PolicyClient", "GetEntityTag", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetEntityTag(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "policy.PolicyClient", "GetEntityTag", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetEntityTag prepares the GetEntityTag request. -func (c PolicyClient) preparerForGetEntityTag(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.AsHead(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/policies/policy", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetEntityTag handles the response to the GetEntityTag request. The method always -// closes the http.Response Body. -func (c PolicyClient) responderForGetEntityTag(resp *http.Response) (result GetEntityTagOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2022-08-01/policy/method_listbyservice.go b/resource-manager/apimanagement/2022-08-01/policy/method_listbyservice.go new file mode 100644 index 00000000000..2cba37b4dd0 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/policy/method_listbyservice.go @@ -0,0 +1,52 @@ +package policy + +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 ListByServiceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PolicyCollection +} + +// ListByService ... +func (c PolicyClient) ListByService(ctx context.Context, id ServiceId) (result ListByServiceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/policies", 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/apimanagement/2022-08-01/policy/method_listbyservice_autorest.go b/resource-manager/apimanagement/2022-08-01/policy/method_listbyservice_autorest.go deleted file mode 100644 index 753788e2a82..00000000000 --- a/resource-manager/apimanagement/2022-08-01/policy/method_listbyservice_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package policy - -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 ListByServiceOperationResponse struct { - HttpResponse *http.Response - Model *PolicyCollection -} - -// ListByService ... -func (c PolicyClient) ListByService(ctx context.Context, id ServiceId) (result ListByServiceOperationResponse, err error) { - req, err := c.preparerForListByService(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "policy.PolicyClient", "ListByService", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "policy.PolicyClient", "ListByService", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByService(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "policy.PolicyClient", "ListByService", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForListByService prepares the ListByService request. -func (c PolicyClient) preparerForListByService(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(fmt.Sprintf("%s/policies", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListByService handles the response to the ListByService request. The method always -// closes the http.Response Body. -func (c PolicyClient) responderForListByService(resp *http.Response) (result ListByServiceOperationResponse, 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/apimanagement/2022-08-01/policydescription/client.go b/resource-manager/apimanagement/2022-08-01/policydescription/client.go index 2ad1b60908c..a732550d9d3 100644 --- a/resource-manager/apimanagement/2022-08-01/policydescription/client.go +++ b/resource-manager/apimanagement/2022-08-01/policydescription/client.go @@ -1,18 +1,26 @@ package policydescription -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 PolicyDescriptionClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewPolicyDescriptionClientWithBaseURI(endpoint string) PolicyDescriptionClient { - return PolicyDescriptionClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewPolicyDescriptionClientWithBaseURI(api environments.Api) (*PolicyDescriptionClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "policydescription", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating PolicyDescriptionClient: %+v", err) } + + return &PolicyDescriptionClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2022-08-01/policydescription/constants.go b/resource-manager/apimanagement/2022-08-01/policydescription/constants.go index 5f73fe9e994..be5c274580c 100644 --- a/resource-manager/apimanagement/2022-08-01/policydescription/constants.go +++ b/resource-manager/apimanagement/2022-08-01/policydescription/constants.go @@ -1,6 +1,10 @@ package policydescription -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. @@ -25,6 +29,19 @@ func PossibleValuesForPolicyScopeContract() []string { } } +func (s *PolicyScopeContract) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePolicyScopeContract(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parsePolicyScopeContract(input string) (*PolicyScopeContract, error) { vals := map[string]PolicyScopeContract{ "all": PolicyScopeContractAll, diff --git a/resource-manager/apimanagement/2022-08-01/policydescription/method_listbyservice.go b/resource-manager/apimanagement/2022-08-01/policydescription/method_listbyservice.go new file mode 100644 index 00000000000..397951b3351 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/policydescription/method_listbyservice.go @@ -0,0 +1,80 @@ +package policydescription + +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 ListByServiceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PolicyDescriptionCollection +} + +type ListByServiceOperationOptions struct { + Scope *PolicyScopeContract +} + +func DefaultListByServiceOperationOptions() ListByServiceOperationOptions { + return ListByServiceOperationOptions{} +} + +func (o ListByServiceOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListByServiceOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListByServiceOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Scope != nil { + out.Append("scope", fmt.Sprintf("%v", *o.Scope)) + } + return &out +} + +// ListByService ... +func (c PolicyDescriptionClient) ListByService(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (result ListByServiceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/policyDescriptions", id.ID()), + OptionsObject: options, + } + + 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/apimanagement/2022-08-01/policydescription/method_listbyservice_autorest.go b/resource-manager/apimanagement/2022-08-01/policydescription/method_listbyservice_autorest.go deleted file mode 100644 index 0b74d09e511..00000000000 --- a/resource-manager/apimanagement/2022-08-01/policydescription/method_listbyservice_autorest.go +++ /dev/null @@ -1,98 +0,0 @@ -package policydescription - -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 ListByServiceOperationResponse struct { - HttpResponse *http.Response - Model *PolicyDescriptionCollection -} - -type ListByServiceOperationOptions struct { - Scope *PolicyScopeContract -} - -func DefaultListByServiceOperationOptions() ListByServiceOperationOptions { - return ListByServiceOperationOptions{} -} - -func (o ListByServiceOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o ListByServiceOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Scope != nil { - out["scope"] = *o.Scope - } - - return out -} - -// ListByService ... -func (c PolicyDescriptionClient) ListByService(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (result ListByServiceOperationResponse, err error) { - req, err := c.preparerForListByService(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "policydescription.PolicyDescriptionClient", "ListByService", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "policydescription.PolicyDescriptionClient", "ListByService", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByService(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "policydescription.PolicyDescriptionClient", "ListByService", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForListByService prepares the ListByService request. -func (c PolicyDescriptionClient) preparerForListByService(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/policyDescriptions", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListByService handles the response to the ListByService request. The method always -// closes the http.Response Body. -func (c PolicyDescriptionClient) responderForListByService(resp *http.Response) (result ListByServiceOperationResponse, 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/apimanagement/2022-08-01/policyfragment/client.go b/resource-manager/apimanagement/2022-08-01/policyfragment/client.go index 18490ea107c..d1d36422842 100644 --- a/resource-manager/apimanagement/2022-08-01/policyfragment/client.go +++ b/resource-manager/apimanagement/2022-08-01/policyfragment/client.go @@ -1,18 +1,26 @@ package policyfragment -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 PolicyFragmentClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewPolicyFragmentClientWithBaseURI(endpoint string) PolicyFragmentClient { - return PolicyFragmentClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewPolicyFragmentClientWithBaseURI(api environments.Api) (*PolicyFragmentClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "policyfragment", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating PolicyFragmentClient: %+v", err) } + + return &PolicyFragmentClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2022-08-01/policyfragment/constants.go b/resource-manager/apimanagement/2022-08-01/policyfragment/constants.go index 488ac0f2c2a..60aec2160bc 100644 --- a/resource-manager/apimanagement/2022-08-01/policyfragment/constants.go +++ b/resource-manager/apimanagement/2022-08-01/policyfragment/constants.go @@ -1,6 +1,10 @@ package policyfragment -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 PossibleValuesForPolicyFragmentContentFormat() []string { } } +func (s *PolicyFragmentContentFormat) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePolicyFragmentContentFormat(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parsePolicyFragmentContentFormat(input string) (*PolicyFragmentContentFormat, error) { vals := map[string]PolicyFragmentContentFormat{ "rawxml": PolicyFragmentContentFormatRawxml, diff --git a/resource-manager/apimanagement/2022-08-01/policyfragment/method_createorupdate.go b/resource-manager/apimanagement/2022-08-01/policyfragment/method_createorupdate.go new file mode 100644 index 00000000000..009b8d3a927 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/policyfragment/method_createorupdate.go @@ -0,0 +1,103 @@ +package policyfragment + +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 +} + +type CreateOrUpdateOperationOptions struct { + IfMatch *string +} + +func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { + return CreateOrUpdateOperationOptions{} +} + +func (o CreateOrUpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o CreateOrUpdateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o CreateOrUpdateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// CreateOrUpdate ... +func (c PolicyFragmentClient) CreateOrUpdate(ctx context.Context, id PolicyFragmentId, input PolicyFragmentContract, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + OptionsObject: options, + } + + 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 PolicyFragmentClient) CreateOrUpdateThenPoll(ctx context.Context, id PolicyFragmentId, input PolicyFragmentContract, options CreateOrUpdateOperationOptions) error { + result, err := c.CreateOrUpdate(ctx, id, input, options) + 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/apimanagement/2022-08-01/policyfragment/method_createorupdate_autorest.go b/resource-manager/apimanagement/2022-08-01/policyfragment/method_createorupdate_autorest.go deleted file mode 100644 index a2894348f3d..00000000000 --- a/resource-manager/apimanagement/2022-08-01/policyfragment/method_createorupdate_autorest.go +++ /dev/null @@ -1,108 +0,0 @@ -package policyfragment - -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 -} - -type CreateOrUpdateOperationOptions struct { - IfMatch *string -} - -func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { - return CreateOrUpdateOperationOptions{} -} - -func (o CreateOrUpdateOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o CreateOrUpdateOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// CreateOrUpdate ... -func (c PolicyFragmentClient) CreateOrUpdate(ctx context.Context, id PolicyFragmentId, input PolicyFragmentContract, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdate(ctx, id, input, options) - if err != nil { - err = autorest.NewErrorWithError(err, "policyfragment.PolicyFragmentClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result, err = c.senderForCreateOrUpdate(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "policyfragment.PolicyFragmentClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed -func (c PolicyFragmentClient) CreateOrUpdateThenPoll(ctx context.Context, id PolicyFragmentId, input PolicyFragmentContract, options CreateOrUpdateOperationOptions) error { - result, err := c.CreateOrUpdate(ctx, id, input, options) - 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 PolicyFragmentClient) preparerForCreateOrUpdate(ctx context.Context, id PolicyFragmentId, input PolicyFragmentContract, options CreateOrUpdateOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - 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 PolicyFragmentClient) 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/apimanagement/2022-08-01/policyfragment/method_delete.go b/resource-manager/apimanagement/2022-08-01/policyfragment/method_delete.go new file mode 100644 index 00000000000..c64764861f9 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/policyfragment/method_delete.go @@ -0,0 +1,76 @@ +package policyfragment + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +type DeleteOperationOptions struct { + IfMatch *string +} + +func DefaultDeleteOperationOptions() DeleteOperationOptions { + return DeleteOperationOptions{} +} + +func (o DeleteOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o DeleteOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o DeleteOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// Delete ... +func (c PolicyFragmentClient) Delete(ctx context.Context, id PolicyFragmentId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2022-08-01/policyfragment/method_delete_autorest.go b/resource-manager/apimanagement/2022-08-01/policyfragment/method_delete_autorest.go deleted file mode 100644 index 3fa7776b197..00000000000 --- a/resource-manager/apimanagement/2022-08-01/policyfragment/method_delete_autorest.go +++ /dev/null @@ -1,95 +0,0 @@ -package policyfragment - -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 DeleteOperationResponse struct { - HttpResponse *http.Response -} - -type DeleteOperationOptions struct { - IfMatch *string -} - -func DefaultDeleteOperationOptions() DeleteOperationOptions { - return DeleteOperationOptions{} -} - -func (o DeleteOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o DeleteOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// Delete ... -func (c PolicyFragmentClient) Delete(ctx context.Context, id PolicyFragmentId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { - req, err := c.preparerForDelete(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "policyfragment.PolicyFragmentClient", "Delete", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "policyfragment.PolicyFragmentClient", "Delete", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForDelete(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "policyfragment.PolicyFragmentClient", "Delete", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForDelete prepares the Delete request. -func (c PolicyFragmentClient) preparerForDelete(ctx context.Context, id PolicyFragmentId, options DeleteOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForDelete handles the response to the Delete request. The method always -// closes the http.Response Body. -func (c PolicyFragmentClient) responderForDelete(resp *http.Response) (result DeleteOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2022-08-01/policyfragment/method_get.go b/resource-manager/apimanagement/2022-08-01/policyfragment/method_get.go new file mode 100644 index 00000000000..d954db31db3 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/policyfragment/method_get.go @@ -0,0 +1,80 @@ +package policyfragment + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PolicyFragmentContract +} + +type GetOperationOptions struct { + Format *PolicyFragmentContentFormat +} + +func DefaultGetOperationOptions() GetOperationOptions { + return GetOperationOptions{} +} + +func (o GetOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o GetOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o GetOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Format != nil { + out.Append("format", fmt.Sprintf("%v", *o.Format)) + } + return &out +} + +// Get ... +func (c PolicyFragmentClient) Get(ctx context.Context, id PolicyFragmentId, options GetOperationOptions) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + OptionsObject: options, + } + + 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/apimanagement/2022-08-01/policyfragment/method_get_autorest.go b/resource-manager/apimanagement/2022-08-01/policyfragment/method_get_autorest.go deleted file mode 100644 index 9308600e3de..00000000000 --- a/resource-manager/apimanagement/2022-08-01/policyfragment/method_get_autorest.go +++ /dev/null @@ -1,97 +0,0 @@ -package policyfragment - -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 *PolicyFragmentContract -} - -type GetOperationOptions struct { - Format *PolicyFragmentContentFormat -} - -func DefaultGetOperationOptions() GetOperationOptions { - return GetOperationOptions{} -} - -func (o GetOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o GetOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Format != nil { - out["format"] = *o.Format - } - - return out -} - -// Get ... -func (c PolicyFragmentClient) Get(ctx context.Context, id PolicyFragmentId, options GetOperationOptions) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "policyfragment.PolicyFragmentClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "policyfragment.PolicyFragmentClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "policyfragment.PolicyFragmentClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c PolicyFragmentClient) preparerForGet(ctx context.Context, id PolicyFragmentId, options GetOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(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 PolicyFragmentClient) 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/apimanagement/2022-08-01/policyfragment/method_getentitytag.go b/resource-manager/apimanagement/2022-08-01/policyfragment/method_getentitytag.go new file mode 100644 index 00000000000..1d3b811f0e0 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/policyfragment/method_getentitytag.go @@ -0,0 +1,46 @@ +package policyfragment + +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 GetEntityTagOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// GetEntityTag ... +func (c PolicyFragmentClient) GetEntityTag(ctx context.Context, id PolicyFragmentId) (result GetEntityTagOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodHead, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2022-08-01/policyfragment/method_getentitytag_autorest.go b/resource-manager/apimanagement/2022-08-01/policyfragment/method_getentitytag_autorest.go deleted file mode 100644 index f1a7ad2c35d..00000000000 --- a/resource-manager/apimanagement/2022-08-01/policyfragment/method_getentitytag_autorest.go +++ /dev/null @@ -1,66 +0,0 @@ -package policyfragment - -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 GetEntityTagOperationResponse struct { - HttpResponse *http.Response -} - -// GetEntityTag ... -func (c PolicyFragmentClient) GetEntityTag(ctx context.Context, id PolicyFragmentId) (result GetEntityTagOperationResponse, err error) { - req, err := c.preparerForGetEntityTag(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "policyfragment.PolicyFragmentClient", "GetEntityTag", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "policyfragment.PolicyFragmentClient", "GetEntityTag", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetEntityTag(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "policyfragment.PolicyFragmentClient", "GetEntityTag", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetEntityTag prepares the GetEntityTag request. -func (c PolicyFragmentClient) preparerForGetEntityTag(ctx context.Context, id PolicyFragmentId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsHead(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetEntityTag handles the response to the GetEntityTag request. The method always -// closes the http.Response Body. -func (c PolicyFragmentClient) responderForGetEntityTag(resp *http.Response) (result GetEntityTagOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2022-08-01/policyfragment/method_listbyservice.go b/resource-manager/apimanagement/2022-08-01/policyfragment/method_listbyservice.go new file mode 100644 index 00000000000..04a5102f3ea --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/policyfragment/method_listbyservice.go @@ -0,0 +1,92 @@ +package policyfragment + +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 ListByServiceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PolicyFragmentCollection +} + +type ListByServiceOperationOptions struct { + Filter *string + Orderby *string + Skip *int64 + Top *int64 +} + +func DefaultListByServiceOperationOptions() ListByServiceOperationOptions { + return ListByServiceOperationOptions{} +} + +func (o ListByServiceOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListByServiceOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListByServiceOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.Orderby != nil { + out.Append("$orderby", fmt.Sprintf("%v", *o.Orderby)) + } + if o.Skip != nil { + out.Append("$skip", fmt.Sprintf("%v", *o.Skip)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +// ListByService ... +func (c PolicyFragmentClient) ListByService(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (result ListByServiceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/policyFragments", id.ID()), + OptionsObject: options, + } + + 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/apimanagement/2022-08-01/policyfragment/method_listbyservice_autorest.go b/resource-manager/apimanagement/2022-08-01/policyfragment/method_listbyservice_autorest.go deleted file mode 100644 index 0207c407e77..00000000000 --- a/resource-manager/apimanagement/2022-08-01/policyfragment/method_listbyservice_autorest.go +++ /dev/null @@ -1,113 +0,0 @@ -package policyfragment - -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 ListByServiceOperationResponse struct { - HttpResponse *http.Response - Model *PolicyFragmentCollection -} - -type ListByServiceOperationOptions struct { - Filter *string - Orderby *string - Skip *int64 - Top *int64 -} - -func DefaultListByServiceOperationOptions() ListByServiceOperationOptions { - return ListByServiceOperationOptions{} -} - -func (o ListByServiceOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o ListByServiceOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Filter != nil { - out["$filter"] = *o.Filter - } - - if o.Orderby != nil { - out["$orderby"] = *o.Orderby - } - - if o.Skip != nil { - out["$skip"] = *o.Skip - } - - if o.Top != nil { - out["$top"] = *o.Top - } - - return out -} - -// ListByService ... -func (c PolicyFragmentClient) ListByService(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (result ListByServiceOperationResponse, err error) { - req, err := c.preparerForListByService(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "policyfragment.PolicyFragmentClient", "ListByService", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "policyfragment.PolicyFragmentClient", "ListByService", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByService(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "policyfragment.PolicyFragmentClient", "ListByService", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForListByService prepares the ListByService request. -func (c PolicyFragmentClient) preparerForListByService(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/policyFragments", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListByService handles the response to the ListByService request. The method always -// closes the http.Response Body. -func (c PolicyFragmentClient) responderForListByService(resp *http.Response) (result ListByServiceOperationResponse, 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/apimanagement/2022-08-01/policyfragment/method_listreferences.go b/resource-manager/apimanagement/2022-08-01/policyfragment/method_listreferences.go new file mode 100644 index 00000000000..77dd2dbf94a --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/policyfragment/method_listreferences.go @@ -0,0 +1,84 @@ +package policyfragment + +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 ListReferencesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ResourceCollection +} + +type ListReferencesOperationOptions struct { + Skip *int64 + Top *int64 +} + +func DefaultListReferencesOperationOptions() ListReferencesOperationOptions { + return ListReferencesOperationOptions{} +} + +func (o ListReferencesOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListReferencesOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListReferencesOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Skip != nil { + out.Append("$skip", fmt.Sprintf("%v", *o.Skip)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +// ListReferences ... +func (c PolicyFragmentClient) ListReferences(ctx context.Context, id PolicyFragmentId, options ListReferencesOperationOptions) (result ListReferencesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/listReferences", id.ID()), + OptionsObject: options, + } + + 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/apimanagement/2022-08-01/policyfragment/method_listreferences_autorest.go b/resource-manager/apimanagement/2022-08-01/policyfragment/method_listreferences_autorest.go deleted file mode 100644 index 2faa2082619..00000000000 --- a/resource-manager/apimanagement/2022-08-01/policyfragment/method_listreferences_autorest.go +++ /dev/null @@ -1,103 +0,0 @@ -package policyfragment - -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 ListReferencesOperationResponse struct { - HttpResponse *http.Response - Model *ResourceCollection -} - -type ListReferencesOperationOptions struct { - Skip *int64 - Top *int64 -} - -func DefaultListReferencesOperationOptions() ListReferencesOperationOptions { - return ListReferencesOperationOptions{} -} - -func (o ListReferencesOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o ListReferencesOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Skip != nil { - out["$skip"] = *o.Skip - } - - if o.Top != nil { - out["$top"] = *o.Top - } - - return out -} - -// ListReferences ... -func (c PolicyFragmentClient) ListReferences(ctx context.Context, id PolicyFragmentId, options ListReferencesOperationOptions) (result ListReferencesOperationResponse, err error) { - req, err := c.preparerForListReferences(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "policyfragment.PolicyFragmentClient", "ListReferences", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "policyfragment.PolicyFragmentClient", "ListReferences", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListReferences(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "policyfragment.PolicyFragmentClient", "ListReferences", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForListReferences prepares the ListReferences request. -func (c PolicyFragmentClient) preparerForListReferences(ctx context.Context, id PolicyFragmentId, options ListReferencesOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/listReferences", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListReferences handles the response to the ListReferences request. The method always -// closes the http.Response Body. -func (c PolicyFragmentClient) responderForListReferences(resp *http.Response) (result ListReferencesOperationResponse, 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/apimanagement/2022-08-01/portalconfig/client.go b/resource-manager/apimanagement/2022-08-01/portalconfig/client.go index 11a8d2ba497..2e6459cd865 100644 --- a/resource-manager/apimanagement/2022-08-01/portalconfig/client.go +++ b/resource-manager/apimanagement/2022-08-01/portalconfig/client.go @@ -1,18 +1,26 @@ package portalconfig -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 PortalConfigClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewPortalConfigClientWithBaseURI(endpoint string) PortalConfigClient { - return PortalConfigClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewPortalConfigClientWithBaseURI(api environments.Api) (*PortalConfigClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "portalconfig", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating PortalConfigClient: %+v", err) } + + return &PortalConfigClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2022-08-01/portalconfig/constants.go b/resource-manager/apimanagement/2022-08-01/portalconfig/constants.go index 2a479921c56..5329a0b27fc 100644 --- a/resource-manager/apimanagement/2022-08-01/portalconfig/constants.go +++ b/resource-manager/apimanagement/2022-08-01/portalconfig/constants.go @@ -1,6 +1,10 @@ package portalconfig -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 PossibleValuesForPortalSettingsCspMode() []string { } } +func (s *PortalSettingsCspMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePortalSettingsCspMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parsePortalSettingsCspMode(input string) (*PortalSettingsCspMode, error) { vals := map[string]PortalSettingsCspMode{ "disabled": PortalSettingsCspModeDisabled, diff --git a/resource-manager/apimanagement/2022-08-01/portalconfig/method_createorupdate.go b/resource-manager/apimanagement/2022-08-01/portalconfig/method_createorupdate.go new file mode 100644 index 00000000000..b25743bf5fa --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/portalconfig/method_createorupdate.go @@ -0,0 +1,84 @@ +package portalconfig + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PortalConfigContract +} + +type CreateOrUpdateOperationOptions struct { + IfMatch *string +} + +func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { + return CreateOrUpdateOperationOptions{} +} + +func (o CreateOrUpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o CreateOrUpdateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o CreateOrUpdateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// CreateOrUpdate ... +func (c PortalConfigClient) CreateOrUpdate(ctx context.Context, id PortalConfigId, input PortalConfigContract, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + OptionsObject: options, + } + + 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/apimanagement/2022-08-01/portalconfig/method_createorupdate_autorest.go b/resource-manager/apimanagement/2022-08-01/portalconfig/method_createorupdate_autorest.go deleted file mode 100644 index 65548a236c4..00000000000 --- a/resource-manager/apimanagement/2022-08-01/portalconfig/method_createorupdate_autorest.go +++ /dev/null @@ -1,98 +0,0 @@ -package portalconfig - -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 *PortalConfigContract -} - -type CreateOrUpdateOperationOptions struct { - IfMatch *string -} - -func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { - return CreateOrUpdateOperationOptions{} -} - -func (o CreateOrUpdateOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o CreateOrUpdateOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// CreateOrUpdate ... -func (c PortalConfigClient) CreateOrUpdate(ctx context.Context, id PortalConfigId, input PortalConfigContract, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdate(ctx, id, input, options) - if err != nil { - err = autorest.NewErrorWithError(err, "portalconfig.PortalConfigClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "portalconfig.PortalConfigClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCreateOrUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "portalconfig.PortalConfigClient", "CreateOrUpdate", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCreateOrUpdate prepares the CreateOrUpdate request. -func (c PortalConfigClient) preparerForCreateOrUpdate(ctx context.Context, id PortalConfigId, input PortalConfigContract, options CreateOrUpdateOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - 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 PortalConfigClient) 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/apimanagement/2022-08-01/portalconfig/method_get.go b/resource-manager/apimanagement/2022-08-01/portalconfig/method_get.go new file mode 100644 index 00000000000..5c75192f019 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/portalconfig/method_get.go @@ -0,0 +1,51 @@ +package portalconfig + +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 *PortalConfigContract +} + +// Get ... +func (c PortalConfigClient) Get(ctx context.Context, id PortalConfigId) (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/apimanagement/2022-08-01/portalconfig/method_get_autorest.go b/resource-manager/apimanagement/2022-08-01/portalconfig/method_get_autorest.go deleted file mode 100644 index 499483dec16..00000000000 --- a/resource-manager/apimanagement/2022-08-01/portalconfig/method_get_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package portalconfig - -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 *PortalConfigContract -} - -// Get ... -func (c PortalConfigClient) Get(ctx context.Context, id PortalConfigId) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "portalconfig.PortalConfigClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "portalconfig.PortalConfigClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "portalconfig.PortalConfigClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c PortalConfigClient) preparerForGet(ctx context.Context, id PortalConfigId) (*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 PortalConfigClient) 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/apimanagement/2022-08-01/portalconfig/method_getentitytag.go b/resource-manager/apimanagement/2022-08-01/portalconfig/method_getentitytag.go new file mode 100644 index 00000000000..72fdc64bba5 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/portalconfig/method_getentitytag.go @@ -0,0 +1,46 @@ +package portalconfig + +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 GetEntityTagOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// GetEntityTag ... +func (c PortalConfigClient) GetEntityTag(ctx context.Context, id PortalConfigId) (result GetEntityTagOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodHead, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2022-08-01/portalconfig/method_getentitytag_autorest.go b/resource-manager/apimanagement/2022-08-01/portalconfig/method_getentitytag_autorest.go deleted file mode 100644 index 2a5b8158e77..00000000000 --- a/resource-manager/apimanagement/2022-08-01/portalconfig/method_getentitytag_autorest.go +++ /dev/null @@ -1,66 +0,0 @@ -package portalconfig - -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 GetEntityTagOperationResponse struct { - HttpResponse *http.Response -} - -// GetEntityTag ... -func (c PortalConfigClient) GetEntityTag(ctx context.Context, id PortalConfigId) (result GetEntityTagOperationResponse, err error) { - req, err := c.preparerForGetEntityTag(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "portalconfig.PortalConfigClient", "GetEntityTag", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "portalconfig.PortalConfigClient", "GetEntityTag", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetEntityTag(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "portalconfig.PortalConfigClient", "GetEntityTag", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetEntityTag prepares the GetEntityTag request. -func (c PortalConfigClient) preparerForGetEntityTag(ctx context.Context, id PortalConfigId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsHead(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetEntityTag handles the response to the GetEntityTag request. The method always -// closes the http.Response Body. -func (c PortalConfigClient) responderForGetEntityTag(resp *http.Response) (result GetEntityTagOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2022-08-01/portalconfig/method_listbyservice.go b/resource-manager/apimanagement/2022-08-01/portalconfig/method_listbyservice.go new file mode 100644 index 00000000000..c3452f50639 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/portalconfig/method_listbyservice.go @@ -0,0 +1,52 @@ +package portalconfig + +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 ListByServiceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PortalConfigCollection +} + +// ListByService ... +func (c PortalConfigClient) ListByService(ctx context.Context, id ServiceId) (result ListByServiceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/portalConfigs", 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/apimanagement/2022-08-01/portalconfig/method_listbyservice_autorest.go b/resource-manager/apimanagement/2022-08-01/portalconfig/method_listbyservice_autorest.go deleted file mode 100644 index 8cd1fbe6e9c..00000000000 --- a/resource-manager/apimanagement/2022-08-01/portalconfig/method_listbyservice_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package portalconfig - -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 ListByServiceOperationResponse struct { - HttpResponse *http.Response - Model *PortalConfigCollection -} - -// ListByService ... -func (c PortalConfigClient) ListByService(ctx context.Context, id ServiceId) (result ListByServiceOperationResponse, err error) { - req, err := c.preparerForListByService(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "portalconfig.PortalConfigClient", "ListByService", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "portalconfig.PortalConfigClient", "ListByService", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByService(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "portalconfig.PortalConfigClient", "ListByService", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForListByService prepares the ListByService request. -func (c PortalConfigClient) preparerForListByService(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(fmt.Sprintf("%s/portalConfigs", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListByService handles the response to the ListByService request. The method always -// closes the http.Response Body. -func (c PortalConfigClient) responderForListByService(resp *http.Response) (result ListByServiceOperationResponse, 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/apimanagement/2022-08-01/portalconfig/method_update.go b/resource-manager/apimanagement/2022-08-01/portalconfig/method_update.go new file mode 100644 index 00000000000..6543c107ba9 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/portalconfig/method_update.go @@ -0,0 +1,84 @@ +package portalconfig + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PortalConfigContract +} + +type UpdateOperationOptions struct { + IfMatch *string +} + +func DefaultUpdateOperationOptions() UpdateOperationOptions { + return UpdateOperationOptions{} +} + +func (o UpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o UpdateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o UpdateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// Update ... +func (c PortalConfigClient) Update(ctx context.Context, id PortalConfigId, input PortalConfigContract, options UpdateOperationOptions) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + OptionsObject: options, + } + + 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/apimanagement/2022-08-01/portalconfig/method_update_autorest.go b/resource-manager/apimanagement/2022-08-01/portalconfig/method_update_autorest.go deleted file mode 100644 index 8d818a308e6..00000000000 --- a/resource-manager/apimanagement/2022-08-01/portalconfig/method_update_autorest.go +++ /dev/null @@ -1,98 +0,0 @@ -package portalconfig - -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 *PortalConfigContract -} - -type UpdateOperationOptions struct { - IfMatch *string -} - -func DefaultUpdateOperationOptions() UpdateOperationOptions { - return UpdateOperationOptions{} -} - -func (o UpdateOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o UpdateOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// Update ... -func (c PortalConfigClient) Update(ctx context.Context, id PortalConfigId, input PortalConfigContract, options UpdateOperationOptions) (result UpdateOperationResponse, err error) { - req, err := c.preparerForUpdate(ctx, id, input, options) - if err != nil { - err = autorest.NewErrorWithError(err, "portalconfig.PortalConfigClient", "Update", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "portalconfig.PortalConfigClient", "Update", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "portalconfig.PortalConfigClient", "Update", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForUpdate prepares the Update request. -func (c PortalConfigClient) preparerForUpdate(ctx context.Context, id PortalConfigId, input PortalConfigContract, options UpdateOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPatch(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - 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 PortalConfigClient) 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/apimanagement/2022-08-01/portalrevision/client.go b/resource-manager/apimanagement/2022-08-01/portalrevision/client.go index b6215519652..01b0e3dbaa2 100644 --- a/resource-manager/apimanagement/2022-08-01/portalrevision/client.go +++ b/resource-manager/apimanagement/2022-08-01/portalrevision/client.go @@ -1,18 +1,26 @@ package portalrevision -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 PortalRevisionClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewPortalRevisionClientWithBaseURI(endpoint string) PortalRevisionClient { - return PortalRevisionClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewPortalRevisionClientWithBaseURI(api environments.Api) (*PortalRevisionClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "portalrevision", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating PortalRevisionClient: %+v", err) } + + return &PortalRevisionClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2022-08-01/portalrevision/constants.go b/resource-manager/apimanagement/2022-08-01/portalrevision/constants.go index aa2001884d8..721b9d119dc 100644 --- a/resource-manager/apimanagement/2022-08-01/portalrevision/constants.go +++ b/resource-manager/apimanagement/2022-08-01/portalrevision/constants.go @@ -1,6 +1,10 @@ package portalrevision -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 PossibleValuesForPortalRevisionStatus() []string { } } +func (s *PortalRevisionStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePortalRevisionStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parsePortalRevisionStatus(input string) (*PortalRevisionStatus, error) { vals := map[string]PortalRevisionStatus{ "completed": PortalRevisionStatusCompleted, diff --git a/resource-manager/apimanagement/2022-08-01/portalrevision/method_createorupdate.go b/resource-manager/apimanagement/2022-08-01/portalrevision/method_createorupdate.go new file mode 100644 index 00000000000..a28f2755f5b --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/portalrevision/method_createorupdate.go @@ -0,0 +1,74 @@ +package portalrevision + +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 +} + +// CreateOrUpdate ... +func (c PortalRevisionClient) CreateOrUpdate(ctx context.Context, id PortalRevisionId, input PortalRevisionContract) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusCreated, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed +func (c PortalRevisionClient) CreateOrUpdateThenPoll(ctx context.Context, id PortalRevisionId, input PortalRevisionContract) 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/apimanagement/2022-08-01/portalrevision/method_createorupdate_autorest.go b/resource-manager/apimanagement/2022-08-01/portalrevision/method_createorupdate_autorest.go deleted file mode 100644 index e674d1c6391..00000000000 --- a/resource-manager/apimanagement/2022-08-01/portalrevision/method_createorupdate_autorest.go +++ /dev/null @@ -1,79 +0,0 @@ -package portalrevision - -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 -} - -// CreateOrUpdate ... -func (c PortalRevisionClient) CreateOrUpdate(ctx context.Context, id PortalRevisionId, input PortalRevisionContract) (result CreateOrUpdateOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "portalrevision.PortalRevisionClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result, err = c.senderForCreateOrUpdate(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "portalrevision.PortalRevisionClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed -func (c PortalRevisionClient) CreateOrUpdateThenPoll(ctx context.Context, id PortalRevisionId, input PortalRevisionContract) 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 PortalRevisionClient) preparerForCreateOrUpdate(ctx context.Context, id PortalRevisionId, input PortalRevisionContract) (*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 PortalRevisionClient) 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/apimanagement/2022-08-01/portalrevision/method_get.go b/resource-manager/apimanagement/2022-08-01/portalrevision/method_get.go new file mode 100644 index 00000000000..ebc6cd16a57 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/portalrevision/method_get.go @@ -0,0 +1,51 @@ +package portalrevision + +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 *PortalRevisionContract +} + +// Get ... +func (c PortalRevisionClient) Get(ctx context.Context, id PortalRevisionId) (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/apimanagement/2022-08-01/portalrevision/method_get_autorest.go b/resource-manager/apimanagement/2022-08-01/portalrevision/method_get_autorest.go deleted file mode 100644 index 2c81b2f3322..00000000000 --- a/resource-manager/apimanagement/2022-08-01/portalrevision/method_get_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package portalrevision - -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 *PortalRevisionContract -} - -// Get ... -func (c PortalRevisionClient) Get(ctx context.Context, id PortalRevisionId) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "portalrevision.PortalRevisionClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "portalrevision.PortalRevisionClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "portalrevision.PortalRevisionClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c PortalRevisionClient) preparerForGet(ctx context.Context, id PortalRevisionId) (*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 PortalRevisionClient) 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/apimanagement/2022-08-01/portalrevision/method_getentitytag.go b/resource-manager/apimanagement/2022-08-01/portalrevision/method_getentitytag.go new file mode 100644 index 00000000000..c29d462fb8e --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/portalrevision/method_getentitytag.go @@ -0,0 +1,46 @@ +package portalrevision + +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 GetEntityTagOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// GetEntityTag ... +func (c PortalRevisionClient) GetEntityTag(ctx context.Context, id PortalRevisionId) (result GetEntityTagOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodHead, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2022-08-01/portalrevision/method_getentitytag_autorest.go b/resource-manager/apimanagement/2022-08-01/portalrevision/method_getentitytag_autorest.go deleted file mode 100644 index 673f88eb7c5..00000000000 --- a/resource-manager/apimanagement/2022-08-01/portalrevision/method_getentitytag_autorest.go +++ /dev/null @@ -1,66 +0,0 @@ -package portalrevision - -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 GetEntityTagOperationResponse struct { - HttpResponse *http.Response -} - -// GetEntityTag ... -func (c PortalRevisionClient) GetEntityTag(ctx context.Context, id PortalRevisionId) (result GetEntityTagOperationResponse, err error) { - req, err := c.preparerForGetEntityTag(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "portalrevision.PortalRevisionClient", "GetEntityTag", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "portalrevision.PortalRevisionClient", "GetEntityTag", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetEntityTag(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "portalrevision.PortalRevisionClient", "GetEntityTag", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetEntityTag prepares the GetEntityTag request. -func (c PortalRevisionClient) preparerForGetEntityTag(ctx context.Context, id PortalRevisionId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsHead(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetEntityTag handles the response to the GetEntityTag request. The method always -// closes the http.Response Body. -func (c PortalRevisionClient) responderForGetEntityTag(resp *http.Response) (result GetEntityTagOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2022-08-01/portalrevision/method_listbyservice.go b/resource-manager/apimanagement/2022-08-01/portalrevision/method_listbyservice.go new file mode 100644 index 00000000000..367a0040241 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/portalrevision/method_listbyservice.go @@ -0,0 +1,125 @@ +package portalrevision + +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 ListByServiceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]PortalRevisionContract +} + +type ListByServiceCompleteResult struct { + Items []PortalRevisionContract +} + +type ListByServiceOperationOptions struct { + Filter *string + Skip *int64 + Top *int64 +} + +func DefaultListByServiceOperationOptions() ListByServiceOperationOptions { + return ListByServiceOperationOptions{} +} + +func (o ListByServiceOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListByServiceOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListByServiceOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.Skip != nil { + out.Append("$skip", fmt.Sprintf("%v", *o.Skip)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +// ListByService ... +func (c PortalRevisionClient) ListByService(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (result ListByServiceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/portalRevisions", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]PortalRevisionContract `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByServiceComplete retrieves all the results into a single object +func (c PortalRevisionClient) ListByServiceComplete(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (ListByServiceCompleteResult, error) { + return c.ListByServiceCompleteMatchingPredicate(ctx, id, options, PortalRevisionContractOperationPredicate{}) +} + +// ListByServiceCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c PortalRevisionClient) ListByServiceCompleteMatchingPredicate(ctx context.Context, id ServiceId, options ListByServiceOperationOptions, predicate PortalRevisionContractOperationPredicate) (result ListByServiceCompleteResult, err error) { + items := make([]PortalRevisionContract, 0) + + resp, err := c.ListByService(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByServiceCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/apimanagement/2022-08-01/portalrevision/method_listbyservice_autorest.go b/resource-manager/apimanagement/2022-08-01/portalrevision/method_listbyservice_autorest.go deleted file mode 100644 index e804ebd138b..00000000000 --- a/resource-manager/apimanagement/2022-08-01/portalrevision/method_listbyservice_autorest.go +++ /dev/null @@ -1,225 +0,0 @@ -package portalrevision - -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 ListByServiceOperationResponse struct { - HttpResponse *http.Response - Model *[]PortalRevisionContract - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListByServiceOperationResponse, error) -} - -type ListByServiceCompleteResult struct { - Items []PortalRevisionContract -} - -func (r ListByServiceOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListByServiceOperationResponse) LoadMore(ctx context.Context) (resp ListByServiceOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -type ListByServiceOperationOptions struct { - Filter *string - Skip *int64 - Top *int64 -} - -func DefaultListByServiceOperationOptions() ListByServiceOperationOptions { - return ListByServiceOperationOptions{} -} - -func (o ListByServiceOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o ListByServiceOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Filter != nil { - out["$filter"] = *o.Filter - } - - if o.Skip != nil { - out["$skip"] = *o.Skip - } - - if o.Top != nil { - out["$top"] = *o.Top - } - - return out -} - -// ListByService ... -func (c PortalRevisionClient) ListByService(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (resp ListByServiceOperationResponse, err error) { - req, err := c.preparerForListByService(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "portalrevision.PortalRevisionClient", "ListByService", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "portalrevision.PortalRevisionClient", "ListByService", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListByService(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "portalrevision.PortalRevisionClient", "ListByService", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListByService prepares the ListByService request. -func (c PortalRevisionClient) preparerForListByService(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/portalRevisions", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListByServiceWithNextLink prepares the ListByService request with the given nextLink token. -func (c PortalRevisionClient) preparerForListByServiceWithNextLink(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)) -} - -// responderForListByService handles the response to the ListByService request. The method always -// closes the http.Response Body. -func (c PortalRevisionClient) responderForListByService(resp *http.Response) (result ListByServiceOperationResponse, err error) { - type page struct { - Values []PortalRevisionContract `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 ListByServiceOperationResponse, err error) { - req, err := c.preparerForListByServiceWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "portalrevision.PortalRevisionClient", "ListByService", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "portalrevision.PortalRevisionClient", "ListByService", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByService(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "portalrevision.PortalRevisionClient", "ListByService", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListByServiceComplete retrieves all of the results into a single object -func (c PortalRevisionClient) ListByServiceComplete(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (ListByServiceCompleteResult, error) { - return c.ListByServiceCompleteMatchingPredicate(ctx, id, options, PortalRevisionContractOperationPredicate{}) -} - -// ListByServiceCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c PortalRevisionClient) ListByServiceCompleteMatchingPredicate(ctx context.Context, id ServiceId, options ListByServiceOperationOptions, predicate PortalRevisionContractOperationPredicate) (resp ListByServiceCompleteResult, err error) { - items := make([]PortalRevisionContract, 0) - - page, err := c.ListByService(ctx, id, options) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListByServiceCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/apimanagement/2022-08-01/portalrevision/method_update.go b/resource-manager/apimanagement/2022-08-01/portalrevision/method_update.go new file mode 100644 index 00000000000..d9b47a64729 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/portalrevision/method_update.go @@ -0,0 +1,102 @@ +package portalrevision + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +type UpdateOperationOptions struct { + IfMatch *string +} + +func DefaultUpdateOperationOptions() UpdateOperationOptions { + return UpdateOperationOptions{} +} + +func (o UpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o UpdateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o UpdateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// Update ... +func (c PortalRevisionClient) Update(ctx context.Context, id PortalRevisionId, input PortalRevisionContract, options UpdateOperationOptions) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// UpdateThenPoll performs Update then polls until it's completed +func (c PortalRevisionClient) UpdateThenPoll(ctx context.Context, id PortalRevisionId, input PortalRevisionContract, options UpdateOperationOptions) error { + result, err := c.Update(ctx, id, input, options) + if err != nil { + return fmt.Errorf("performing Update: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Update: %+v", err) + } + + return nil +} diff --git a/resource-manager/apimanagement/2022-08-01/portalrevision/method_update_autorest.go b/resource-manager/apimanagement/2022-08-01/portalrevision/method_update_autorest.go deleted file mode 100644 index e6c980e81fa..00000000000 --- a/resource-manager/apimanagement/2022-08-01/portalrevision/method_update_autorest.go +++ /dev/null @@ -1,108 +0,0 @@ -package portalrevision - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type UpdateOperationResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -type UpdateOperationOptions struct { - IfMatch *string -} - -func DefaultUpdateOperationOptions() UpdateOperationOptions { - return UpdateOperationOptions{} -} - -func (o UpdateOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o UpdateOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// Update ... -func (c PortalRevisionClient) Update(ctx context.Context, id PortalRevisionId, input PortalRevisionContract, options UpdateOperationOptions) (result UpdateOperationResponse, err error) { - req, err := c.preparerForUpdate(ctx, id, input, options) - if err != nil { - err = autorest.NewErrorWithError(err, "portalrevision.PortalRevisionClient", "Update", nil, "Failure preparing request") - return - } - - result, err = c.senderForUpdate(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "portalrevision.PortalRevisionClient", "Update", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// UpdateThenPoll performs Update then polls until it's completed -func (c PortalRevisionClient) UpdateThenPoll(ctx context.Context, id PortalRevisionId, input PortalRevisionContract, options UpdateOperationOptions) error { - result, err := c.Update(ctx, id, input, options) - if err != nil { - return fmt.Errorf("performing Update: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after Update: %+v", err) - } - - return nil -} - -// preparerForUpdate prepares the Update request. -func (c PortalRevisionClient) preparerForUpdate(ctx context.Context, id PortalRevisionId, input PortalRevisionContract, options UpdateOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPatch(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForUpdate sends the Update request. The method will close the -// http.Response Body if it receives an error. -func (c PortalRevisionClient) senderForUpdate(ctx context.Context, req *http.Request) (future UpdateOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/apimanagement/2022-08-01/portalsettings/client.go b/resource-manager/apimanagement/2022-08-01/portalsettings/client.go index 7f256742d89..466acaf2584 100644 --- a/resource-manager/apimanagement/2022-08-01/portalsettings/client.go +++ b/resource-manager/apimanagement/2022-08-01/portalsettings/client.go @@ -1,18 +1,26 @@ package portalsettings -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 PortalSettingsClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewPortalSettingsClientWithBaseURI(endpoint string) PortalSettingsClient { - return PortalSettingsClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewPortalSettingsClientWithBaseURI(api environments.Api) (*PortalSettingsClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "portalsettings", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating PortalSettingsClient: %+v", err) } + + return &PortalSettingsClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2022-08-01/portalsettings/method_listbyservice.go b/resource-manager/apimanagement/2022-08-01/portalsettings/method_listbyservice.go new file mode 100644 index 00000000000..5f25ab8003b --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/portalsettings/method_listbyservice.go @@ -0,0 +1,52 @@ +package portalsettings + +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 ListByServiceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PortalSettingsCollection +} + +// ListByService ... +func (c PortalSettingsClient) ListByService(ctx context.Context, id ServiceId) (result ListByServiceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/portalsettings", 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/apimanagement/2022-08-01/portalsettings/method_listbyservice_autorest.go b/resource-manager/apimanagement/2022-08-01/portalsettings/method_listbyservice_autorest.go deleted file mode 100644 index d9168eff5c9..00000000000 --- a/resource-manager/apimanagement/2022-08-01/portalsettings/method_listbyservice_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package portalsettings - -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 ListByServiceOperationResponse struct { - HttpResponse *http.Response - Model *PortalSettingsCollection -} - -// ListByService ... -func (c PortalSettingsClient) ListByService(ctx context.Context, id ServiceId) (result ListByServiceOperationResponse, err error) { - req, err := c.preparerForListByService(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "portalsettings.PortalSettingsClient", "ListByService", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "portalsettings.PortalSettingsClient", "ListByService", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByService(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "portalsettings.PortalSettingsClient", "ListByService", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForListByService prepares the ListByService request. -func (c PortalSettingsClient) preparerForListByService(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(fmt.Sprintf("%s/portalsettings", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListByService handles the response to the ListByService request. The method always -// closes the http.Response Body. -func (c PortalSettingsClient) responderForListByService(resp *http.Response) (result ListByServiceOperationResponse, 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/apimanagement/2022-08-01/privateendpointconnections/client.go b/resource-manager/apimanagement/2022-08-01/privateendpointconnections/client.go index 1de584406fe..05a6653dc59 100644 --- a/resource-manager/apimanagement/2022-08-01/privateendpointconnections/client.go +++ b/resource-manager/apimanagement/2022-08-01/privateendpointconnections/client.go @@ -1,18 +1,26 @@ package privateendpointconnections -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/environments" +) // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See NOTICE.txt in the project root for license information. type PrivateEndpointConnectionsClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewPrivateEndpointConnectionsClientWithBaseURI(endpoint string) PrivateEndpointConnectionsClient { - return PrivateEndpointConnectionsClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewPrivateEndpointConnectionsClientWithBaseURI(api environments.Api) (*PrivateEndpointConnectionsClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "privateendpointconnections", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating PrivateEndpointConnectionsClient: %+v", err) } + + return &PrivateEndpointConnectionsClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2022-08-01/privateendpointconnections/constants.go b/resource-manager/apimanagement/2022-08-01/privateendpointconnections/constants.go index b6aed9e880a..c5850609650 100644 --- a/resource-manager/apimanagement/2022-08-01/privateendpointconnections/constants.go +++ b/resource-manager/apimanagement/2022-08-01/privateendpointconnections/constants.go @@ -1,6 +1,10 @@ package privateendpointconnections -import "strings" +import ( + "encoding/json" + "fmt" + "strings" +) // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See NOTICE.txt in the project root for license information. @@ -23,6 +27,19 @@ func PossibleValuesForPrivateEndpointConnectionProvisioningState() []string { } } +func (s *PrivateEndpointConnectionProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePrivateEndpointConnectionProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parsePrivateEndpointConnectionProvisioningState(input string) (*PrivateEndpointConnectionProvisioningState, error) { vals := map[string]PrivateEndpointConnectionProvisioningState{ "creating": PrivateEndpointConnectionProvisioningStateCreating, @@ -55,6 +72,19 @@ func PossibleValuesForPrivateEndpointServiceConnectionStatus() []string { } } +func (s *PrivateEndpointServiceConnectionStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePrivateEndpointServiceConnectionStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parsePrivateEndpointServiceConnectionStatus(input string) (*PrivateEndpointServiceConnectionStatus, error) { vals := map[string]PrivateEndpointServiceConnectionStatus{ "approved": PrivateEndpointServiceConnectionStatusApproved, diff --git a/resource-manager/apimanagement/2022-08-01/privateendpointconnections/method_privateendpointconnectioncreateorupdate.go b/resource-manager/apimanagement/2022-08-01/privateendpointconnections/method_privateendpointconnectioncreateorupdate.go new file mode 100644 index 00000000000..f348834c3ca --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/privateendpointconnections/method_privateendpointconnectioncreateorupdate.go @@ -0,0 +1,74 @@ +package privateendpointconnections + +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 PrivateEndpointConnectionCreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// PrivateEndpointConnectionCreateOrUpdate ... +func (c PrivateEndpointConnectionsClient) PrivateEndpointConnectionCreateOrUpdate(ctx context.Context, id PrivateEndpointConnectionId, input PrivateEndpointConnectionRequest) (result PrivateEndpointConnectionCreateOrUpdateOperationResponse, 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 +} + +// PrivateEndpointConnectionCreateOrUpdateThenPoll performs PrivateEndpointConnectionCreateOrUpdate then polls until it's completed +func (c PrivateEndpointConnectionsClient) PrivateEndpointConnectionCreateOrUpdateThenPoll(ctx context.Context, id PrivateEndpointConnectionId, input PrivateEndpointConnectionRequest) error { + result, err := c.PrivateEndpointConnectionCreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing PrivateEndpointConnectionCreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after PrivateEndpointConnectionCreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/apimanagement/2022-08-01/privateendpointconnections/method_privateendpointconnectioncreateorupdate_autorest.go b/resource-manager/apimanagement/2022-08-01/privateendpointconnections/method_privateendpointconnectioncreateorupdate_autorest.go deleted file mode 100644 index f890917081c..00000000000 --- a/resource-manager/apimanagement/2022-08-01/privateendpointconnections/method_privateendpointconnectioncreateorupdate_autorest.go +++ /dev/null @@ -1,79 +0,0 @@ -package privateendpointconnections - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type PrivateEndpointConnectionCreateOrUpdateOperationResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// PrivateEndpointConnectionCreateOrUpdate ... -func (c PrivateEndpointConnectionsClient) PrivateEndpointConnectionCreateOrUpdate(ctx context.Context, id PrivateEndpointConnectionId, input PrivateEndpointConnectionRequest) (result PrivateEndpointConnectionCreateOrUpdateOperationResponse, err error) { - req, err := c.preparerForPrivateEndpointConnectionCreateOrUpdate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "privateendpointconnections.PrivateEndpointConnectionsClient", "PrivateEndpointConnectionCreateOrUpdate", nil, "Failure preparing request") - return - } - - result, err = c.senderForPrivateEndpointConnectionCreateOrUpdate(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "privateendpointconnections.PrivateEndpointConnectionsClient", "PrivateEndpointConnectionCreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// PrivateEndpointConnectionCreateOrUpdateThenPoll performs PrivateEndpointConnectionCreateOrUpdate then polls until it's completed -func (c PrivateEndpointConnectionsClient) PrivateEndpointConnectionCreateOrUpdateThenPoll(ctx context.Context, id PrivateEndpointConnectionId, input PrivateEndpointConnectionRequest) error { - result, err := c.PrivateEndpointConnectionCreateOrUpdate(ctx, id, input) - if err != nil { - return fmt.Errorf("performing PrivateEndpointConnectionCreateOrUpdate: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after PrivateEndpointConnectionCreateOrUpdate: %+v", err) - } - - return nil -} - -// preparerForPrivateEndpointConnectionCreateOrUpdate prepares the PrivateEndpointConnectionCreateOrUpdate request. -func (c PrivateEndpointConnectionsClient) preparerForPrivateEndpointConnectionCreateOrUpdate(ctx context.Context, id PrivateEndpointConnectionId, input PrivateEndpointConnectionRequest) (*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)) -} - -// senderForPrivateEndpointConnectionCreateOrUpdate sends the PrivateEndpointConnectionCreateOrUpdate request. The method will close the -// http.Response Body if it receives an error. -func (c PrivateEndpointConnectionsClient) senderForPrivateEndpointConnectionCreateOrUpdate(ctx context.Context, req *http.Request) (future PrivateEndpointConnectionCreateOrUpdateOperationResponse, 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/apimanagement/2022-08-01/privateendpointconnections/method_privateendpointconnectiondelete.go b/resource-manager/apimanagement/2022-08-01/privateendpointconnections/method_privateendpointconnectiondelete.go new file mode 100644 index 00000000000..3dea5aca1b3 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/privateendpointconnections/method_privateendpointconnectiondelete.go @@ -0,0 +1,71 @@ +package privateendpointconnections + +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 PrivateEndpointConnectionDeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// PrivateEndpointConnectionDelete ... +func (c PrivateEndpointConnectionsClient) PrivateEndpointConnectionDelete(ctx context.Context, id PrivateEndpointConnectionId) (result PrivateEndpointConnectionDeleteOperationResponse, 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 +} + +// PrivateEndpointConnectionDeleteThenPoll performs PrivateEndpointConnectionDelete then polls until it's completed +func (c PrivateEndpointConnectionsClient) PrivateEndpointConnectionDeleteThenPoll(ctx context.Context, id PrivateEndpointConnectionId) error { + result, err := c.PrivateEndpointConnectionDelete(ctx, id) + if err != nil { + return fmt.Errorf("performing PrivateEndpointConnectionDelete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after PrivateEndpointConnectionDelete: %+v", err) + } + + return nil +} diff --git a/resource-manager/apimanagement/2022-08-01/privateendpointconnections/method_privateendpointconnectiondelete_autorest.go b/resource-manager/apimanagement/2022-08-01/privateendpointconnections/method_privateendpointconnectiondelete_autorest.go deleted file mode 100644 index 6c53edbf85b..00000000000 --- a/resource-manager/apimanagement/2022-08-01/privateendpointconnections/method_privateendpointconnectiondelete_autorest.go +++ /dev/null @@ -1,78 +0,0 @@ -package privateendpointconnections - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type PrivateEndpointConnectionDeleteOperationResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// PrivateEndpointConnectionDelete ... -func (c PrivateEndpointConnectionsClient) PrivateEndpointConnectionDelete(ctx context.Context, id PrivateEndpointConnectionId) (result PrivateEndpointConnectionDeleteOperationResponse, err error) { - req, err := c.preparerForPrivateEndpointConnectionDelete(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "privateendpointconnections.PrivateEndpointConnectionsClient", "PrivateEndpointConnectionDelete", nil, "Failure preparing request") - return - } - - result, err = c.senderForPrivateEndpointConnectionDelete(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "privateendpointconnections.PrivateEndpointConnectionsClient", "PrivateEndpointConnectionDelete", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// PrivateEndpointConnectionDeleteThenPoll performs PrivateEndpointConnectionDelete then polls until it's completed -func (c PrivateEndpointConnectionsClient) PrivateEndpointConnectionDeleteThenPoll(ctx context.Context, id PrivateEndpointConnectionId) error { - result, err := c.PrivateEndpointConnectionDelete(ctx, id) - if err != nil { - return fmt.Errorf("performing PrivateEndpointConnectionDelete: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after PrivateEndpointConnectionDelete: %+v", err) - } - - return nil -} - -// preparerForPrivateEndpointConnectionDelete prepares the PrivateEndpointConnectionDelete request. -func (c PrivateEndpointConnectionsClient) preparerForPrivateEndpointConnectionDelete(ctx context.Context, id PrivateEndpointConnectionId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForPrivateEndpointConnectionDelete sends the PrivateEndpointConnectionDelete request. The method will close the -// http.Response Body if it receives an error. -func (c PrivateEndpointConnectionsClient) senderForPrivateEndpointConnectionDelete(ctx context.Context, req *http.Request) (future PrivateEndpointConnectionDeleteOperationResponse, 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/apimanagement/2022-08-01/privateendpointconnections/method_privateendpointconnectiongetbyname.go b/resource-manager/apimanagement/2022-08-01/privateendpointconnections/method_privateendpointconnectiongetbyname.go new file mode 100644 index 00000000000..51d57d4f314 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/privateendpointconnections/method_privateendpointconnectiongetbyname.go @@ -0,0 +1,51 @@ +package privateendpointconnections + +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 PrivateEndpointConnectionGetByNameOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PrivateEndpointConnection +} + +// PrivateEndpointConnectionGetByName ... +func (c PrivateEndpointConnectionsClient) PrivateEndpointConnectionGetByName(ctx context.Context, id PrivateEndpointConnectionId) (result PrivateEndpointConnectionGetByNameOperationResponse, 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/apimanagement/2022-08-01/privateendpointconnections/method_privateendpointconnectiongetbyname_autorest.go b/resource-manager/apimanagement/2022-08-01/privateendpointconnections/method_privateendpointconnectiongetbyname_autorest.go deleted file mode 100644 index 88167729441..00000000000 --- a/resource-manager/apimanagement/2022-08-01/privateendpointconnections/method_privateendpointconnectiongetbyname_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package privateendpointconnections - -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 PrivateEndpointConnectionGetByNameOperationResponse struct { - HttpResponse *http.Response - Model *PrivateEndpointConnection -} - -// PrivateEndpointConnectionGetByName ... -func (c PrivateEndpointConnectionsClient) PrivateEndpointConnectionGetByName(ctx context.Context, id PrivateEndpointConnectionId) (result PrivateEndpointConnectionGetByNameOperationResponse, err error) { - req, err := c.preparerForPrivateEndpointConnectionGetByName(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "privateendpointconnections.PrivateEndpointConnectionsClient", "PrivateEndpointConnectionGetByName", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "privateendpointconnections.PrivateEndpointConnectionsClient", "PrivateEndpointConnectionGetByName", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForPrivateEndpointConnectionGetByName(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "privateendpointconnections.PrivateEndpointConnectionsClient", "PrivateEndpointConnectionGetByName", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForPrivateEndpointConnectionGetByName prepares the PrivateEndpointConnectionGetByName request. -func (c PrivateEndpointConnectionsClient) preparerForPrivateEndpointConnectionGetByName(ctx context.Context, id PrivateEndpointConnectionId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForPrivateEndpointConnectionGetByName handles the response to the PrivateEndpointConnectionGetByName request. The method always -// closes the http.Response Body. -func (c PrivateEndpointConnectionsClient) responderForPrivateEndpointConnectionGetByName(resp *http.Response) (result PrivateEndpointConnectionGetByNameOperationResponse, 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/apimanagement/2022-08-01/privateendpointconnections/method_privateendpointconnectiongetprivatelinkresource.go b/resource-manager/apimanagement/2022-08-01/privateendpointconnections/method_privateendpointconnectiongetprivatelinkresource.go new file mode 100644 index 00000000000..fd334bbacc0 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/privateendpointconnections/method_privateendpointconnectiongetprivatelinkresource.go @@ -0,0 +1,51 @@ +package privateendpointconnections + +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 PrivateEndpointConnectionGetPrivateLinkResourceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PrivateLinkResource +} + +// PrivateEndpointConnectionGetPrivateLinkResource ... +func (c PrivateEndpointConnectionsClient) PrivateEndpointConnectionGetPrivateLinkResource(ctx context.Context, id PrivateLinkResourceId) (result PrivateEndpointConnectionGetPrivateLinkResourceOperationResponse, 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/apimanagement/2022-08-01/privateendpointconnections/method_privateendpointconnectiongetprivatelinkresource_autorest.go b/resource-manager/apimanagement/2022-08-01/privateendpointconnections/method_privateendpointconnectiongetprivatelinkresource_autorest.go deleted file mode 100644 index 511f46e493e..00000000000 --- a/resource-manager/apimanagement/2022-08-01/privateendpointconnections/method_privateendpointconnectiongetprivatelinkresource_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package privateendpointconnections - -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 PrivateEndpointConnectionGetPrivateLinkResourceOperationResponse struct { - HttpResponse *http.Response - Model *PrivateLinkResource -} - -// PrivateEndpointConnectionGetPrivateLinkResource ... -func (c PrivateEndpointConnectionsClient) PrivateEndpointConnectionGetPrivateLinkResource(ctx context.Context, id PrivateLinkResourceId) (result PrivateEndpointConnectionGetPrivateLinkResourceOperationResponse, err error) { - req, err := c.preparerForPrivateEndpointConnectionGetPrivateLinkResource(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "privateendpointconnections.PrivateEndpointConnectionsClient", "PrivateEndpointConnectionGetPrivateLinkResource", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "privateendpointconnections.PrivateEndpointConnectionsClient", "PrivateEndpointConnectionGetPrivateLinkResource", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForPrivateEndpointConnectionGetPrivateLinkResource(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "privateendpointconnections.PrivateEndpointConnectionsClient", "PrivateEndpointConnectionGetPrivateLinkResource", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForPrivateEndpointConnectionGetPrivateLinkResource prepares the PrivateEndpointConnectionGetPrivateLinkResource request. -func (c PrivateEndpointConnectionsClient) preparerForPrivateEndpointConnectionGetPrivateLinkResource(ctx context.Context, id PrivateLinkResourceId) (*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)) -} - -// responderForPrivateEndpointConnectionGetPrivateLinkResource handles the response to the PrivateEndpointConnectionGetPrivateLinkResource request. The method always -// closes the http.Response Body. -func (c PrivateEndpointConnectionsClient) responderForPrivateEndpointConnectionGetPrivateLinkResource(resp *http.Response) (result PrivateEndpointConnectionGetPrivateLinkResourceOperationResponse, 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/apimanagement/2022-08-01/privateendpointconnections/method_privateendpointconnectionlistbyservice.go b/resource-manager/apimanagement/2022-08-01/privateendpointconnections/method_privateendpointconnectionlistbyservice.go new file mode 100644 index 00000000000..7ac03e3c251 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/privateendpointconnections/method_privateendpointconnectionlistbyservice.go @@ -0,0 +1,52 @@ +package privateendpointconnections + +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 PrivateEndpointConnectionListByServiceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PrivateEndpointConnectionListResult +} + +// PrivateEndpointConnectionListByService ... +func (c PrivateEndpointConnectionsClient) PrivateEndpointConnectionListByService(ctx context.Context, id ServiceId) (result PrivateEndpointConnectionListByServiceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/privateEndpointConnections", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.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/apimanagement/2022-08-01/privateendpointconnections/method_privateendpointconnectionlistbyservice_autorest.go b/resource-manager/apimanagement/2022-08-01/privateendpointconnections/method_privateendpointconnectionlistbyservice_autorest.go deleted file mode 100644 index a3878a76021..00000000000 --- a/resource-manager/apimanagement/2022-08-01/privateendpointconnections/method_privateendpointconnectionlistbyservice_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package privateendpointconnections - -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 PrivateEndpointConnectionListByServiceOperationResponse struct { - HttpResponse *http.Response - Model *PrivateEndpointConnectionListResult -} - -// PrivateEndpointConnectionListByService ... -func (c PrivateEndpointConnectionsClient) PrivateEndpointConnectionListByService(ctx context.Context, id ServiceId) (result PrivateEndpointConnectionListByServiceOperationResponse, err error) { - req, err := c.preparerForPrivateEndpointConnectionListByService(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "privateendpointconnections.PrivateEndpointConnectionsClient", "PrivateEndpointConnectionListByService", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "privateendpointconnections.PrivateEndpointConnectionsClient", "PrivateEndpointConnectionListByService", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForPrivateEndpointConnectionListByService(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "privateendpointconnections.PrivateEndpointConnectionsClient", "PrivateEndpointConnectionListByService", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForPrivateEndpointConnectionListByService prepares the PrivateEndpointConnectionListByService request. -func (c PrivateEndpointConnectionsClient) preparerForPrivateEndpointConnectionListByService(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(fmt.Sprintf("%s/privateEndpointConnections", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForPrivateEndpointConnectionListByService handles the response to the PrivateEndpointConnectionListByService request. The method always -// closes the http.Response Body. -func (c PrivateEndpointConnectionsClient) responderForPrivateEndpointConnectionListByService(resp *http.Response) (result PrivateEndpointConnectionListByServiceOperationResponse, 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/apimanagement/2022-08-01/privateendpointconnections/method_privateendpointconnectionlistprivatelinkresources.go b/resource-manager/apimanagement/2022-08-01/privateendpointconnections/method_privateendpointconnectionlistprivatelinkresources.go new file mode 100644 index 00000000000..5d2881f7c92 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/privateendpointconnections/method_privateendpointconnectionlistprivatelinkresources.go @@ -0,0 +1,52 @@ +package privateendpointconnections + +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 PrivateEndpointConnectionListPrivateLinkResourcesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PrivateLinkResourceListResult +} + +// PrivateEndpointConnectionListPrivateLinkResources ... +func (c PrivateEndpointConnectionsClient) PrivateEndpointConnectionListPrivateLinkResources(ctx context.Context, id ServiceId) (result PrivateEndpointConnectionListPrivateLinkResourcesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/privateLinkResources", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + if err = resp.Unmarshal(&result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2022-08-01/privateendpointconnections/method_privateendpointconnectionlistprivatelinkresources_autorest.go b/resource-manager/apimanagement/2022-08-01/privateendpointconnections/method_privateendpointconnectionlistprivatelinkresources_autorest.go deleted file mode 100644 index 2a3bdcb3962..00000000000 --- a/resource-manager/apimanagement/2022-08-01/privateendpointconnections/method_privateendpointconnectionlistprivatelinkresources_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package privateendpointconnections - -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 PrivateEndpointConnectionListPrivateLinkResourcesOperationResponse struct { - HttpResponse *http.Response - Model *PrivateLinkResourceListResult -} - -// PrivateEndpointConnectionListPrivateLinkResources ... -func (c PrivateEndpointConnectionsClient) PrivateEndpointConnectionListPrivateLinkResources(ctx context.Context, id ServiceId) (result PrivateEndpointConnectionListPrivateLinkResourcesOperationResponse, err error) { - req, err := c.preparerForPrivateEndpointConnectionListPrivateLinkResources(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "privateendpointconnections.PrivateEndpointConnectionsClient", "PrivateEndpointConnectionListPrivateLinkResources", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "privateendpointconnections.PrivateEndpointConnectionsClient", "PrivateEndpointConnectionListPrivateLinkResources", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForPrivateEndpointConnectionListPrivateLinkResources(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "privateendpointconnections.PrivateEndpointConnectionsClient", "PrivateEndpointConnectionListPrivateLinkResources", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForPrivateEndpointConnectionListPrivateLinkResources prepares the PrivateEndpointConnectionListPrivateLinkResources request. -func (c PrivateEndpointConnectionsClient) preparerForPrivateEndpointConnectionListPrivateLinkResources(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(fmt.Sprintf("%s/privateLinkResources", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForPrivateEndpointConnectionListPrivateLinkResources handles the response to the PrivateEndpointConnectionListPrivateLinkResources request. The method always -// closes the http.Response Body. -func (c PrivateEndpointConnectionsClient) responderForPrivateEndpointConnectionListPrivateLinkResources(resp *http.Response) (result PrivateEndpointConnectionListPrivateLinkResourcesOperationResponse, 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/apimanagement/2022-08-01/product/client.go b/resource-manager/apimanagement/2022-08-01/product/client.go index 964cb7131cc..558149db254 100644 --- a/resource-manager/apimanagement/2022-08-01/product/client.go +++ b/resource-manager/apimanagement/2022-08-01/product/client.go @@ -1,18 +1,26 @@ package product -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 ProductClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewProductClientWithBaseURI(endpoint string) ProductClient { - return ProductClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewProductClientWithBaseURI(api environments.Api) (*ProductClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "product", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ProductClient: %+v", err) } + + return &ProductClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2022-08-01/product/constants.go b/resource-manager/apimanagement/2022-08-01/product/constants.go index d9ad59725fd..b1aa827fdb2 100644 --- a/resource-manager/apimanagement/2022-08-01/product/constants.go +++ b/resource-manager/apimanagement/2022-08-01/product/constants.go @@ -1,6 +1,10 @@ package product -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 PossibleValuesForProductState() []string { } } +func (s *ProductState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProductState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseProductState(input string) (*ProductState, error) { vals := map[string]ProductState{ "notpublished": ProductStateNotPublished, diff --git a/resource-manager/apimanagement/2022-08-01/product/method_createorupdate.go b/resource-manager/apimanagement/2022-08-01/product/method_createorupdate.go new file mode 100644 index 00000000000..dc69508e31c --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/product/method_createorupdate.go @@ -0,0 +1,85 @@ +package product + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ProductContract +} + +type CreateOrUpdateOperationOptions struct { + IfMatch *string +} + +func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { + return CreateOrUpdateOperationOptions{} +} + +func (o CreateOrUpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o CreateOrUpdateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o CreateOrUpdateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// CreateOrUpdate ... +func (c ProductClient) CreateOrUpdate(ctx context.Context, id ProductId, input ProductContract, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + OptionsObject: options, + } + + 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/apimanagement/2022-08-01/product/method_createorupdate_autorest.go b/resource-manager/apimanagement/2022-08-01/product/method_createorupdate_autorest.go deleted file mode 100644 index 22bfb9119bf..00000000000 --- a/resource-manager/apimanagement/2022-08-01/product/method_createorupdate_autorest.go +++ /dev/null @@ -1,98 +0,0 @@ -package product - -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 *ProductContract -} - -type CreateOrUpdateOperationOptions struct { - IfMatch *string -} - -func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { - return CreateOrUpdateOperationOptions{} -} - -func (o CreateOrUpdateOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o CreateOrUpdateOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// CreateOrUpdate ... -func (c ProductClient) CreateOrUpdate(ctx context.Context, id ProductId, input ProductContract, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdate(ctx, id, input, options) - if err != nil { - err = autorest.NewErrorWithError(err, "product.ProductClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "product.ProductClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCreateOrUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "product.ProductClient", "CreateOrUpdate", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCreateOrUpdate prepares the CreateOrUpdate request. -func (c ProductClient) preparerForCreateOrUpdate(ctx context.Context, id ProductId, input ProductContract, options CreateOrUpdateOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - 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 ProductClient) responderForCreateOrUpdate(resp *http.Response) (result CreateOrUpdateOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2022-08-01/product/method_delete.go b/resource-manager/apimanagement/2022-08-01/product/method_delete.go new file mode 100644 index 00000000000..a2aebab1182 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/product/method_delete.go @@ -0,0 +1,79 @@ +package product + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +type DeleteOperationOptions struct { + DeleteSubscriptions *bool + IfMatch *string +} + +func DefaultDeleteOperationOptions() DeleteOperationOptions { + return DeleteOperationOptions{} +} + +func (o DeleteOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o DeleteOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o DeleteOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.DeleteSubscriptions != nil { + out.Append("deleteSubscriptions", fmt.Sprintf("%v", *o.DeleteSubscriptions)) + } + return &out +} + +// Delete ... +func (c ProductClient) Delete(ctx context.Context, id ProductId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2022-08-01/product/method_delete_autorest.go b/resource-manager/apimanagement/2022-08-01/product/method_delete_autorest.go deleted file mode 100644 index 6646be8a32f..00000000000 --- a/resource-manager/apimanagement/2022-08-01/product/method_delete_autorest.go +++ /dev/null @@ -1,100 +0,0 @@ -package product - -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 DeleteOperationResponse struct { - HttpResponse *http.Response -} - -type DeleteOperationOptions struct { - DeleteSubscriptions *bool - IfMatch *string -} - -func DefaultDeleteOperationOptions() DeleteOperationOptions { - return DeleteOperationOptions{} -} - -func (o DeleteOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o DeleteOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.DeleteSubscriptions != nil { - out["deleteSubscriptions"] = *o.DeleteSubscriptions - } - - return out -} - -// Delete ... -func (c ProductClient) Delete(ctx context.Context, id ProductId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { - req, err := c.preparerForDelete(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "product.ProductClient", "Delete", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "product.ProductClient", "Delete", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForDelete(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "product.ProductClient", "Delete", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForDelete prepares the Delete request. -func (c ProductClient) preparerForDelete(ctx context.Context, id ProductId, options DeleteOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForDelete handles the response to the Delete request. The method always -// closes the http.Response Body. -func (c ProductClient) responderForDelete(resp *http.Response) (result DeleteOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2022-08-01/product/method_get.go b/resource-manager/apimanagement/2022-08-01/product/method_get.go new file mode 100644 index 00000000000..41152aebc0a --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/product/method_get.go @@ -0,0 +1,51 @@ +package product + +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 *ProductContract +} + +// Get ... +func (c ProductClient) Get(ctx context.Context, id ProductId) (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/apimanagement/2022-08-01/product/method_get_autorest.go b/resource-manager/apimanagement/2022-08-01/product/method_get_autorest.go deleted file mode 100644 index 42680f3af9f..00000000000 --- a/resource-manager/apimanagement/2022-08-01/product/method_get_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package product - -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 *ProductContract -} - -// Get ... -func (c ProductClient) Get(ctx context.Context, id ProductId) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "product.ProductClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "product.ProductClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "product.ProductClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c ProductClient) preparerForGet(ctx context.Context, id ProductId) (*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 ProductClient) 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/apimanagement/2022-08-01/product/method_getentitytag.go b/resource-manager/apimanagement/2022-08-01/product/method_getentitytag.go new file mode 100644 index 00000000000..667f4afad59 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/product/method_getentitytag.go @@ -0,0 +1,46 @@ +package product + +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 GetEntityTagOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// GetEntityTag ... +func (c ProductClient) GetEntityTag(ctx context.Context, id ProductId) (result GetEntityTagOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodHead, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2022-08-01/product/method_getentitytag_autorest.go b/resource-manager/apimanagement/2022-08-01/product/method_getentitytag_autorest.go deleted file mode 100644 index b25eb533c2c..00000000000 --- a/resource-manager/apimanagement/2022-08-01/product/method_getentitytag_autorest.go +++ /dev/null @@ -1,66 +0,0 @@ -package product - -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 GetEntityTagOperationResponse struct { - HttpResponse *http.Response -} - -// GetEntityTag ... -func (c ProductClient) GetEntityTag(ctx context.Context, id ProductId) (result GetEntityTagOperationResponse, err error) { - req, err := c.preparerForGetEntityTag(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "product.ProductClient", "GetEntityTag", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "product.ProductClient", "GetEntityTag", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetEntityTag(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "product.ProductClient", "GetEntityTag", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetEntityTag prepares the GetEntityTag request. -func (c ProductClient) preparerForGetEntityTag(ctx context.Context, id ProductId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsHead(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetEntityTag handles the response to the GetEntityTag request. The method always -// closes the http.Response Body. -func (c ProductClient) responderForGetEntityTag(resp *http.Response) (result GetEntityTagOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2022-08-01/product/method_listbyservice.go b/resource-manager/apimanagement/2022-08-01/product/method_listbyservice.go new file mode 100644 index 00000000000..66a835096aa --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/product/method_listbyservice.go @@ -0,0 +1,133 @@ +package product + +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 ListByServiceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ProductContract +} + +type ListByServiceCompleteResult struct { + Items []ProductContract +} + +type ListByServiceOperationOptions struct { + ExpandGroups *bool + Filter *string + Skip *int64 + Tags *string + Top *int64 +} + +func DefaultListByServiceOperationOptions() ListByServiceOperationOptions { + return ListByServiceOperationOptions{} +} + +func (o ListByServiceOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListByServiceOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListByServiceOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.ExpandGroups != nil { + out.Append("expandGroups", fmt.Sprintf("%v", *o.ExpandGroups)) + } + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.Skip != nil { + out.Append("$skip", fmt.Sprintf("%v", *o.Skip)) + } + if o.Tags != nil { + out.Append("tags", fmt.Sprintf("%v", *o.Tags)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +// ListByService ... +func (c ProductClient) ListByService(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (result ListByServiceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/products", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ProductContract `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByServiceComplete retrieves all the results into a single object +func (c ProductClient) ListByServiceComplete(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (ListByServiceCompleteResult, error) { + return c.ListByServiceCompleteMatchingPredicate(ctx, id, options, ProductContractOperationPredicate{}) +} + +// ListByServiceCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ProductClient) ListByServiceCompleteMatchingPredicate(ctx context.Context, id ServiceId, options ListByServiceOperationOptions, predicate ProductContractOperationPredicate) (result ListByServiceCompleteResult, err error) { + items := make([]ProductContract, 0) + + resp, err := c.ListByService(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByServiceCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/apimanagement/2022-08-01/product/method_listbyservice_autorest.go b/resource-manager/apimanagement/2022-08-01/product/method_listbyservice_autorest.go deleted file mode 100644 index 5187a25caa7..00000000000 --- a/resource-manager/apimanagement/2022-08-01/product/method_listbyservice_autorest.go +++ /dev/null @@ -1,235 +0,0 @@ -package product - -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 ListByServiceOperationResponse struct { - HttpResponse *http.Response - Model *[]ProductContract - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListByServiceOperationResponse, error) -} - -type ListByServiceCompleteResult struct { - Items []ProductContract -} - -func (r ListByServiceOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListByServiceOperationResponse) LoadMore(ctx context.Context) (resp ListByServiceOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -type ListByServiceOperationOptions struct { - ExpandGroups *bool - Filter *string - Skip *int64 - Tags *string - Top *int64 -} - -func DefaultListByServiceOperationOptions() ListByServiceOperationOptions { - return ListByServiceOperationOptions{} -} - -func (o ListByServiceOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o ListByServiceOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.ExpandGroups != nil { - out["expandGroups"] = *o.ExpandGroups - } - - if o.Filter != nil { - out["$filter"] = *o.Filter - } - - if o.Skip != nil { - out["$skip"] = *o.Skip - } - - if o.Tags != nil { - out["tags"] = *o.Tags - } - - if o.Top != nil { - out["$top"] = *o.Top - } - - return out -} - -// ListByService ... -func (c ProductClient) ListByService(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (resp ListByServiceOperationResponse, err error) { - req, err := c.preparerForListByService(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "product.ProductClient", "ListByService", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "product.ProductClient", "ListByService", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListByService(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "product.ProductClient", "ListByService", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListByService prepares the ListByService request. -func (c ProductClient) preparerForListByService(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/products", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListByServiceWithNextLink prepares the ListByService request with the given nextLink token. -func (c ProductClient) preparerForListByServiceWithNextLink(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)) -} - -// responderForListByService handles the response to the ListByService request. The method always -// closes the http.Response Body. -func (c ProductClient) responderForListByService(resp *http.Response) (result ListByServiceOperationResponse, err error) { - type page struct { - Values []ProductContract `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 ListByServiceOperationResponse, err error) { - req, err := c.preparerForListByServiceWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "product.ProductClient", "ListByService", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "product.ProductClient", "ListByService", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByService(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "product.ProductClient", "ListByService", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListByServiceComplete retrieves all of the results into a single object -func (c ProductClient) ListByServiceComplete(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (ListByServiceCompleteResult, error) { - return c.ListByServiceCompleteMatchingPredicate(ctx, id, options, ProductContractOperationPredicate{}) -} - -// ListByServiceCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c ProductClient) ListByServiceCompleteMatchingPredicate(ctx context.Context, id ServiceId, options ListByServiceOperationOptions, predicate ProductContractOperationPredicate) (resp ListByServiceCompleteResult, err error) { - items := make([]ProductContract, 0) - - page, err := c.ListByService(ctx, id, options) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListByServiceCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/apimanagement/2022-08-01/product/method_update.go b/resource-manager/apimanagement/2022-08-01/product/method_update.go new file mode 100644 index 00000000000..a9a59bd595e --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/product/method_update.go @@ -0,0 +1,84 @@ +package product + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ProductContract +} + +type UpdateOperationOptions struct { + IfMatch *string +} + +func DefaultUpdateOperationOptions() UpdateOperationOptions { + return UpdateOperationOptions{} +} + +func (o UpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o UpdateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o UpdateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// Update ... +func (c ProductClient) Update(ctx context.Context, id ProductId, input ProductUpdateParameters, options UpdateOperationOptions) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + OptionsObject: options, + } + + 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/apimanagement/2022-08-01/product/method_update_autorest.go b/resource-manager/apimanagement/2022-08-01/product/method_update_autorest.go deleted file mode 100644 index d0fbe1007f8..00000000000 --- a/resource-manager/apimanagement/2022-08-01/product/method_update_autorest.go +++ /dev/null @@ -1,98 +0,0 @@ -package product - -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 *ProductContract -} - -type UpdateOperationOptions struct { - IfMatch *string -} - -func DefaultUpdateOperationOptions() UpdateOperationOptions { - return UpdateOperationOptions{} -} - -func (o UpdateOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o UpdateOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// Update ... -func (c ProductClient) Update(ctx context.Context, id ProductId, input ProductUpdateParameters, options UpdateOperationOptions) (result UpdateOperationResponse, err error) { - req, err := c.preparerForUpdate(ctx, id, input, options) - if err != nil { - err = autorest.NewErrorWithError(err, "product.ProductClient", "Update", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "product.ProductClient", "Update", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "product.ProductClient", "Update", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForUpdate prepares the Update request. -func (c ProductClient) preparerForUpdate(ctx context.Context, id ProductId, input ProductUpdateParameters, options UpdateOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPatch(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - 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 ProductClient) 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/apimanagement/2022-08-01/productapi/client.go b/resource-manager/apimanagement/2022-08-01/productapi/client.go index 5241293a527..1498ceafe98 100644 --- a/resource-manager/apimanagement/2022-08-01/productapi/client.go +++ b/resource-manager/apimanagement/2022-08-01/productapi/client.go @@ -1,18 +1,26 @@ package productapi -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 ProductApiClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewProductApiClientWithBaseURI(endpoint string) ProductApiClient { - return ProductApiClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewProductApiClientWithBaseURI(api environments.Api) (*ProductApiClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "productapi", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ProductApiClient: %+v", err) } + + return &ProductApiClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2022-08-01/productapi/constants.go b/resource-manager/apimanagement/2022-08-01/productapi/constants.go index 0b289271d26..a2efe7f0641 100644 --- a/resource-manager/apimanagement/2022-08-01/productapi/constants.go +++ b/resource-manager/apimanagement/2022-08-01/productapi/constants.go @@ -1,6 +1,10 @@ package productapi -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 PossibleValuesForApiType() []string { } } +func (s *ApiType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseApiType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseApiType(input string) (*ApiType, error) { vals := map[string]ApiType{ "graphql": ApiTypeGraphql, @@ -53,6 +70,19 @@ func PossibleValuesForBearerTokenSendingMethods() []string { } } +func (s *BearerTokenSendingMethods) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseBearerTokenSendingMethods(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseBearerTokenSendingMethods(input string) (*BearerTokenSendingMethods, error) { vals := map[string]BearerTokenSendingMethods{ "authorizationheader": BearerTokenSendingMethodsAuthorizationHeader, @@ -85,6 +115,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{ "http": ProtocolHTTP, @@ -117,6 +160,19 @@ func PossibleValuesForVersioningScheme() []string { } } +func (s *VersioningScheme) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseVersioningScheme(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseVersioningScheme(input string) (*VersioningScheme, error) { vals := map[string]VersioningScheme{ "header": VersioningSchemeHeader, diff --git a/resource-manager/apimanagement/2022-08-01/productapi/method_checkentityexists.go b/resource-manager/apimanagement/2022-08-01/productapi/method_checkentityexists.go new file mode 100644 index 00000000000..69d91adfcef --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/productapi/method_checkentityexists.go @@ -0,0 +1,46 @@ +package productapi + +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 CheckEntityExistsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// CheckEntityExists ... +func (c ProductApiClient) CheckEntityExists(ctx context.Context, id ProductApiId) (result CheckEntityExistsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: http.MethodHead, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2022-08-01/productapi/method_checkentityexists_autorest.go b/resource-manager/apimanagement/2022-08-01/productapi/method_checkentityexists_autorest.go deleted file mode 100644 index 37008921ef3..00000000000 --- a/resource-manager/apimanagement/2022-08-01/productapi/method_checkentityexists_autorest.go +++ /dev/null @@ -1,66 +0,0 @@ -package productapi - -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 CheckEntityExistsOperationResponse struct { - HttpResponse *http.Response -} - -// CheckEntityExists ... -func (c ProductApiClient) CheckEntityExists(ctx context.Context, id ProductApiId) (result CheckEntityExistsOperationResponse, err error) { - req, err := c.preparerForCheckEntityExists(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "productapi.ProductApiClient", "CheckEntityExists", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "productapi.ProductApiClient", "CheckEntityExists", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCheckEntityExists(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "productapi.ProductApiClient", "CheckEntityExists", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCheckEntityExists prepares the CheckEntityExists request. -func (c ProductApiClient) preparerForCheckEntityExists(ctx context.Context, id ProductApiId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsHead(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForCheckEntityExists handles the response to the CheckEntityExists request. The method always -// closes the http.Response Body. -func (c ProductApiClient) responderForCheckEntityExists(resp *http.Response) (result CheckEntityExistsOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2022-08-01/productapi/method_createorupdate.go b/resource-manager/apimanagement/2022-08-01/productapi/method_createorupdate.go new file mode 100644 index 00000000000..cfa64d59695 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/productapi/method_createorupdate.go @@ -0,0 +1,52 @@ +package productapi + +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 *ApiContract +} + +// CreateOrUpdate ... +func (c ProductApiClient) CreateOrUpdate(ctx context.Context, id ProductApiId) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + 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/apimanagement/2022-08-01/productapi/method_createorupdate_autorest.go b/resource-manager/apimanagement/2022-08-01/productapi/method_createorupdate_autorest.go deleted file mode 100644 index 1df50bc936d..00000000000 --- a/resource-manager/apimanagement/2022-08-01/productapi/method_createorupdate_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package productapi - -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 *ApiContract -} - -// CreateOrUpdate ... -func (c ProductApiClient) CreateOrUpdate(ctx context.Context, id ProductApiId) (result CreateOrUpdateOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdate(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "productapi.ProductApiClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "productapi.ProductApiClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCreateOrUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "productapi.ProductApiClient", "CreateOrUpdate", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCreateOrUpdate prepares the CreateOrUpdate request. -func (c ProductApiClient) preparerForCreateOrUpdate(ctx context.Context, id ProductApiId) (*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.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 ProductApiClient) responderForCreateOrUpdate(resp *http.Response) (result CreateOrUpdateOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2022-08-01/productapi/method_delete.go b/resource-manager/apimanagement/2022-08-01/productapi/method_delete.go new file mode 100644 index 00000000000..da188ce2e72 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/productapi/method_delete.go @@ -0,0 +1,47 @@ +package productapi + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c ProductApiClient) Delete(ctx context.Context, id ProductApiId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2022-08-01/productapi/method_delete_autorest.go b/resource-manager/apimanagement/2022-08-01/productapi/method_delete_autorest.go deleted file mode 100644 index b31ea2b6eef..00000000000 --- a/resource-manager/apimanagement/2022-08-01/productapi/method_delete_autorest.go +++ /dev/null @@ -1,66 +0,0 @@ -package productapi - -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 DeleteOperationResponse struct { - HttpResponse *http.Response -} - -// Delete ... -func (c ProductApiClient) Delete(ctx context.Context, id ProductApiId) (result DeleteOperationResponse, err error) { - req, err := c.preparerForDelete(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "productapi.ProductApiClient", "Delete", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "productapi.ProductApiClient", "Delete", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForDelete(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "productapi.ProductApiClient", "Delete", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForDelete prepares the Delete request. -func (c ProductApiClient) preparerForDelete(ctx context.Context, id ProductApiId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForDelete handles the response to the Delete request. The method always -// closes the http.Response Body. -func (c ProductApiClient) responderForDelete(resp *http.Response) (result DeleteOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2022-08-01/productapi/method_listbyproduct.go b/resource-manager/apimanagement/2022-08-01/productapi/method_listbyproduct.go new file mode 100644 index 00000000000..fbe56652d12 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/productapi/method_listbyproduct.go @@ -0,0 +1,125 @@ +package productapi + +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 ListByProductOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ApiContract +} + +type ListByProductCompleteResult struct { + Items []ApiContract +} + +type ListByProductOperationOptions struct { + Filter *string + Skip *int64 + Top *int64 +} + +func DefaultListByProductOperationOptions() ListByProductOperationOptions { + return ListByProductOperationOptions{} +} + +func (o ListByProductOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListByProductOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListByProductOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.Skip != nil { + out.Append("$skip", fmt.Sprintf("%v", *o.Skip)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +// ListByProduct ... +func (c ProductApiClient) ListByProduct(ctx context.Context, id ProductId, options ListByProductOperationOptions) (result ListByProductOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/apis", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ApiContract `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByProductComplete retrieves all the results into a single object +func (c ProductApiClient) ListByProductComplete(ctx context.Context, id ProductId, options ListByProductOperationOptions) (ListByProductCompleteResult, error) { + return c.ListByProductCompleteMatchingPredicate(ctx, id, options, ApiContractOperationPredicate{}) +} + +// ListByProductCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ProductApiClient) ListByProductCompleteMatchingPredicate(ctx context.Context, id ProductId, options ListByProductOperationOptions, predicate ApiContractOperationPredicate) (result ListByProductCompleteResult, err error) { + items := make([]ApiContract, 0) + + resp, err := c.ListByProduct(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByProductCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/apimanagement/2022-08-01/productapi/method_listbyproduct_autorest.go b/resource-manager/apimanagement/2022-08-01/productapi/method_listbyproduct_autorest.go deleted file mode 100644 index 5a0bdb0c971..00000000000 --- a/resource-manager/apimanagement/2022-08-01/productapi/method_listbyproduct_autorest.go +++ /dev/null @@ -1,225 +0,0 @@ -package productapi - -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 ListByProductOperationResponse struct { - HttpResponse *http.Response - Model *[]ApiContract - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListByProductOperationResponse, error) -} - -type ListByProductCompleteResult struct { - Items []ApiContract -} - -func (r ListByProductOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListByProductOperationResponse) LoadMore(ctx context.Context) (resp ListByProductOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -type ListByProductOperationOptions struct { - Filter *string - Skip *int64 - Top *int64 -} - -func DefaultListByProductOperationOptions() ListByProductOperationOptions { - return ListByProductOperationOptions{} -} - -func (o ListByProductOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o ListByProductOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Filter != nil { - out["$filter"] = *o.Filter - } - - if o.Skip != nil { - out["$skip"] = *o.Skip - } - - if o.Top != nil { - out["$top"] = *o.Top - } - - return out -} - -// ListByProduct ... -func (c ProductApiClient) ListByProduct(ctx context.Context, id ProductId, options ListByProductOperationOptions) (resp ListByProductOperationResponse, err error) { - req, err := c.preparerForListByProduct(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "productapi.ProductApiClient", "ListByProduct", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "productapi.ProductApiClient", "ListByProduct", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListByProduct(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "productapi.ProductApiClient", "ListByProduct", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListByProduct prepares the ListByProduct request. -func (c ProductApiClient) preparerForListByProduct(ctx context.Context, id ProductId, options ListByProductOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/apis", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListByProductWithNextLink prepares the ListByProduct request with the given nextLink token. -func (c ProductApiClient) preparerForListByProductWithNextLink(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)) -} - -// responderForListByProduct handles the response to the ListByProduct request. The method always -// closes the http.Response Body. -func (c ProductApiClient) responderForListByProduct(resp *http.Response) (result ListByProductOperationResponse, err error) { - type page struct { - Values []ApiContract `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 ListByProductOperationResponse, err error) { - req, err := c.preparerForListByProductWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "productapi.ProductApiClient", "ListByProduct", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "productapi.ProductApiClient", "ListByProduct", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByProduct(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "productapi.ProductApiClient", "ListByProduct", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListByProductComplete retrieves all of the results into a single object -func (c ProductApiClient) ListByProductComplete(ctx context.Context, id ProductId, options ListByProductOperationOptions) (ListByProductCompleteResult, error) { - return c.ListByProductCompleteMatchingPredicate(ctx, id, options, ApiContractOperationPredicate{}) -} - -// ListByProductCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c ProductApiClient) ListByProductCompleteMatchingPredicate(ctx context.Context, id ProductId, options ListByProductOperationOptions, predicate ApiContractOperationPredicate) (resp ListByProductCompleteResult, err error) { - items := make([]ApiContract, 0) - - page, err := c.ListByProduct(ctx, id, options) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListByProductCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/apimanagement/2022-08-01/productgroup/client.go b/resource-manager/apimanagement/2022-08-01/productgroup/client.go index 08ea091f6e7..6d12fafe195 100644 --- a/resource-manager/apimanagement/2022-08-01/productgroup/client.go +++ b/resource-manager/apimanagement/2022-08-01/productgroup/client.go @@ -1,18 +1,26 @@ package productgroup -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 ProductGroupClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewProductGroupClientWithBaseURI(endpoint string) ProductGroupClient { - return ProductGroupClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewProductGroupClientWithBaseURI(api environments.Api) (*ProductGroupClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "productgroup", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ProductGroupClient: %+v", err) } + + return &ProductGroupClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2022-08-01/productgroup/constants.go b/resource-manager/apimanagement/2022-08-01/productgroup/constants.go index 07ce1de89e9..6ff85f660bd 100644 --- a/resource-manager/apimanagement/2022-08-01/productgroup/constants.go +++ b/resource-manager/apimanagement/2022-08-01/productgroup/constants.go @@ -1,6 +1,10 @@ package productgroup -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 PossibleValuesForGroupType() []string { } } +func (s *GroupType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseGroupType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseGroupType(input string) (*GroupType, error) { vals := map[string]GroupType{ "custom": GroupTypeCustom, diff --git a/resource-manager/apimanagement/2022-08-01/productgroup/method_checkentityexists.go b/resource-manager/apimanagement/2022-08-01/productgroup/method_checkentityexists.go new file mode 100644 index 00000000000..fd90f4c41cf --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/productgroup/method_checkentityexists.go @@ -0,0 +1,46 @@ +package productgroup + +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 CheckEntityExistsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// CheckEntityExists ... +func (c ProductGroupClient) CheckEntityExists(ctx context.Context, id ProductGroupId) (result CheckEntityExistsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: http.MethodHead, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2022-08-01/productgroup/method_checkentityexists_autorest.go b/resource-manager/apimanagement/2022-08-01/productgroup/method_checkentityexists_autorest.go deleted file mode 100644 index 034a222674f..00000000000 --- a/resource-manager/apimanagement/2022-08-01/productgroup/method_checkentityexists_autorest.go +++ /dev/null @@ -1,66 +0,0 @@ -package productgroup - -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 CheckEntityExistsOperationResponse struct { - HttpResponse *http.Response -} - -// CheckEntityExists ... -func (c ProductGroupClient) CheckEntityExists(ctx context.Context, id ProductGroupId) (result CheckEntityExistsOperationResponse, err error) { - req, err := c.preparerForCheckEntityExists(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "productgroup.ProductGroupClient", "CheckEntityExists", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "productgroup.ProductGroupClient", "CheckEntityExists", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCheckEntityExists(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "productgroup.ProductGroupClient", "CheckEntityExists", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCheckEntityExists prepares the CheckEntityExists request. -func (c ProductGroupClient) preparerForCheckEntityExists(ctx context.Context, id ProductGroupId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsHead(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForCheckEntityExists handles the response to the CheckEntityExists request. The method always -// closes the http.Response Body. -func (c ProductGroupClient) responderForCheckEntityExists(resp *http.Response) (result CheckEntityExistsOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2022-08-01/productgroup/method_createorupdate.go b/resource-manager/apimanagement/2022-08-01/productgroup/method_createorupdate.go new file mode 100644 index 00000000000..20656a3ff19 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/productgroup/method_createorupdate.go @@ -0,0 +1,52 @@ +package productgroup + +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 *GroupContract +} + +// CreateOrUpdate ... +func (c ProductGroupClient) CreateOrUpdate(ctx context.Context, id ProductGroupId) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + 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/apimanagement/2022-08-01/productgroup/method_createorupdate_autorest.go b/resource-manager/apimanagement/2022-08-01/productgroup/method_createorupdate_autorest.go deleted file mode 100644 index 578f327aa82..00000000000 --- a/resource-manager/apimanagement/2022-08-01/productgroup/method_createorupdate_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package productgroup - -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 *GroupContract -} - -// CreateOrUpdate ... -func (c ProductGroupClient) CreateOrUpdate(ctx context.Context, id ProductGroupId) (result CreateOrUpdateOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdate(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "productgroup.ProductGroupClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "productgroup.ProductGroupClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCreateOrUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "productgroup.ProductGroupClient", "CreateOrUpdate", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCreateOrUpdate prepares the CreateOrUpdate request. -func (c ProductGroupClient) preparerForCreateOrUpdate(ctx context.Context, id ProductGroupId) (*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.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 ProductGroupClient) responderForCreateOrUpdate(resp *http.Response) (result CreateOrUpdateOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2022-08-01/productgroup/method_delete.go b/resource-manager/apimanagement/2022-08-01/productgroup/method_delete.go new file mode 100644 index 00000000000..3f6b1c8820e --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/productgroup/method_delete.go @@ -0,0 +1,47 @@ +package productgroup + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c ProductGroupClient) Delete(ctx context.Context, id ProductGroupId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2022-08-01/productgroup/method_delete_autorest.go b/resource-manager/apimanagement/2022-08-01/productgroup/method_delete_autorest.go deleted file mode 100644 index 0bc4bd9be4c..00000000000 --- a/resource-manager/apimanagement/2022-08-01/productgroup/method_delete_autorest.go +++ /dev/null @@ -1,66 +0,0 @@ -package productgroup - -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 DeleteOperationResponse struct { - HttpResponse *http.Response -} - -// Delete ... -func (c ProductGroupClient) Delete(ctx context.Context, id ProductGroupId) (result DeleteOperationResponse, err error) { - req, err := c.preparerForDelete(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "productgroup.ProductGroupClient", "Delete", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "productgroup.ProductGroupClient", "Delete", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForDelete(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "productgroup.ProductGroupClient", "Delete", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForDelete prepares the Delete request. -func (c ProductGroupClient) preparerForDelete(ctx context.Context, id ProductGroupId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForDelete handles the response to the Delete request. The method always -// closes the http.Response Body. -func (c ProductGroupClient) responderForDelete(resp *http.Response) (result DeleteOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2022-08-01/productgroup/method_listbyproduct.go b/resource-manager/apimanagement/2022-08-01/productgroup/method_listbyproduct.go new file mode 100644 index 00000000000..483d84c6da7 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/productgroup/method_listbyproduct.go @@ -0,0 +1,125 @@ +package productgroup + +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 ListByProductOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]GroupContract +} + +type ListByProductCompleteResult struct { + Items []GroupContract +} + +type ListByProductOperationOptions struct { + Filter *string + Skip *int64 + Top *int64 +} + +func DefaultListByProductOperationOptions() ListByProductOperationOptions { + return ListByProductOperationOptions{} +} + +func (o ListByProductOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListByProductOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListByProductOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.Skip != nil { + out.Append("$skip", fmt.Sprintf("%v", *o.Skip)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +// ListByProduct ... +func (c ProductGroupClient) ListByProduct(ctx context.Context, id ProductId, options ListByProductOperationOptions) (result ListByProductOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/groups", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]GroupContract `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByProductComplete retrieves all the results into a single object +func (c ProductGroupClient) ListByProductComplete(ctx context.Context, id ProductId, options ListByProductOperationOptions) (ListByProductCompleteResult, error) { + return c.ListByProductCompleteMatchingPredicate(ctx, id, options, GroupContractOperationPredicate{}) +} + +// ListByProductCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ProductGroupClient) ListByProductCompleteMatchingPredicate(ctx context.Context, id ProductId, options ListByProductOperationOptions, predicate GroupContractOperationPredicate) (result ListByProductCompleteResult, err error) { + items := make([]GroupContract, 0) + + resp, err := c.ListByProduct(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByProductCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/apimanagement/2022-08-01/productgroup/method_listbyproduct_autorest.go b/resource-manager/apimanagement/2022-08-01/productgroup/method_listbyproduct_autorest.go deleted file mode 100644 index f5f186c5b31..00000000000 --- a/resource-manager/apimanagement/2022-08-01/productgroup/method_listbyproduct_autorest.go +++ /dev/null @@ -1,225 +0,0 @@ -package productgroup - -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 ListByProductOperationResponse struct { - HttpResponse *http.Response - Model *[]GroupContract - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListByProductOperationResponse, error) -} - -type ListByProductCompleteResult struct { - Items []GroupContract -} - -func (r ListByProductOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListByProductOperationResponse) LoadMore(ctx context.Context) (resp ListByProductOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -type ListByProductOperationOptions struct { - Filter *string - Skip *int64 - Top *int64 -} - -func DefaultListByProductOperationOptions() ListByProductOperationOptions { - return ListByProductOperationOptions{} -} - -func (o ListByProductOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o ListByProductOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Filter != nil { - out["$filter"] = *o.Filter - } - - if o.Skip != nil { - out["$skip"] = *o.Skip - } - - if o.Top != nil { - out["$top"] = *o.Top - } - - return out -} - -// ListByProduct ... -func (c ProductGroupClient) ListByProduct(ctx context.Context, id ProductId, options ListByProductOperationOptions) (resp ListByProductOperationResponse, err error) { - req, err := c.preparerForListByProduct(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "productgroup.ProductGroupClient", "ListByProduct", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "productgroup.ProductGroupClient", "ListByProduct", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListByProduct(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "productgroup.ProductGroupClient", "ListByProduct", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListByProduct prepares the ListByProduct request. -func (c ProductGroupClient) preparerForListByProduct(ctx context.Context, id ProductId, options ListByProductOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/groups", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListByProductWithNextLink prepares the ListByProduct request with the given nextLink token. -func (c ProductGroupClient) preparerForListByProductWithNextLink(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)) -} - -// responderForListByProduct handles the response to the ListByProduct request. The method always -// closes the http.Response Body. -func (c ProductGroupClient) responderForListByProduct(resp *http.Response) (result ListByProductOperationResponse, err error) { - type page struct { - Values []GroupContract `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 ListByProductOperationResponse, err error) { - req, err := c.preparerForListByProductWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "productgroup.ProductGroupClient", "ListByProduct", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "productgroup.ProductGroupClient", "ListByProduct", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByProduct(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "productgroup.ProductGroupClient", "ListByProduct", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListByProductComplete retrieves all of the results into a single object -func (c ProductGroupClient) ListByProductComplete(ctx context.Context, id ProductId, options ListByProductOperationOptions) (ListByProductCompleteResult, error) { - return c.ListByProductCompleteMatchingPredicate(ctx, id, options, GroupContractOperationPredicate{}) -} - -// ListByProductCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c ProductGroupClient) ListByProductCompleteMatchingPredicate(ctx context.Context, id ProductId, options ListByProductOperationOptions, predicate GroupContractOperationPredicate) (resp ListByProductCompleteResult, err error) { - items := make([]GroupContract, 0) - - page, err := c.ListByProduct(ctx, id, options) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListByProductCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/apimanagement/2022-08-01/productpolicy/client.go b/resource-manager/apimanagement/2022-08-01/productpolicy/client.go index dfce4d67a5d..406874ed741 100644 --- a/resource-manager/apimanagement/2022-08-01/productpolicy/client.go +++ b/resource-manager/apimanagement/2022-08-01/productpolicy/client.go @@ -1,18 +1,26 @@ package productpolicy -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 ProductPolicyClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewProductPolicyClientWithBaseURI(endpoint string) ProductPolicyClient { - return ProductPolicyClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewProductPolicyClientWithBaseURI(api environments.Api) (*ProductPolicyClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "productpolicy", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ProductPolicyClient: %+v", err) } + + return &ProductPolicyClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2022-08-01/productpolicy/constants.go b/resource-manager/apimanagement/2022-08-01/productpolicy/constants.go index 9408a1eb3a8..196b57d596f 100644 --- a/resource-manager/apimanagement/2022-08-01/productpolicy/constants.go +++ b/resource-manager/apimanagement/2022-08-01/productpolicy/constants.go @@ -1,6 +1,10 @@ package productpolicy -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 PossibleValuesForPolicyContentFormat() []string { } } +func (s *PolicyContentFormat) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePolicyContentFormat(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parsePolicyContentFormat(input string) (*PolicyContentFormat, error) { vals := map[string]PolicyContentFormat{ "rawxml": PolicyContentFormatRawxml, @@ -53,6 +70,19 @@ func PossibleValuesForPolicyExportFormat() []string { } } +func (s *PolicyExportFormat) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePolicyExportFormat(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parsePolicyExportFormat(input string) (*PolicyExportFormat, error) { vals := map[string]PolicyExportFormat{ "rawxml": PolicyExportFormatRawxml, diff --git a/resource-manager/apimanagement/2022-08-01/productpolicy/method_createorupdate.go b/resource-manager/apimanagement/2022-08-01/productpolicy/method_createorupdate.go new file mode 100644 index 00000000000..0471e0e461f --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/productpolicy/method_createorupdate.go @@ -0,0 +1,85 @@ +package productpolicy + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PolicyContract +} + +type CreateOrUpdateOperationOptions struct { + IfMatch *string +} + +func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { + return CreateOrUpdateOperationOptions{} +} + +func (o CreateOrUpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o CreateOrUpdateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o CreateOrUpdateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// CreateOrUpdate ... +func (c ProductPolicyClient) CreateOrUpdate(ctx context.Context, id ProductId, input PolicyContract, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/policies/policy", id.ID()), + OptionsObject: options, + } + + 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/apimanagement/2022-08-01/productpolicy/method_createorupdate_autorest.go b/resource-manager/apimanagement/2022-08-01/productpolicy/method_createorupdate_autorest.go deleted file mode 100644 index 43f5c165d57..00000000000 --- a/resource-manager/apimanagement/2022-08-01/productpolicy/method_createorupdate_autorest.go +++ /dev/null @@ -1,99 +0,0 @@ -package productpolicy - -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 CreateOrUpdateOperationResponse struct { - HttpResponse *http.Response - Model *PolicyContract -} - -type CreateOrUpdateOperationOptions struct { - IfMatch *string -} - -func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { - return CreateOrUpdateOperationOptions{} -} - -func (o CreateOrUpdateOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o CreateOrUpdateOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// CreateOrUpdate ... -func (c ProductPolicyClient) CreateOrUpdate(ctx context.Context, id ProductId, input PolicyContract, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdate(ctx, id, input, options) - if err != nil { - err = autorest.NewErrorWithError(err, "productpolicy.ProductPolicyClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "productpolicy.ProductPolicyClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCreateOrUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "productpolicy.ProductPolicyClient", "CreateOrUpdate", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCreateOrUpdate prepares the CreateOrUpdate request. -func (c ProductPolicyClient) preparerForCreateOrUpdate(ctx context.Context, id ProductId, input PolicyContract, options CreateOrUpdateOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/policies/policy", 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 ProductPolicyClient) responderForCreateOrUpdate(resp *http.Response) (result CreateOrUpdateOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2022-08-01/productpolicy/method_delete.go b/resource-manager/apimanagement/2022-08-01/productpolicy/method_delete.go new file mode 100644 index 00000000000..09bc23bd22e --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/productpolicy/method_delete.go @@ -0,0 +1,76 @@ +package productpolicy + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +type DeleteOperationOptions struct { + IfMatch *string +} + +func DefaultDeleteOperationOptions() DeleteOperationOptions { + return DeleteOperationOptions{} +} + +func (o DeleteOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o DeleteOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o DeleteOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// Delete ... +func (c ProductPolicyClient) Delete(ctx context.Context, id ProductId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: fmt.Sprintf("%s/policies/policy", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2022-08-01/productpolicy/method_delete_autorest.go b/resource-manager/apimanagement/2022-08-01/productpolicy/method_delete_autorest.go deleted file mode 100644 index d18f700767f..00000000000 --- a/resource-manager/apimanagement/2022-08-01/productpolicy/method_delete_autorest.go +++ /dev/null @@ -1,96 +0,0 @@ -package productpolicy - -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 DeleteOperationResponse struct { - HttpResponse *http.Response -} - -type DeleteOperationOptions struct { - IfMatch *string -} - -func DefaultDeleteOperationOptions() DeleteOperationOptions { - return DeleteOperationOptions{} -} - -func (o DeleteOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o DeleteOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// Delete ... -func (c ProductPolicyClient) Delete(ctx context.Context, id ProductId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { - req, err := c.preparerForDelete(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "productpolicy.ProductPolicyClient", "Delete", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "productpolicy.ProductPolicyClient", "Delete", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForDelete(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "productpolicy.ProductPolicyClient", "Delete", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForDelete prepares the Delete request. -func (c ProductPolicyClient) preparerForDelete(ctx context.Context, id ProductId, options DeleteOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/policies/policy", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForDelete handles the response to the Delete request. The method always -// closes the http.Response Body. -func (c ProductPolicyClient) responderForDelete(resp *http.Response) (result DeleteOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2022-08-01/productpolicy/method_get.go b/resource-manager/apimanagement/2022-08-01/productpolicy/method_get.go new file mode 100644 index 00000000000..46284c64c32 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/productpolicy/method_get.go @@ -0,0 +1,80 @@ +package productpolicy + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PolicyContract +} + +type GetOperationOptions struct { + Format *PolicyExportFormat +} + +func DefaultGetOperationOptions() GetOperationOptions { + return GetOperationOptions{} +} + +func (o GetOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o GetOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o GetOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Format != nil { + out.Append("format", fmt.Sprintf("%v", *o.Format)) + } + return &out +} + +// Get ... +func (c ProductPolicyClient) Get(ctx context.Context, id ProductId, options GetOperationOptions) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/policies/policy", id.ID()), + OptionsObject: options, + } + + 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/apimanagement/2022-08-01/productpolicy/method_get_autorest.go b/resource-manager/apimanagement/2022-08-01/productpolicy/method_get_autorest.go deleted file mode 100644 index b2933e55f93..00000000000 --- a/resource-manager/apimanagement/2022-08-01/productpolicy/method_get_autorest.go +++ /dev/null @@ -1,98 +0,0 @@ -package productpolicy - -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 GetOperationResponse struct { - HttpResponse *http.Response - Model *PolicyContract -} - -type GetOperationOptions struct { - Format *PolicyExportFormat -} - -func DefaultGetOperationOptions() GetOperationOptions { - return GetOperationOptions{} -} - -func (o GetOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o GetOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Format != nil { - out["format"] = *o.Format - } - - return out -} - -// Get ... -func (c ProductPolicyClient) Get(ctx context.Context, id ProductId, options GetOperationOptions) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "productpolicy.ProductPolicyClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "productpolicy.ProductPolicyClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "productpolicy.ProductPolicyClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c ProductPolicyClient) preparerForGet(ctx context.Context, id ProductId, options GetOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/policies/policy", 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 ProductPolicyClient) 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/apimanagement/2022-08-01/productpolicy/method_getentitytag.go b/resource-manager/apimanagement/2022-08-01/productpolicy/method_getentitytag.go new file mode 100644 index 00000000000..3e3787982d6 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/productpolicy/method_getentitytag.go @@ -0,0 +1,47 @@ +package productpolicy + +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 GetEntityTagOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// GetEntityTag ... +func (c ProductPolicyClient) GetEntityTag(ctx context.Context, id ProductId) (result GetEntityTagOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodHead, + Path: fmt.Sprintf("%s/policies/policy", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2022-08-01/productpolicy/method_getentitytag_autorest.go b/resource-manager/apimanagement/2022-08-01/productpolicy/method_getentitytag_autorest.go deleted file mode 100644 index f446b88fb66..00000000000 --- a/resource-manager/apimanagement/2022-08-01/productpolicy/method_getentitytag_autorest.go +++ /dev/null @@ -1,67 +0,0 @@ -package productpolicy - -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 GetEntityTagOperationResponse struct { - HttpResponse *http.Response -} - -// GetEntityTag ... -func (c ProductPolicyClient) GetEntityTag(ctx context.Context, id ProductId) (result GetEntityTagOperationResponse, err error) { - req, err := c.preparerForGetEntityTag(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "productpolicy.ProductPolicyClient", "GetEntityTag", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "productpolicy.ProductPolicyClient", "GetEntityTag", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetEntityTag(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "productpolicy.ProductPolicyClient", "GetEntityTag", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetEntityTag prepares the GetEntityTag request. -func (c ProductPolicyClient) preparerForGetEntityTag(ctx context.Context, id ProductId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsHead(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/policies/policy", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetEntityTag handles the response to the GetEntityTag request. The method always -// closes the http.Response Body. -func (c ProductPolicyClient) responderForGetEntityTag(resp *http.Response) (result GetEntityTagOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2022-08-01/productpolicy/method_listbyproduct.go b/resource-manager/apimanagement/2022-08-01/productpolicy/method_listbyproduct.go new file mode 100644 index 00000000000..d9cbc9812e4 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/productpolicy/method_listbyproduct.go @@ -0,0 +1,52 @@ +package productpolicy + +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 ListByProductOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PolicyCollection +} + +// ListByProduct ... +func (c ProductPolicyClient) ListByProduct(ctx context.Context, id ProductId) (result ListByProductOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/policies", 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/apimanagement/2022-08-01/productpolicy/method_listbyproduct_autorest.go b/resource-manager/apimanagement/2022-08-01/productpolicy/method_listbyproduct_autorest.go deleted file mode 100644 index 40fab3bcf62..00000000000 --- a/resource-manager/apimanagement/2022-08-01/productpolicy/method_listbyproduct_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package productpolicy - -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 ListByProductOperationResponse struct { - HttpResponse *http.Response - Model *PolicyCollection -} - -// ListByProduct ... -func (c ProductPolicyClient) ListByProduct(ctx context.Context, id ProductId) (result ListByProductOperationResponse, err error) { - req, err := c.preparerForListByProduct(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "productpolicy.ProductPolicyClient", "ListByProduct", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "productpolicy.ProductPolicyClient", "ListByProduct", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByProduct(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "productpolicy.ProductPolicyClient", "ListByProduct", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForListByProduct prepares the ListByProduct request. -func (c ProductPolicyClient) preparerForListByProduct(ctx context.Context, id ProductId) (*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/policies", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListByProduct handles the response to the ListByProduct request. The method always -// closes the http.Response Body. -func (c ProductPolicyClient) responderForListByProduct(resp *http.Response) (result ListByProductOperationResponse, 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/apimanagement/2022-08-01/productsbytag/client.go b/resource-manager/apimanagement/2022-08-01/productsbytag/client.go index 819f4c151ff..88609064dad 100644 --- a/resource-manager/apimanagement/2022-08-01/productsbytag/client.go +++ b/resource-manager/apimanagement/2022-08-01/productsbytag/client.go @@ -1,18 +1,26 @@ package productsbytag -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 ProductsByTagClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewProductsByTagClientWithBaseURI(endpoint string) ProductsByTagClient { - return ProductsByTagClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewProductsByTagClientWithBaseURI(api environments.Api) (*ProductsByTagClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "productsbytag", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ProductsByTagClient: %+v", err) } + + return &ProductsByTagClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2022-08-01/productsbytag/constants.go b/resource-manager/apimanagement/2022-08-01/productsbytag/constants.go index a3a2af687c4..6380c578cd4 100644 --- a/resource-manager/apimanagement/2022-08-01/productsbytag/constants.go +++ b/resource-manager/apimanagement/2022-08-01/productsbytag/constants.go @@ -1,6 +1,10 @@ package productsbytag -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 PossibleValuesForApiType() []string { } } +func (s *ApiType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseApiType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseApiType(input string) (*ApiType, error) { vals := map[string]ApiType{ "graphql": ApiTypeGraphql, @@ -53,6 +70,19 @@ func PossibleValuesForBearerTokenSendingMethods() []string { } } +func (s *BearerTokenSendingMethods) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseBearerTokenSendingMethods(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseBearerTokenSendingMethods(input string) (*BearerTokenSendingMethods, error) { vals := map[string]BearerTokenSendingMethods{ "authorizationheader": BearerTokenSendingMethodsAuthorizationHeader, @@ -81,6 +111,19 @@ func PossibleValuesForProductState() []string { } } +func (s *ProductState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProductState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseProductState(input string) (*ProductState, error) { vals := map[string]ProductState{ "notpublished": ProductStateNotPublished, @@ -113,6 +156,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{ "http": ProtocolHTTP, diff --git a/resource-manager/apimanagement/2022-08-01/productsbytag/method_productlistbytags.go b/resource-manager/apimanagement/2022-08-01/productsbytag/method_productlistbytags.go new file mode 100644 index 00000000000..bd145c12a02 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/productsbytag/method_productlistbytags.go @@ -0,0 +1,129 @@ +package productsbytag + +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 ProductListByTagsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]TagResourceContract +} + +type ProductListByTagsCompleteResult struct { + Items []TagResourceContract +} + +type ProductListByTagsOperationOptions struct { + Filter *string + IncludeNotTaggedProducts *bool + Skip *int64 + Top *int64 +} + +func DefaultProductListByTagsOperationOptions() ProductListByTagsOperationOptions { + return ProductListByTagsOperationOptions{} +} + +func (o ProductListByTagsOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ProductListByTagsOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ProductListByTagsOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.IncludeNotTaggedProducts != nil { + out.Append("includeNotTaggedProducts", fmt.Sprintf("%v", *o.IncludeNotTaggedProducts)) + } + if o.Skip != nil { + out.Append("$skip", fmt.Sprintf("%v", *o.Skip)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +// ProductListByTags ... +func (c ProductsByTagClient) ProductListByTags(ctx context.Context, id ServiceId, options ProductListByTagsOperationOptions) (result ProductListByTagsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/productsByTags", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]TagResourceContract `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ProductListByTagsComplete retrieves all the results into a single object +func (c ProductsByTagClient) ProductListByTagsComplete(ctx context.Context, id ServiceId, options ProductListByTagsOperationOptions) (ProductListByTagsCompleteResult, error) { + return c.ProductListByTagsCompleteMatchingPredicate(ctx, id, options, TagResourceContractOperationPredicate{}) +} + +// ProductListByTagsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ProductsByTagClient) ProductListByTagsCompleteMatchingPredicate(ctx context.Context, id ServiceId, options ProductListByTagsOperationOptions, predicate TagResourceContractOperationPredicate) (result ProductListByTagsCompleteResult, err error) { + items := make([]TagResourceContract, 0) + + resp, err := c.ProductListByTags(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ProductListByTagsCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/apimanagement/2022-08-01/productsbytag/method_productlistbytags_autorest.go b/resource-manager/apimanagement/2022-08-01/productsbytag/method_productlistbytags_autorest.go deleted file mode 100644 index 2cff77a5a10..00000000000 --- a/resource-manager/apimanagement/2022-08-01/productsbytag/method_productlistbytags_autorest.go +++ /dev/null @@ -1,230 +0,0 @@ -package productsbytag - -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 ProductListByTagsOperationResponse struct { - HttpResponse *http.Response - Model *[]TagResourceContract - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ProductListByTagsOperationResponse, error) -} - -type ProductListByTagsCompleteResult struct { - Items []TagResourceContract -} - -func (r ProductListByTagsOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ProductListByTagsOperationResponse) LoadMore(ctx context.Context) (resp ProductListByTagsOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -type ProductListByTagsOperationOptions struct { - Filter *string - IncludeNotTaggedProducts *bool - Skip *int64 - Top *int64 -} - -func DefaultProductListByTagsOperationOptions() ProductListByTagsOperationOptions { - return ProductListByTagsOperationOptions{} -} - -func (o ProductListByTagsOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o ProductListByTagsOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Filter != nil { - out["$filter"] = *o.Filter - } - - if o.IncludeNotTaggedProducts != nil { - out["includeNotTaggedProducts"] = *o.IncludeNotTaggedProducts - } - - if o.Skip != nil { - out["$skip"] = *o.Skip - } - - if o.Top != nil { - out["$top"] = *o.Top - } - - return out -} - -// ProductListByTags ... -func (c ProductsByTagClient) ProductListByTags(ctx context.Context, id ServiceId, options ProductListByTagsOperationOptions) (resp ProductListByTagsOperationResponse, err error) { - req, err := c.preparerForProductListByTags(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "productsbytag.ProductsByTagClient", "ProductListByTags", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "productsbytag.ProductsByTagClient", "ProductListByTags", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForProductListByTags(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "productsbytag.ProductsByTagClient", "ProductListByTags", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForProductListByTags prepares the ProductListByTags request. -func (c ProductsByTagClient) preparerForProductListByTags(ctx context.Context, id ServiceId, options ProductListByTagsOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/productsByTags", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForProductListByTagsWithNextLink prepares the ProductListByTags request with the given nextLink token. -func (c ProductsByTagClient) preparerForProductListByTagsWithNextLink(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)) -} - -// responderForProductListByTags handles the response to the ProductListByTags request. The method always -// closes the http.Response Body. -func (c ProductsByTagClient) responderForProductListByTags(resp *http.Response) (result ProductListByTagsOperationResponse, err error) { - type page struct { - Values []TagResourceContract `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 ProductListByTagsOperationResponse, err error) { - req, err := c.preparerForProductListByTagsWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "productsbytag.ProductsByTagClient", "ProductListByTags", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "productsbytag.ProductsByTagClient", "ProductListByTags", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForProductListByTags(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "productsbytag.ProductsByTagClient", "ProductListByTags", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ProductListByTagsComplete retrieves all of the results into a single object -func (c ProductsByTagClient) ProductListByTagsComplete(ctx context.Context, id ServiceId, options ProductListByTagsOperationOptions) (ProductListByTagsCompleteResult, error) { - return c.ProductListByTagsCompleteMatchingPredicate(ctx, id, options, TagResourceContractOperationPredicate{}) -} - -// ProductListByTagsCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c ProductsByTagClient) ProductListByTagsCompleteMatchingPredicate(ctx context.Context, id ServiceId, options ProductListByTagsOperationOptions, predicate TagResourceContractOperationPredicate) (resp ProductListByTagsCompleteResult, err error) { - items := make([]TagResourceContract, 0) - - page, err := c.ProductListByTags(ctx, id, options) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ProductListByTagsCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/apimanagement/2022-08-01/productsubscription/client.go b/resource-manager/apimanagement/2022-08-01/productsubscription/client.go index e6fc998ab6f..d8a5835a232 100644 --- a/resource-manager/apimanagement/2022-08-01/productsubscription/client.go +++ b/resource-manager/apimanagement/2022-08-01/productsubscription/client.go @@ -1,18 +1,26 @@ package productsubscription -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 ProductSubscriptionClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewProductSubscriptionClientWithBaseURI(endpoint string) ProductSubscriptionClient { - return ProductSubscriptionClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewProductSubscriptionClientWithBaseURI(api environments.Api) (*ProductSubscriptionClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "productsubscription", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ProductSubscriptionClient: %+v", err) } + + return &ProductSubscriptionClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2022-08-01/productsubscription/constants.go b/resource-manager/apimanagement/2022-08-01/productsubscription/constants.go index 3d9bc9cb116..b701ce04fea 100644 --- a/resource-manager/apimanagement/2022-08-01/productsubscription/constants.go +++ b/resource-manager/apimanagement/2022-08-01/productsubscription/constants.go @@ -1,6 +1,10 @@ package productsubscription -import "strings" +import ( + "encoding/json" + "fmt" + "strings" +) // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See NOTICE.txt in the project root for license information. @@ -27,6 +31,19 @@ func PossibleValuesForSubscriptionState() []string { } } +func (s *SubscriptionState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSubscriptionState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseSubscriptionState(input string) (*SubscriptionState, error) { vals := map[string]SubscriptionState{ "active": SubscriptionStateActive, diff --git a/resource-manager/apimanagement/2022-08-01/productsubscription/method_list.go b/resource-manager/apimanagement/2022-08-01/productsubscription/method_list.go new file mode 100644 index 00000000000..6e4d8a7a32c --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/productsubscription/method_list.go @@ -0,0 +1,125 @@ +package productsubscription + +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 *[]SubscriptionContract +} + +type ListCompleteResult struct { + Items []SubscriptionContract +} + +type ListOperationOptions struct { + Filter *string + Skip *int64 + Top *int64 +} + +func DefaultListOperationOptions() ListOperationOptions { + return ListOperationOptions{} +} + +func (o ListOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.Skip != nil { + out.Append("$skip", fmt.Sprintf("%v", *o.Skip)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +// List ... +func (c ProductSubscriptionClient) List(ctx context.Context, id ProductId, options ListOperationOptions) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/subscriptions", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]SubscriptionContract `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 ProductSubscriptionClient) ListComplete(ctx context.Context, id ProductId, options ListOperationOptions) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, options, SubscriptionContractOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ProductSubscriptionClient) ListCompleteMatchingPredicate(ctx context.Context, id ProductId, options ListOperationOptions, predicate SubscriptionContractOperationPredicate) (result ListCompleteResult, err error) { + items := make([]SubscriptionContract, 0) + + resp, err := c.List(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/apimanagement/2022-08-01/productsubscription/method_list_autorest.go b/resource-manager/apimanagement/2022-08-01/productsubscription/method_list_autorest.go deleted file mode 100644 index c90464fedfa..00000000000 --- a/resource-manager/apimanagement/2022-08-01/productsubscription/method_list_autorest.go +++ /dev/null @@ -1,225 +0,0 @@ -package productsubscription - -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 *[]SubscriptionContract - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListOperationResponse, error) -} - -type ListCompleteResult struct { - Items []SubscriptionContract -} - -func (r ListOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListOperationResponse) LoadMore(ctx context.Context) (resp ListOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -type ListOperationOptions struct { - Filter *string - Skip *int64 - Top *int64 -} - -func DefaultListOperationOptions() ListOperationOptions { - return ListOperationOptions{} -} - -func (o ListOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o ListOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Filter != nil { - out["$filter"] = *o.Filter - } - - if o.Skip != nil { - out["$skip"] = *o.Skip - } - - if o.Top != nil { - out["$top"] = *o.Top - } - - return out -} - -// List ... -func (c ProductSubscriptionClient) List(ctx context.Context, id ProductId, options ListOperationOptions) (resp ListOperationResponse, err error) { - req, err := c.preparerForList(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "productsubscription.ProductSubscriptionClient", "List", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "productsubscription.ProductSubscriptionClient", "List", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForList(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "productsubscription.ProductSubscriptionClient", "List", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForList prepares the List request. -func (c ProductSubscriptionClient) preparerForList(ctx context.Context, id ProductId, options ListOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/subscriptions", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListWithNextLink prepares the List request with the given nextLink token. -func (c ProductSubscriptionClient) 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 ProductSubscriptionClient) responderForList(resp *http.Response) (result ListOperationResponse, err error) { - type page struct { - Values []SubscriptionContract `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, "productsubscription.ProductSubscriptionClient", "List", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "productsubscription.ProductSubscriptionClient", "List", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForList(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "productsubscription.ProductSubscriptionClient", "List", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListComplete retrieves all of the results into a single object -func (c ProductSubscriptionClient) ListComplete(ctx context.Context, id ProductId, options ListOperationOptions) (ListCompleteResult, error) { - return c.ListCompleteMatchingPredicate(ctx, id, options, SubscriptionContractOperationPredicate{}) -} - -// ListCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c ProductSubscriptionClient) ListCompleteMatchingPredicate(ctx context.Context, id ProductId, options ListOperationOptions, predicate SubscriptionContractOperationPredicate) (resp ListCompleteResult, err error) { - items := make([]SubscriptionContract, 0) - - page, err := c.List(ctx, id, options) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/apimanagement/2022-08-01/producttag/client.go b/resource-manager/apimanagement/2022-08-01/producttag/client.go index 852ad05f1e6..20b63f571e6 100644 --- a/resource-manager/apimanagement/2022-08-01/producttag/client.go +++ b/resource-manager/apimanagement/2022-08-01/producttag/client.go @@ -1,18 +1,26 @@ package producttag -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 ProductTagClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewProductTagClientWithBaseURI(endpoint string) ProductTagClient { - return ProductTagClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewProductTagClientWithBaseURI(api environments.Api) (*ProductTagClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "producttag", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ProductTagClient: %+v", err) } + + return &ProductTagClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2022-08-01/producttag/method_tagassigntoproduct.go b/resource-manager/apimanagement/2022-08-01/producttag/method_tagassigntoproduct.go new file mode 100644 index 00000000000..55885dbd935 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/producttag/method_tagassigntoproduct.go @@ -0,0 +1,52 @@ +package producttag + +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 TagAssignToProductOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *TagContract +} + +// TagAssignToProduct ... +func (c ProductTagClient) TagAssignToProduct(ctx context.Context, id ProductTagId) (result TagAssignToProductOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + 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/apimanagement/2022-08-01/producttag/method_tagassigntoproduct_autorest.go b/resource-manager/apimanagement/2022-08-01/producttag/method_tagassigntoproduct_autorest.go deleted file mode 100644 index 6a0b20cfc9a..00000000000 --- a/resource-manager/apimanagement/2022-08-01/producttag/method_tagassigntoproduct_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package producttag - -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 TagAssignToProductOperationResponse struct { - HttpResponse *http.Response - Model *TagContract -} - -// TagAssignToProduct ... -func (c ProductTagClient) TagAssignToProduct(ctx context.Context, id ProductTagId) (result TagAssignToProductOperationResponse, err error) { - req, err := c.preparerForTagAssignToProduct(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "producttag.ProductTagClient", "TagAssignToProduct", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "producttag.ProductTagClient", "TagAssignToProduct", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForTagAssignToProduct(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "producttag.ProductTagClient", "TagAssignToProduct", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForTagAssignToProduct prepares the TagAssignToProduct request. -func (c ProductTagClient) preparerForTagAssignToProduct(ctx context.Context, id ProductTagId) (*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.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForTagAssignToProduct handles the response to the TagAssignToProduct request. The method always -// closes the http.Response Body. -func (c ProductTagClient) responderForTagAssignToProduct(resp *http.Response) (result TagAssignToProductOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2022-08-01/producttag/method_tagdetachfromproduct.go b/resource-manager/apimanagement/2022-08-01/producttag/method_tagdetachfromproduct.go new file mode 100644 index 00000000000..9564ceb67e1 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/producttag/method_tagdetachfromproduct.go @@ -0,0 +1,47 @@ +package producttag + +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 TagDetachFromProductOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// TagDetachFromProduct ... +func (c ProductTagClient) TagDetachFromProduct(ctx context.Context, id ProductTagId) (result TagDetachFromProductOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2022-08-01/producttag/method_tagdetachfromproduct_autorest.go b/resource-manager/apimanagement/2022-08-01/producttag/method_tagdetachfromproduct_autorest.go deleted file mode 100644 index de37a803293..00000000000 --- a/resource-manager/apimanagement/2022-08-01/producttag/method_tagdetachfromproduct_autorest.go +++ /dev/null @@ -1,66 +0,0 @@ -package producttag - -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 TagDetachFromProductOperationResponse struct { - HttpResponse *http.Response -} - -// TagDetachFromProduct ... -func (c ProductTagClient) TagDetachFromProduct(ctx context.Context, id ProductTagId) (result TagDetachFromProductOperationResponse, err error) { - req, err := c.preparerForTagDetachFromProduct(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "producttag.ProductTagClient", "TagDetachFromProduct", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "producttag.ProductTagClient", "TagDetachFromProduct", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForTagDetachFromProduct(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "producttag.ProductTagClient", "TagDetachFromProduct", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForTagDetachFromProduct prepares the TagDetachFromProduct request. -func (c ProductTagClient) preparerForTagDetachFromProduct(ctx context.Context, id ProductTagId) (*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)) -} - -// responderForTagDetachFromProduct handles the response to the TagDetachFromProduct request. The method always -// closes the http.Response Body. -func (c ProductTagClient) responderForTagDetachFromProduct(resp *http.Response) (result TagDetachFromProductOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2022-08-01/producttag/method_taggetbyproduct.go b/resource-manager/apimanagement/2022-08-01/producttag/method_taggetbyproduct.go new file mode 100644 index 00000000000..413a4b52b72 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/producttag/method_taggetbyproduct.go @@ -0,0 +1,51 @@ +package producttag + +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 TagGetByProductOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *TagContract +} + +// TagGetByProduct ... +func (c ProductTagClient) TagGetByProduct(ctx context.Context, id ProductTagId) (result TagGetByProductOperationResponse, 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/apimanagement/2022-08-01/producttag/method_taggetbyproduct_autorest.go b/resource-manager/apimanagement/2022-08-01/producttag/method_taggetbyproduct_autorest.go deleted file mode 100644 index beb3693330c..00000000000 --- a/resource-manager/apimanagement/2022-08-01/producttag/method_taggetbyproduct_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package producttag - -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 TagGetByProductOperationResponse struct { - HttpResponse *http.Response - Model *TagContract -} - -// TagGetByProduct ... -func (c ProductTagClient) TagGetByProduct(ctx context.Context, id ProductTagId) (result TagGetByProductOperationResponse, err error) { - req, err := c.preparerForTagGetByProduct(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "producttag.ProductTagClient", "TagGetByProduct", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "producttag.ProductTagClient", "TagGetByProduct", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForTagGetByProduct(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "producttag.ProductTagClient", "TagGetByProduct", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForTagGetByProduct prepares the TagGetByProduct request. -func (c ProductTagClient) preparerForTagGetByProduct(ctx context.Context, id ProductTagId) (*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)) -} - -// responderForTagGetByProduct handles the response to the TagGetByProduct request. The method always -// closes the http.Response Body. -func (c ProductTagClient) responderForTagGetByProduct(resp *http.Response) (result TagGetByProductOperationResponse, 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/apimanagement/2022-08-01/producttag/method_taggetentitystatebyproduct.go b/resource-manager/apimanagement/2022-08-01/producttag/method_taggetentitystatebyproduct.go new file mode 100644 index 00000000000..8f023009406 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/producttag/method_taggetentitystatebyproduct.go @@ -0,0 +1,46 @@ +package producttag + +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 TagGetEntityStateByProductOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// TagGetEntityStateByProduct ... +func (c ProductTagClient) TagGetEntityStateByProduct(ctx context.Context, id ProductTagId) (result TagGetEntityStateByProductOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodHead, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2022-08-01/producttag/method_taggetentitystatebyproduct_autorest.go b/resource-manager/apimanagement/2022-08-01/producttag/method_taggetentitystatebyproduct_autorest.go deleted file mode 100644 index ba4e65f8cd1..00000000000 --- a/resource-manager/apimanagement/2022-08-01/producttag/method_taggetentitystatebyproduct_autorest.go +++ /dev/null @@ -1,66 +0,0 @@ -package producttag - -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 TagGetEntityStateByProductOperationResponse struct { - HttpResponse *http.Response -} - -// TagGetEntityStateByProduct ... -func (c ProductTagClient) TagGetEntityStateByProduct(ctx context.Context, id ProductTagId) (result TagGetEntityStateByProductOperationResponse, err error) { - req, err := c.preparerForTagGetEntityStateByProduct(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "producttag.ProductTagClient", "TagGetEntityStateByProduct", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "producttag.ProductTagClient", "TagGetEntityStateByProduct", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForTagGetEntityStateByProduct(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "producttag.ProductTagClient", "TagGetEntityStateByProduct", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForTagGetEntityStateByProduct prepares the TagGetEntityStateByProduct request. -func (c ProductTagClient) preparerForTagGetEntityStateByProduct(ctx context.Context, id ProductTagId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsHead(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForTagGetEntityStateByProduct handles the response to the TagGetEntityStateByProduct request. The method always -// closes the http.Response Body. -func (c ProductTagClient) responderForTagGetEntityStateByProduct(resp *http.Response) (result TagGetEntityStateByProductOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2022-08-01/producttag/method_taglistbyproduct.go b/resource-manager/apimanagement/2022-08-01/producttag/method_taglistbyproduct.go new file mode 100644 index 00000000000..0b73c472a25 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/producttag/method_taglistbyproduct.go @@ -0,0 +1,125 @@ +package producttag + +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 TagListByProductOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]TagContract +} + +type TagListByProductCompleteResult struct { + Items []TagContract +} + +type TagListByProductOperationOptions struct { + Filter *string + Skip *int64 + Top *int64 +} + +func DefaultTagListByProductOperationOptions() TagListByProductOperationOptions { + return TagListByProductOperationOptions{} +} + +func (o TagListByProductOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o TagListByProductOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o TagListByProductOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.Skip != nil { + out.Append("$skip", fmt.Sprintf("%v", *o.Skip)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +// TagListByProduct ... +func (c ProductTagClient) TagListByProduct(ctx context.Context, id ProductId, options TagListByProductOperationOptions) (result TagListByProductOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/tags", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]TagContract `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// TagListByProductComplete retrieves all the results into a single object +func (c ProductTagClient) TagListByProductComplete(ctx context.Context, id ProductId, options TagListByProductOperationOptions) (TagListByProductCompleteResult, error) { + return c.TagListByProductCompleteMatchingPredicate(ctx, id, options, TagContractOperationPredicate{}) +} + +// TagListByProductCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ProductTagClient) TagListByProductCompleteMatchingPredicate(ctx context.Context, id ProductId, options TagListByProductOperationOptions, predicate TagContractOperationPredicate) (result TagListByProductCompleteResult, err error) { + items := make([]TagContract, 0) + + resp, err := c.TagListByProduct(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = TagListByProductCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/apimanagement/2022-08-01/producttag/method_taglistbyproduct_autorest.go b/resource-manager/apimanagement/2022-08-01/producttag/method_taglistbyproduct_autorest.go deleted file mode 100644 index f0717ee0f77..00000000000 --- a/resource-manager/apimanagement/2022-08-01/producttag/method_taglistbyproduct_autorest.go +++ /dev/null @@ -1,225 +0,0 @@ -package producttag - -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 TagListByProductOperationResponse struct { - HttpResponse *http.Response - Model *[]TagContract - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (TagListByProductOperationResponse, error) -} - -type TagListByProductCompleteResult struct { - Items []TagContract -} - -func (r TagListByProductOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r TagListByProductOperationResponse) LoadMore(ctx context.Context) (resp TagListByProductOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -type TagListByProductOperationOptions struct { - Filter *string - Skip *int64 - Top *int64 -} - -func DefaultTagListByProductOperationOptions() TagListByProductOperationOptions { - return TagListByProductOperationOptions{} -} - -func (o TagListByProductOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o TagListByProductOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Filter != nil { - out["$filter"] = *o.Filter - } - - if o.Skip != nil { - out["$skip"] = *o.Skip - } - - if o.Top != nil { - out["$top"] = *o.Top - } - - return out -} - -// TagListByProduct ... -func (c ProductTagClient) TagListByProduct(ctx context.Context, id ProductId, options TagListByProductOperationOptions) (resp TagListByProductOperationResponse, err error) { - req, err := c.preparerForTagListByProduct(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "producttag.ProductTagClient", "TagListByProduct", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "producttag.ProductTagClient", "TagListByProduct", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForTagListByProduct(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "producttag.ProductTagClient", "TagListByProduct", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForTagListByProduct prepares the TagListByProduct request. -func (c ProductTagClient) preparerForTagListByProduct(ctx context.Context, id ProductId, options TagListByProductOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/tags", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForTagListByProductWithNextLink prepares the TagListByProduct request with the given nextLink token. -func (c ProductTagClient) preparerForTagListByProductWithNextLink(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)) -} - -// responderForTagListByProduct handles the response to the TagListByProduct request. The method always -// closes the http.Response Body. -func (c ProductTagClient) responderForTagListByProduct(resp *http.Response) (result TagListByProductOperationResponse, err error) { - type page struct { - Values []TagContract `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 TagListByProductOperationResponse, err error) { - req, err := c.preparerForTagListByProductWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "producttag.ProductTagClient", "TagListByProduct", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "producttag.ProductTagClient", "TagListByProduct", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForTagListByProduct(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "producttag.ProductTagClient", "TagListByProduct", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// TagListByProductComplete retrieves all of the results into a single object -func (c ProductTagClient) TagListByProductComplete(ctx context.Context, id ProductId, options TagListByProductOperationOptions) (TagListByProductCompleteResult, error) { - return c.TagListByProductCompleteMatchingPredicate(ctx, id, options, TagContractOperationPredicate{}) -} - -// TagListByProductCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c ProductTagClient) TagListByProductCompleteMatchingPredicate(ctx context.Context, id ProductId, options TagListByProductOperationOptions, predicate TagContractOperationPredicate) (resp TagListByProductCompleteResult, err error) { - items := make([]TagContract, 0) - - page, err := c.TagListByProduct(ctx, id, options) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := TagListByProductCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/apimanagement/2022-08-01/productwiki/client.go b/resource-manager/apimanagement/2022-08-01/productwiki/client.go index 675bec67e09..3f477fcd5b2 100644 --- a/resource-manager/apimanagement/2022-08-01/productwiki/client.go +++ b/resource-manager/apimanagement/2022-08-01/productwiki/client.go @@ -1,18 +1,26 @@ package productwiki -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 ProductWikiClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewProductWikiClientWithBaseURI(endpoint string) ProductWikiClient { - return ProductWikiClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewProductWikiClientWithBaseURI(api environments.Api) (*ProductWikiClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "productwiki", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ProductWikiClient: %+v", err) } + + return &ProductWikiClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2022-08-01/productwiki/method_createorupdate.go b/resource-manager/apimanagement/2022-08-01/productwiki/method_createorupdate.go new file mode 100644 index 00000000000..18ccc4803c6 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/productwiki/method_createorupdate.go @@ -0,0 +1,85 @@ +package productwiki + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *WikiContract +} + +type CreateOrUpdateOperationOptions struct { + IfMatch *string +} + +func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { + return CreateOrUpdateOperationOptions{} +} + +func (o CreateOrUpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o CreateOrUpdateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o CreateOrUpdateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// CreateOrUpdate ... +func (c ProductWikiClient) CreateOrUpdate(ctx context.Context, id ProductId, input WikiContract, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/wikis/default", id.ID()), + OptionsObject: options, + } + + 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/apimanagement/2022-08-01/productwiki/method_createorupdate_autorest.go b/resource-manager/apimanagement/2022-08-01/productwiki/method_createorupdate_autorest.go deleted file mode 100644 index 1ae89a8a3ec..00000000000 --- a/resource-manager/apimanagement/2022-08-01/productwiki/method_createorupdate_autorest.go +++ /dev/null @@ -1,99 +0,0 @@ -package productwiki - -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 CreateOrUpdateOperationResponse struct { - HttpResponse *http.Response - Model *WikiContract -} - -type CreateOrUpdateOperationOptions struct { - IfMatch *string -} - -func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { - return CreateOrUpdateOperationOptions{} -} - -func (o CreateOrUpdateOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o CreateOrUpdateOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// CreateOrUpdate ... -func (c ProductWikiClient) CreateOrUpdate(ctx context.Context, id ProductId, input WikiContract, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdate(ctx, id, input, options) - if err != nil { - err = autorest.NewErrorWithError(err, "productwiki.ProductWikiClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "productwiki.ProductWikiClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCreateOrUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "productwiki.ProductWikiClient", "CreateOrUpdate", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCreateOrUpdate prepares the CreateOrUpdate request. -func (c ProductWikiClient) preparerForCreateOrUpdate(ctx context.Context, id ProductId, input WikiContract, options CreateOrUpdateOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/wikis/default", 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 ProductWikiClient) responderForCreateOrUpdate(resp *http.Response) (result CreateOrUpdateOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2022-08-01/productwiki/method_delete.go b/resource-manager/apimanagement/2022-08-01/productwiki/method_delete.go new file mode 100644 index 00000000000..f2b6e116ed7 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/productwiki/method_delete.go @@ -0,0 +1,76 @@ +package productwiki + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +type DeleteOperationOptions struct { + IfMatch *string +} + +func DefaultDeleteOperationOptions() DeleteOperationOptions { + return DeleteOperationOptions{} +} + +func (o DeleteOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o DeleteOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o DeleteOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// Delete ... +func (c ProductWikiClient) Delete(ctx context.Context, id ProductId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: fmt.Sprintf("%s/wikis/default", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2022-08-01/productwiki/method_delete_autorest.go b/resource-manager/apimanagement/2022-08-01/productwiki/method_delete_autorest.go deleted file mode 100644 index 7a6351db182..00000000000 --- a/resource-manager/apimanagement/2022-08-01/productwiki/method_delete_autorest.go +++ /dev/null @@ -1,96 +0,0 @@ -package productwiki - -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 DeleteOperationResponse struct { - HttpResponse *http.Response -} - -type DeleteOperationOptions struct { - IfMatch *string -} - -func DefaultDeleteOperationOptions() DeleteOperationOptions { - return DeleteOperationOptions{} -} - -func (o DeleteOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o DeleteOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// Delete ... -func (c ProductWikiClient) Delete(ctx context.Context, id ProductId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { - req, err := c.preparerForDelete(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "productwiki.ProductWikiClient", "Delete", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "productwiki.ProductWikiClient", "Delete", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForDelete(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "productwiki.ProductWikiClient", "Delete", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForDelete prepares the Delete request. -func (c ProductWikiClient) preparerForDelete(ctx context.Context, id ProductId, options DeleteOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/wikis/default", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForDelete handles the response to the Delete request. The method always -// closes the http.Response Body. -func (c ProductWikiClient) responderForDelete(resp *http.Response) (result DeleteOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2022-08-01/productwiki/method_get.go b/resource-manager/apimanagement/2022-08-01/productwiki/method_get.go new file mode 100644 index 00000000000..3caa860baa9 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/productwiki/method_get.go @@ -0,0 +1,52 @@ +package productwiki + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *WikiContract +} + +// Get ... +func (c ProductWikiClient) Get(ctx context.Context, id ProductId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/wikis/default", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + if err = resp.Unmarshal(&result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2022-08-01/productwiki/method_get_autorest.go b/resource-manager/apimanagement/2022-08-01/productwiki/method_get_autorest.go deleted file mode 100644 index 2845aa8b36a..00000000000 --- a/resource-manager/apimanagement/2022-08-01/productwiki/method_get_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package productwiki - -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 GetOperationResponse struct { - HttpResponse *http.Response - Model *WikiContract -} - -// Get ... -func (c ProductWikiClient) Get(ctx context.Context, id ProductId) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "productwiki.ProductWikiClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "productwiki.ProductWikiClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "productwiki.ProductWikiClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c ProductWikiClient) preparerForGet(ctx context.Context, id ProductId) (*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/wikis/default", 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 ProductWikiClient) 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/apimanagement/2022-08-01/productwiki/method_getentitytag.go b/resource-manager/apimanagement/2022-08-01/productwiki/method_getentitytag.go new file mode 100644 index 00000000000..ddec183a011 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/productwiki/method_getentitytag.go @@ -0,0 +1,47 @@ +package productwiki + +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 GetEntityTagOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// GetEntityTag ... +func (c ProductWikiClient) GetEntityTag(ctx context.Context, id ProductId) (result GetEntityTagOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodHead, + Path: fmt.Sprintf("%s/wikis/default", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2022-08-01/productwiki/method_getentitytag_autorest.go b/resource-manager/apimanagement/2022-08-01/productwiki/method_getentitytag_autorest.go deleted file mode 100644 index b09360c8742..00000000000 --- a/resource-manager/apimanagement/2022-08-01/productwiki/method_getentitytag_autorest.go +++ /dev/null @@ -1,67 +0,0 @@ -package productwiki - -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 GetEntityTagOperationResponse struct { - HttpResponse *http.Response -} - -// GetEntityTag ... -func (c ProductWikiClient) GetEntityTag(ctx context.Context, id ProductId) (result GetEntityTagOperationResponse, err error) { - req, err := c.preparerForGetEntityTag(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "productwiki.ProductWikiClient", "GetEntityTag", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "productwiki.ProductWikiClient", "GetEntityTag", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetEntityTag(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "productwiki.ProductWikiClient", "GetEntityTag", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetEntityTag prepares the GetEntityTag request. -func (c ProductWikiClient) preparerForGetEntityTag(ctx context.Context, id ProductId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsHead(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/wikis/default", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetEntityTag handles the response to the GetEntityTag request. The method always -// closes the http.Response Body. -func (c ProductWikiClient) responderForGetEntityTag(resp *http.Response) (result GetEntityTagOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2022-08-01/productwiki/method_list.go b/resource-manager/apimanagement/2022-08-01/productwiki/method_list.go new file mode 100644 index 00000000000..d5eef04fbff --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/productwiki/method_list.go @@ -0,0 +1,125 @@ +package productwiki + +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 *[]WikiContract +} + +type ListCompleteResult struct { + Items []WikiContract +} + +type ListOperationOptions struct { + Filter *string + Skip *int64 + Top *int64 +} + +func DefaultListOperationOptions() ListOperationOptions { + return ListOperationOptions{} +} + +func (o ListOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.Skip != nil { + out.Append("$skip", fmt.Sprintf("%v", *o.Skip)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +// List ... +func (c ProductWikiClient) List(ctx context.Context, id ProductId, options ListOperationOptions) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/wikis", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]WikiContract `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 ProductWikiClient) ListComplete(ctx context.Context, id ProductId, options ListOperationOptions) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, options, WikiContractOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ProductWikiClient) ListCompleteMatchingPredicate(ctx context.Context, id ProductId, options ListOperationOptions, predicate WikiContractOperationPredicate) (result ListCompleteResult, err error) { + items := make([]WikiContract, 0) + + resp, err := c.List(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/apimanagement/2022-08-01/productwiki/method_list_autorest.go b/resource-manager/apimanagement/2022-08-01/productwiki/method_list_autorest.go deleted file mode 100644 index 3bbef9a5aa7..00000000000 --- a/resource-manager/apimanagement/2022-08-01/productwiki/method_list_autorest.go +++ /dev/null @@ -1,225 +0,0 @@ -package productwiki - -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 *[]WikiContract - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListOperationResponse, error) -} - -type ListCompleteResult struct { - Items []WikiContract -} - -func (r ListOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListOperationResponse) LoadMore(ctx context.Context) (resp ListOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -type ListOperationOptions struct { - Filter *string - Skip *int64 - Top *int64 -} - -func DefaultListOperationOptions() ListOperationOptions { - return ListOperationOptions{} -} - -func (o ListOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o ListOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Filter != nil { - out["$filter"] = *o.Filter - } - - if o.Skip != nil { - out["$skip"] = *o.Skip - } - - if o.Top != nil { - out["$top"] = *o.Top - } - - return out -} - -// List ... -func (c ProductWikiClient) List(ctx context.Context, id ProductId, options ListOperationOptions) (resp ListOperationResponse, err error) { - req, err := c.preparerForList(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "productwiki.ProductWikiClient", "List", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "productwiki.ProductWikiClient", "List", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForList(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "productwiki.ProductWikiClient", "List", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForList prepares the List request. -func (c ProductWikiClient) preparerForList(ctx context.Context, id ProductId, options ListOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/wikis", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListWithNextLink prepares the List request with the given nextLink token. -func (c ProductWikiClient) 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 ProductWikiClient) responderForList(resp *http.Response) (result ListOperationResponse, err error) { - type page struct { - Values []WikiContract `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, "productwiki.ProductWikiClient", "List", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "productwiki.ProductWikiClient", "List", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForList(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "productwiki.ProductWikiClient", "List", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListComplete retrieves all of the results into a single object -func (c ProductWikiClient) ListComplete(ctx context.Context, id ProductId, options ListOperationOptions) (ListCompleteResult, error) { - return c.ListCompleteMatchingPredicate(ctx, id, options, WikiContractOperationPredicate{}) -} - -// ListCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c ProductWikiClient) ListCompleteMatchingPredicate(ctx context.Context, id ProductId, options ListOperationOptions, predicate WikiContractOperationPredicate) (resp ListCompleteResult, err error) { - items := make([]WikiContract, 0) - - page, err := c.List(ctx, id, options) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/apimanagement/2022-08-01/productwiki/method_update.go b/resource-manager/apimanagement/2022-08-01/productwiki/method_update.go new file mode 100644 index 00000000000..742d965ee39 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/productwiki/method_update.go @@ -0,0 +1,84 @@ +package productwiki + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *WikiContract +} + +type UpdateOperationOptions struct { + IfMatch *string +} + +func DefaultUpdateOperationOptions() UpdateOperationOptions { + return UpdateOperationOptions{} +} + +func (o UpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o UpdateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o UpdateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// Update ... +func (c ProductWikiClient) Update(ctx context.Context, id ProductId, input WikiUpdateContract, options UpdateOperationOptions) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: fmt.Sprintf("%s/wikis/default", id.ID()), + OptionsObject: options, + } + + 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/apimanagement/2022-08-01/productwiki/method_update_autorest.go b/resource-manager/apimanagement/2022-08-01/productwiki/method_update_autorest.go deleted file mode 100644 index 67def99260e..00000000000 --- a/resource-manager/apimanagement/2022-08-01/productwiki/method_update_autorest.go +++ /dev/null @@ -1,99 +0,0 @@ -package productwiki - -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 UpdateOperationResponse struct { - HttpResponse *http.Response - Model *WikiContract -} - -type UpdateOperationOptions struct { - IfMatch *string -} - -func DefaultUpdateOperationOptions() UpdateOperationOptions { - return UpdateOperationOptions{} -} - -func (o UpdateOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o UpdateOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// Update ... -func (c ProductWikiClient) Update(ctx context.Context, id ProductId, input WikiUpdateContract, options UpdateOperationOptions) (result UpdateOperationResponse, err error) { - req, err := c.preparerForUpdate(ctx, id, input, options) - if err != nil { - err = autorest.NewErrorWithError(err, "productwiki.ProductWikiClient", "Update", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "productwiki.ProductWikiClient", "Update", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "productwiki.ProductWikiClient", "Update", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForUpdate prepares the Update request. -func (c ProductWikiClient) preparerForUpdate(ctx context.Context, id ProductId, input WikiUpdateContract, options UpdateOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPatch(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/wikis/default", 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 ProductWikiClient) 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/apimanagement/2022-08-01/quotabycounterkeys/client.go b/resource-manager/apimanagement/2022-08-01/quotabycounterkeys/client.go index 2671480732c..fa7c3b75859 100644 --- a/resource-manager/apimanagement/2022-08-01/quotabycounterkeys/client.go +++ b/resource-manager/apimanagement/2022-08-01/quotabycounterkeys/client.go @@ -1,18 +1,26 @@ package quotabycounterkeys -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 QuotaByCounterKeysClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewQuotaByCounterKeysClientWithBaseURI(endpoint string) QuotaByCounterKeysClient { - return QuotaByCounterKeysClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewQuotaByCounterKeysClientWithBaseURI(api environments.Api) (*QuotaByCounterKeysClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "quotabycounterkeys", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating QuotaByCounterKeysClient: %+v", err) } + + return &QuotaByCounterKeysClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2022-08-01/quotabycounterkeys/method_listbyservice.go b/resource-manager/apimanagement/2022-08-01/quotabycounterkeys/method_listbyservice.go new file mode 100644 index 00000000000..dea7040ba8b --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/quotabycounterkeys/method_listbyservice.go @@ -0,0 +1,51 @@ +package quotabycounterkeys + +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 ListByServiceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *QuotaCounterCollection +} + +// ListByService ... +func (c QuotaByCounterKeysClient) ListByService(ctx context.Context, id QuotaId) (result ListByServiceOperationResponse, 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/apimanagement/2022-08-01/quotabycounterkeys/method_listbyservice_autorest.go b/resource-manager/apimanagement/2022-08-01/quotabycounterkeys/method_listbyservice_autorest.go deleted file mode 100644 index bc4c2e7a4c2..00000000000 --- a/resource-manager/apimanagement/2022-08-01/quotabycounterkeys/method_listbyservice_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package quotabycounterkeys - -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 ListByServiceOperationResponse struct { - HttpResponse *http.Response - Model *QuotaCounterCollection -} - -// ListByService ... -func (c QuotaByCounterKeysClient) ListByService(ctx context.Context, id QuotaId) (result ListByServiceOperationResponse, err error) { - req, err := c.preparerForListByService(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "quotabycounterkeys.QuotaByCounterKeysClient", "ListByService", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "quotabycounterkeys.QuotaByCounterKeysClient", "ListByService", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByService(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "quotabycounterkeys.QuotaByCounterKeysClient", "ListByService", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForListByService prepares the ListByService request. -func (c QuotaByCounterKeysClient) preparerForListByService(ctx context.Context, id QuotaId) (*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)) -} - -// responderForListByService handles the response to the ListByService request. The method always -// closes the http.Response Body. -func (c QuotaByCounterKeysClient) responderForListByService(resp *http.Response) (result ListByServiceOperationResponse, 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/apimanagement/2022-08-01/quotabycounterkeys/method_update.go b/resource-manager/apimanagement/2022-08-01/quotabycounterkeys/method_update.go new file mode 100644 index 00000000000..f9bc3fcc0d4 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/quotabycounterkeys/method_update.go @@ -0,0 +1,55 @@ +package quotabycounterkeys + +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 *QuotaCounterCollection +} + +// Update ... +func (c QuotaByCounterKeysClient) Update(ctx context.Context, id QuotaId, input QuotaCounterValueUpdateContract) (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/apimanagement/2022-08-01/quotabycounterkeys/method_update_autorest.go b/resource-manager/apimanagement/2022-08-01/quotabycounterkeys/method_update_autorest.go deleted file mode 100644 index 4acf4507ad4..00000000000 --- a/resource-manager/apimanagement/2022-08-01/quotabycounterkeys/method_update_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package quotabycounterkeys - -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 *QuotaCounterCollection -} - -// Update ... -func (c QuotaByCounterKeysClient) Update(ctx context.Context, id QuotaId, input QuotaCounterValueUpdateContract) (result UpdateOperationResponse, err error) { - req, err := c.preparerForUpdate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "quotabycounterkeys.QuotaByCounterKeysClient", "Update", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "quotabycounterkeys.QuotaByCounterKeysClient", "Update", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "quotabycounterkeys.QuotaByCounterKeysClient", "Update", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForUpdate prepares the Update request. -func (c QuotaByCounterKeysClient) preparerForUpdate(ctx context.Context, id QuotaId, input QuotaCounterValueUpdateContract) (*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 QuotaByCounterKeysClient) 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/apimanagement/2022-08-01/quotabyperiodkeys/client.go b/resource-manager/apimanagement/2022-08-01/quotabyperiodkeys/client.go index 09577f5147f..8798344eed8 100644 --- a/resource-manager/apimanagement/2022-08-01/quotabyperiodkeys/client.go +++ b/resource-manager/apimanagement/2022-08-01/quotabyperiodkeys/client.go @@ -1,18 +1,26 @@ package quotabyperiodkeys -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 QuotaByPeriodKeysClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewQuotaByPeriodKeysClientWithBaseURI(endpoint string) QuotaByPeriodKeysClient { - return QuotaByPeriodKeysClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewQuotaByPeriodKeysClientWithBaseURI(api environments.Api) (*QuotaByPeriodKeysClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "quotabyperiodkeys", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating QuotaByPeriodKeysClient: %+v", err) } + + return &QuotaByPeriodKeysClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2022-08-01/quotabyperiodkeys/method_get.go b/resource-manager/apimanagement/2022-08-01/quotabyperiodkeys/method_get.go new file mode 100644 index 00000000000..d5d20c15b6f --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/quotabyperiodkeys/method_get.go @@ -0,0 +1,51 @@ +package quotabyperiodkeys + +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 *QuotaCounterContract +} + +// Get ... +func (c QuotaByPeriodKeysClient) Get(ctx context.Context, id PeriodId) (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/apimanagement/2022-08-01/quotabyperiodkeys/method_get_autorest.go b/resource-manager/apimanagement/2022-08-01/quotabyperiodkeys/method_get_autorest.go deleted file mode 100644 index 01ee60c2d53..00000000000 --- a/resource-manager/apimanagement/2022-08-01/quotabyperiodkeys/method_get_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package quotabyperiodkeys - -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 *QuotaCounterContract -} - -// Get ... -func (c QuotaByPeriodKeysClient) Get(ctx context.Context, id PeriodId) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "quotabyperiodkeys.QuotaByPeriodKeysClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "quotabyperiodkeys.QuotaByPeriodKeysClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "quotabyperiodkeys.QuotaByPeriodKeysClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c QuotaByPeriodKeysClient) preparerForGet(ctx context.Context, id PeriodId) (*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 QuotaByPeriodKeysClient) 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/apimanagement/2022-08-01/quotabyperiodkeys/method_update.go b/resource-manager/apimanagement/2022-08-01/quotabyperiodkeys/method_update.go new file mode 100644 index 00000000000..0d078a397a0 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/quotabyperiodkeys/method_update.go @@ -0,0 +1,55 @@ +package quotabyperiodkeys + +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 *QuotaCounterContract +} + +// Update ... +func (c QuotaByPeriodKeysClient) Update(ctx context.Context, id PeriodId, input QuotaCounterValueUpdateContract) (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/apimanagement/2022-08-01/quotabyperiodkeys/method_update_autorest.go b/resource-manager/apimanagement/2022-08-01/quotabyperiodkeys/method_update_autorest.go deleted file mode 100644 index 40b49856a3c..00000000000 --- a/resource-manager/apimanagement/2022-08-01/quotabyperiodkeys/method_update_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package quotabyperiodkeys - -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 *QuotaCounterContract -} - -// Update ... -func (c QuotaByPeriodKeysClient) Update(ctx context.Context, id PeriodId, input QuotaCounterValueUpdateContract) (result UpdateOperationResponse, err error) { - req, err := c.preparerForUpdate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "quotabyperiodkeys.QuotaByPeriodKeysClient", "Update", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "quotabyperiodkeys.QuotaByPeriodKeysClient", "Update", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "quotabyperiodkeys.QuotaByPeriodKeysClient", "Update", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForUpdate prepares the Update request. -func (c QuotaByPeriodKeysClient) preparerForUpdate(ctx context.Context, id PeriodId, input QuotaCounterValueUpdateContract) (*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 QuotaByPeriodKeysClient) 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/apimanagement/2022-08-01/region/client.go b/resource-manager/apimanagement/2022-08-01/region/client.go index 68b48c48347..2222b891e03 100644 --- a/resource-manager/apimanagement/2022-08-01/region/client.go +++ b/resource-manager/apimanagement/2022-08-01/region/client.go @@ -1,18 +1,26 @@ package region -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 RegionClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewRegionClientWithBaseURI(endpoint string) RegionClient { - return RegionClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewRegionClientWithBaseURI(api environments.Api) (*RegionClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "region", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating RegionClient: %+v", err) } + + return &RegionClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2022-08-01/region/method_listbyservice.go b/resource-manager/apimanagement/2022-08-01/region/method_listbyservice.go new file mode 100644 index 00000000000..5969f7e8fea --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/region/method_listbyservice.go @@ -0,0 +1,89 @@ +package region + +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 ListByServiceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]RegionContract +} + +type ListByServiceCompleteResult struct { + Items []RegionContract +} + +// ListByService ... +func (c RegionClient) ListByService(ctx context.Context, id ServiceId) (result ListByServiceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/regions", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]RegionContract `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByServiceComplete retrieves all the results into a single object +func (c RegionClient) ListByServiceComplete(ctx context.Context, id ServiceId) (ListByServiceCompleteResult, error) { + return c.ListByServiceCompleteMatchingPredicate(ctx, id, RegionContractOperationPredicate{}) +} + +// ListByServiceCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c RegionClient) ListByServiceCompleteMatchingPredicate(ctx context.Context, id ServiceId, predicate RegionContractOperationPredicate) (result ListByServiceCompleteResult, err error) { + items := make([]RegionContract, 0) + + resp, err := c.ListByService(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 = ListByServiceCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/apimanagement/2022-08-01/region/method_listbyservice_autorest.go b/resource-manager/apimanagement/2022-08-01/region/method_listbyservice_autorest.go deleted file mode 100644 index f1bc29a5de4..00000000000 --- a/resource-manager/apimanagement/2022-08-01/region/method_listbyservice_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package region - -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 ListByServiceOperationResponse struct { - HttpResponse *http.Response - Model *[]RegionContract - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListByServiceOperationResponse, error) -} - -type ListByServiceCompleteResult struct { - Items []RegionContract -} - -func (r ListByServiceOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListByServiceOperationResponse) LoadMore(ctx context.Context) (resp ListByServiceOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListByService ... -func (c RegionClient) ListByService(ctx context.Context, id ServiceId) (resp ListByServiceOperationResponse, err error) { - req, err := c.preparerForListByService(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "region.RegionClient", "ListByService", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "region.RegionClient", "ListByService", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListByService(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "region.RegionClient", "ListByService", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListByService prepares the ListByService request. -func (c RegionClient) preparerForListByService(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(fmt.Sprintf("%s/regions", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListByServiceWithNextLink prepares the ListByService request with the given nextLink token. -func (c RegionClient) preparerForListByServiceWithNextLink(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)) -} - -// responderForListByService handles the response to the ListByService request. The method always -// closes the http.Response Body. -func (c RegionClient) responderForListByService(resp *http.Response) (result ListByServiceOperationResponse, err error) { - type page struct { - Values []RegionContract `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 ListByServiceOperationResponse, err error) { - req, err := c.preparerForListByServiceWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "region.RegionClient", "ListByService", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "region.RegionClient", "ListByService", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByService(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "region.RegionClient", "ListByService", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListByServiceComplete retrieves all of the results into a single object -func (c RegionClient) ListByServiceComplete(ctx context.Context, id ServiceId) (ListByServiceCompleteResult, error) { - return c.ListByServiceCompleteMatchingPredicate(ctx, id, RegionContractOperationPredicate{}) -} - -// ListByServiceCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c RegionClient) ListByServiceCompleteMatchingPredicate(ctx context.Context, id ServiceId, predicate RegionContractOperationPredicate) (resp ListByServiceCompleteResult, err error) { - items := make([]RegionContract, 0) - - page, err := c.ListByService(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 := ListByServiceCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/apimanagement/2022-08-01/reports/client.go b/resource-manager/apimanagement/2022-08-01/reports/client.go index 605c74c6124..205fdeee8dd 100644 --- a/resource-manager/apimanagement/2022-08-01/reports/client.go +++ b/resource-manager/apimanagement/2022-08-01/reports/client.go @@ -1,18 +1,26 @@ package reports -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 ReportsClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewReportsClientWithBaseURI(endpoint string) ReportsClient { - return ReportsClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewReportsClientWithBaseURI(api environments.Api) (*ReportsClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "reports", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ReportsClient: %+v", err) } + + return &ReportsClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2022-08-01/reports/method_listbyapi.go b/resource-manager/apimanagement/2022-08-01/reports/method_listbyapi.go new file mode 100644 index 00000000000..06522bae2a6 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/reports/method_listbyapi.go @@ -0,0 +1,129 @@ +package reports + +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 ListByApiOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ReportRecordContract +} + +type ListByApiCompleteResult struct { + Items []ReportRecordContract +} + +type ListByApiOperationOptions struct { + Filter *string + Orderby *string + Skip *int64 + Top *int64 +} + +func DefaultListByApiOperationOptions() ListByApiOperationOptions { + return ListByApiOperationOptions{} +} + +func (o ListByApiOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListByApiOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListByApiOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.Orderby != nil { + out.Append("$orderby", fmt.Sprintf("%v", *o.Orderby)) + } + if o.Skip != nil { + out.Append("$skip", fmt.Sprintf("%v", *o.Skip)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +// ListByApi ... +func (c ReportsClient) ListByApi(ctx context.Context, id ServiceId, options ListByApiOperationOptions) (result ListByApiOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/reports/byApi", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ReportRecordContract `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByApiComplete retrieves all the results into a single object +func (c ReportsClient) ListByApiComplete(ctx context.Context, id ServiceId, options ListByApiOperationOptions) (ListByApiCompleteResult, error) { + return c.ListByApiCompleteMatchingPredicate(ctx, id, options, ReportRecordContractOperationPredicate{}) +} + +// ListByApiCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ReportsClient) ListByApiCompleteMatchingPredicate(ctx context.Context, id ServiceId, options ListByApiOperationOptions, predicate ReportRecordContractOperationPredicate) (result ListByApiCompleteResult, err error) { + items := make([]ReportRecordContract, 0) + + resp, err := c.ListByApi(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByApiCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/apimanagement/2022-08-01/reports/method_listbyapi_autorest.go b/resource-manager/apimanagement/2022-08-01/reports/method_listbyapi_autorest.go deleted file mode 100644 index 61513c4e70d..00000000000 --- a/resource-manager/apimanagement/2022-08-01/reports/method_listbyapi_autorest.go +++ /dev/null @@ -1,230 +0,0 @@ -package reports - -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 ListByApiOperationResponse struct { - HttpResponse *http.Response - Model *[]ReportRecordContract - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListByApiOperationResponse, error) -} - -type ListByApiCompleteResult struct { - Items []ReportRecordContract -} - -func (r ListByApiOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListByApiOperationResponse) LoadMore(ctx context.Context) (resp ListByApiOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -type ListByApiOperationOptions struct { - Filter *string - Orderby *string - Skip *int64 - Top *int64 -} - -func DefaultListByApiOperationOptions() ListByApiOperationOptions { - return ListByApiOperationOptions{} -} - -func (o ListByApiOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o ListByApiOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Filter != nil { - out["$filter"] = *o.Filter - } - - if o.Orderby != nil { - out["$orderby"] = *o.Orderby - } - - if o.Skip != nil { - out["$skip"] = *o.Skip - } - - if o.Top != nil { - out["$top"] = *o.Top - } - - return out -} - -// ListByApi ... -func (c ReportsClient) ListByApi(ctx context.Context, id ServiceId, options ListByApiOperationOptions) (resp ListByApiOperationResponse, err error) { - req, err := c.preparerForListByApi(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "reports.ReportsClient", "ListByApi", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "reports.ReportsClient", "ListByApi", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListByApi(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "reports.ReportsClient", "ListByApi", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListByApi prepares the ListByApi request. -func (c ReportsClient) preparerForListByApi(ctx context.Context, id ServiceId, options ListByApiOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/reports/byApi", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListByApiWithNextLink prepares the ListByApi request with the given nextLink token. -func (c ReportsClient) preparerForListByApiWithNextLink(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)) -} - -// responderForListByApi handles the response to the ListByApi request. The method always -// closes the http.Response Body. -func (c ReportsClient) responderForListByApi(resp *http.Response) (result ListByApiOperationResponse, err error) { - type page struct { - Values []ReportRecordContract `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 ListByApiOperationResponse, err error) { - req, err := c.preparerForListByApiWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "reports.ReportsClient", "ListByApi", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "reports.ReportsClient", "ListByApi", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByApi(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "reports.ReportsClient", "ListByApi", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListByApiComplete retrieves all of the results into a single object -func (c ReportsClient) ListByApiComplete(ctx context.Context, id ServiceId, options ListByApiOperationOptions) (ListByApiCompleteResult, error) { - return c.ListByApiCompleteMatchingPredicate(ctx, id, options, ReportRecordContractOperationPredicate{}) -} - -// ListByApiCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c ReportsClient) ListByApiCompleteMatchingPredicate(ctx context.Context, id ServiceId, options ListByApiOperationOptions, predicate ReportRecordContractOperationPredicate) (resp ListByApiCompleteResult, err error) { - items := make([]ReportRecordContract, 0) - - page, err := c.ListByApi(ctx, id, options) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListByApiCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/apimanagement/2022-08-01/reports/method_listbygeo.go b/resource-manager/apimanagement/2022-08-01/reports/method_listbygeo.go new file mode 100644 index 00000000000..2532e17d25b --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/reports/method_listbygeo.go @@ -0,0 +1,125 @@ +package reports + +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 ListByGeoOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ReportRecordContract +} + +type ListByGeoCompleteResult struct { + Items []ReportRecordContract +} + +type ListByGeoOperationOptions struct { + Filter *string + Skip *int64 + Top *int64 +} + +func DefaultListByGeoOperationOptions() ListByGeoOperationOptions { + return ListByGeoOperationOptions{} +} + +func (o ListByGeoOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListByGeoOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListByGeoOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.Skip != nil { + out.Append("$skip", fmt.Sprintf("%v", *o.Skip)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +// ListByGeo ... +func (c ReportsClient) ListByGeo(ctx context.Context, id ServiceId, options ListByGeoOperationOptions) (result ListByGeoOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/reports/byGeo", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ReportRecordContract `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByGeoComplete retrieves all the results into a single object +func (c ReportsClient) ListByGeoComplete(ctx context.Context, id ServiceId, options ListByGeoOperationOptions) (ListByGeoCompleteResult, error) { + return c.ListByGeoCompleteMatchingPredicate(ctx, id, options, ReportRecordContractOperationPredicate{}) +} + +// ListByGeoCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ReportsClient) ListByGeoCompleteMatchingPredicate(ctx context.Context, id ServiceId, options ListByGeoOperationOptions, predicate ReportRecordContractOperationPredicate) (result ListByGeoCompleteResult, err error) { + items := make([]ReportRecordContract, 0) + + resp, err := c.ListByGeo(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByGeoCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/apimanagement/2022-08-01/reports/method_listbygeo_autorest.go b/resource-manager/apimanagement/2022-08-01/reports/method_listbygeo_autorest.go deleted file mode 100644 index 946c693c961..00000000000 --- a/resource-manager/apimanagement/2022-08-01/reports/method_listbygeo_autorest.go +++ /dev/null @@ -1,225 +0,0 @@ -package reports - -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 ListByGeoOperationResponse struct { - HttpResponse *http.Response - Model *[]ReportRecordContract - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListByGeoOperationResponse, error) -} - -type ListByGeoCompleteResult struct { - Items []ReportRecordContract -} - -func (r ListByGeoOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListByGeoOperationResponse) LoadMore(ctx context.Context) (resp ListByGeoOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -type ListByGeoOperationOptions struct { - Filter *string - Skip *int64 - Top *int64 -} - -func DefaultListByGeoOperationOptions() ListByGeoOperationOptions { - return ListByGeoOperationOptions{} -} - -func (o ListByGeoOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o ListByGeoOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Filter != nil { - out["$filter"] = *o.Filter - } - - if o.Skip != nil { - out["$skip"] = *o.Skip - } - - if o.Top != nil { - out["$top"] = *o.Top - } - - return out -} - -// ListByGeo ... -func (c ReportsClient) ListByGeo(ctx context.Context, id ServiceId, options ListByGeoOperationOptions) (resp ListByGeoOperationResponse, err error) { - req, err := c.preparerForListByGeo(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "reports.ReportsClient", "ListByGeo", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "reports.ReportsClient", "ListByGeo", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListByGeo(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "reports.ReportsClient", "ListByGeo", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListByGeo prepares the ListByGeo request. -func (c ReportsClient) preparerForListByGeo(ctx context.Context, id ServiceId, options ListByGeoOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/reports/byGeo", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListByGeoWithNextLink prepares the ListByGeo request with the given nextLink token. -func (c ReportsClient) preparerForListByGeoWithNextLink(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)) -} - -// responderForListByGeo handles the response to the ListByGeo request. The method always -// closes the http.Response Body. -func (c ReportsClient) responderForListByGeo(resp *http.Response) (result ListByGeoOperationResponse, err error) { - type page struct { - Values []ReportRecordContract `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 ListByGeoOperationResponse, err error) { - req, err := c.preparerForListByGeoWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "reports.ReportsClient", "ListByGeo", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "reports.ReportsClient", "ListByGeo", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByGeo(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "reports.ReportsClient", "ListByGeo", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListByGeoComplete retrieves all of the results into a single object -func (c ReportsClient) ListByGeoComplete(ctx context.Context, id ServiceId, options ListByGeoOperationOptions) (ListByGeoCompleteResult, error) { - return c.ListByGeoCompleteMatchingPredicate(ctx, id, options, ReportRecordContractOperationPredicate{}) -} - -// ListByGeoCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c ReportsClient) ListByGeoCompleteMatchingPredicate(ctx context.Context, id ServiceId, options ListByGeoOperationOptions, predicate ReportRecordContractOperationPredicate) (resp ListByGeoCompleteResult, err error) { - items := make([]ReportRecordContract, 0) - - page, err := c.ListByGeo(ctx, id, options) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListByGeoCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/apimanagement/2022-08-01/reports/method_listbyoperation.go b/resource-manager/apimanagement/2022-08-01/reports/method_listbyoperation.go new file mode 100644 index 00000000000..80567e9f209 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/reports/method_listbyoperation.go @@ -0,0 +1,129 @@ +package reports + +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 ListByOperationOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ReportRecordContract +} + +type ListByOperationCompleteResult struct { + Items []ReportRecordContract +} + +type ListByOperationOperationOptions struct { + Filter *string + Orderby *string + Skip *int64 + Top *int64 +} + +func DefaultListByOperationOperationOptions() ListByOperationOperationOptions { + return ListByOperationOperationOptions{} +} + +func (o ListByOperationOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListByOperationOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListByOperationOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.Orderby != nil { + out.Append("$orderby", fmt.Sprintf("%v", *o.Orderby)) + } + if o.Skip != nil { + out.Append("$skip", fmt.Sprintf("%v", *o.Skip)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +// ListByOperation ... +func (c ReportsClient) ListByOperation(ctx context.Context, id ServiceId, options ListByOperationOperationOptions) (result ListByOperationOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/reports/byOperation", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ReportRecordContract `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByOperationComplete retrieves all the results into a single object +func (c ReportsClient) ListByOperationComplete(ctx context.Context, id ServiceId, options ListByOperationOperationOptions) (ListByOperationCompleteResult, error) { + return c.ListByOperationCompleteMatchingPredicate(ctx, id, options, ReportRecordContractOperationPredicate{}) +} + +// ListByOperationCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ReportsClient) ListByOperationCompleteMatchingPredicate(ctx context.Context, id ServiceId, options ListByOperationOperationOptions, predicate ReportRecordContractOperationPredicate) (result ListByOperationCompleteResult, err error) { + items := make([]ReportRecordContract, 0) + + resp, err := c.ListByOperation(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByOperationCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/apimanagement/2022-08-01/reports/method_listbyoperation_autorest.go b/resource-manager/apimanagement/2022-08-01/reports/method_listbyoperation_autorest.go deleted file mode 100644 index 3aa660eb04c..00000000000 --- a/resource-manager/apimanagement/2022-08-01/reports/method_listbyoperation_autorest.go +++ /dev/null @@ -1,230 +0,0 @@ -package reports - -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 ListByOperationOperationResponse struct { - HttpResponse *http.Response - Model *[]ReportRecordContract - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListByOperationOperationResponse, error) -} - -type ListByOperationCompleteResult struct { - Items []ReportRecordContract -} - -func (r ListByOperationOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListByOperationOperationResponse) LoadMore(ctx context.Context) (resp ListByOperationOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -type ListByOperationOperationOptions struct { - Filter *string - Orderby *string - Skip *int64 - Top *int64 -} - -func DefaultListByOperationOperationOptions() ListByOperationOperationOptions { - return ListByOperationOperationOptions{} -} - -func (o ListByOperationOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o ListByOperationOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Filter != nil { - out["$filter"] = *o.Filter - } - - if o.Orderby != nil { - out["$orderby"] = *o.Orderby - } - - if o.Skip != nil { - out["$skip"] = *o.Skip - } - - if o.Top != nil { - out["$top"] = *o.Top - } - - return out -} - -// ListByOperation ... -func (c ReportsClient) ListByOperation(ctx context.Context, id ServiceId, options ListByOperationOperationOptions) (resp ListByOperationOperationResponse, err error) { - req, err := c.preparerForListByOperation(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "reports.ReportsClient", "ListByOperation", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "reports.ReportsClient", "ListByOperation", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListByOperation(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "reports.ReportsClient", "ListByOperation", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListByOperation prepares the ListByOperation request. -func (c ReportsClient) preparerForListByOperation(ctx context.Context, id ServiceId, options ListByOperationOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/reports/byOperation", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListByOperationWithNextLink prepares the ListByOperation request with the given nextLink token. -func (c ReportsClient) preparerForListByOperationWithNextLink(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)) -} - -// responderForListByOperation handles the response to the ListByOperation request. The method always -// closes the http.Response Body. -func (c ReportsClient) responderForListByOperation(resp *http.Response) (result ListByOperationOperationResponse, err error) { - type page struct { - Values []ReportRecordContract `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 ListByOperationOperationResponse, err error) { - req, err := c.preparerForListByOperationWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "reports.ReportsClient", "ListByOperation", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "reports.ReportsClient", "ListByOperation", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByOperation(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "reports.ReportsClient", "ListByOperation", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListByOperationComplete retrieves all of the results into a single object -func (c ReportsClient) ListByOperationComplete(ctx context.Context, id ServiceId, options ListByOperationOperationOptions) (ListByOperationCompleteResult, error) { - return c.ListByOperationCompleteMatchingPredicate(ctx, id, options, ReportRecordContractOperationPredicate{}) -} - -// ListByOperationCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c ReportsClient) ListByOperationCompleteMatchingPredicate(ctx context.Context, id ServiceId, options ListByOperationOperationOptions, predicate ReportRecordContractOperationPredicate) (resp ListByOperationCompleteResult, err error) { - items := make([]ReportRecordContract, 0) - - page, err := c.ListByOperation(ctx, id, options) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListByOperationCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/apimanagement/2022-08-01/reports/method_listbyproduct.go b/resource-manager/apimanagement/2022-08-01/reports/method_listbyproduct.go new file mode 100644 index 00000000000..de187303948 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/reports/method_listbyproduct.go @@ -0,0 +1,129 @@ +package reports + +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 ListByProductOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ReportRecordContract +} + +type ListByProductCompleteResult struct { + Items []ReportRecordContract +} + +type ListByProductOperationOptions struct { + Filter *string + Orderby *string + Skip *int64 + Top *int64 +} + +func DefaultListByProductOperationOptions() ListByProductOperationOptions { + return ListByProductOperationOptions{} +} + +func (o ListByProductOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListByProductOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListByProductOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.Orderby != nil { + out.Append("$orderby", fmt.Sprintf("%v", *o.Orderby)) + } + if o.Skip != nil { + out.Append("$skip", fmt.Sprintf("%v", *o.Skip)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +// ListByProduct ... +func (c ReportsClient) ListByProduct(ctx context.Context, id ServiceId, options ListByProductOperationOptions) (result ListByProductOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/reports/byProduct", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ReportRecordContract `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByProductComplete retrieves all the results into a single object +func (c ReportsClient) ListByProductComplete(ctx context.Context, id ServiceId, options ListByProductOperationOptions) (ListByProductCompleteResult, error) { + return c.ListByProductCompleteMatchingPredicate(ctx, id, options, ReportRecordContractOperationPredicate{}) +} + +// ListByProductCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ReportsClient) ListByProductCompleteMatchingPredicate(ctx context.Context, id ServiceId, options ListByProductOperationOptions, predicate ReportRecordContractOperationPredicate) (result ListByProductCompleteResult, err error) { + items := make([]ReportRecordContract, 0) + + resp, err := c.ListByProduct(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByProductCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/apimanagement/2022-08-01/reports/method_listbyproduct_autorest.go b/resource-manager/apimanagement/2022-08-01/reports/method_listbyproduct_autorest.go deleted file mode 100644 index 507a05240b8..00000000000 --- a/resource-manager/apimanagement/2022-08-01/reports/method_listbyproduct_autorest.go +++ /dev/null @@ -1,230 +0,0 @@ -package reports - -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 ListByProductOperationResponse struct { - HttpResponse *http.Response - Model *[]ReportRecordContract - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListByProductOperationResponse, error) -} - -type ListByProductCompleteResult struct { - Items []ReportRecordContract -} - -func (r ListByProductOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListByProductOperationResponse) LoadMore(ctx context.Context) (resp ListByProductOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -type ListByProductOperationOptions struct { - Filter *string - Orderby *string - Skip *int64 - Top *int64 -} - -func DefaultListByProductOperationOptions() ListByProductOperationOptions { - return ListByProductOperationOptions{} -} - -func (o ListByProductOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o ListByProductOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Filter != nil { - out["$filter"] = *o.Filter - } - - if o.Orderby != nil { - out["$orderby"] = *o.Orderby - } - - if o.Skip != nil { - out["$skip"] = *o.Skip - } - - if o.Top != nil { - out["$top"] = *o.Top - } - - return out -} - -// ListByProduct ... -func (c ReportsClient) ListByProduct(ctx context.Context, id ServiceId, options ListByProductOperationOptions) (resp ListByProductOperationResponse, err error) { - req, err := c.preparerForListByProduct(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "reports.ReportsClient", "ListByProduct", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "reports.ReportsClient", "ListByProduct", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListByProduct(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "reports.ReportsClient", "ListByProduct", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListByProduct prepares the ListByProduct request. -func (c ReportsClient) preparerForListByProduct(ctx context.Context, id ServiceId, options ListByProductOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/reports/byProduct", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListByProductWithNextLink prepares the ListByProduct request with the given nextLink token. -func (c ReportsClient) preparerForListByProductWithNextLink(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)) -} - -// responderForListByProduct handles the response to the ListByProduct request. The method always -// closes the http.Response Body. -func (c ReportsClient) responderForListByProduct(resp *http.Response) (result ListByProductOperationResponse, err error) { - type page struct { - Values []ReportRecordContract `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 ListByProductOperationResponse, err error) { - req, err := c.preparerForListByProductWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "reports.ReportsClient", "ListByProduct", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "reports.ReportsClient", "ListByProduct", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByProduct(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "reports.ReportsClient", "ListByProduct", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListByProductComplete retrieves all of the results into a single object -func (c ReportsClient) ListByProductComplete(ctx context.Context, id ServiceId, options ListByProductOperationOptions) (ListByProductCompleteResult, error) { - return c.ListByProductCompleteMatchingPredicate(ctx, id, options, ReportRecordContractOperationPredicate{}) -} - -// ListByProductCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c ReportsClient) ListByProductCompleteMatchingPredicate(ctx context.Context, id ServiceId, options ListByProductOperationOptions, predicate ReportRecordContractOperationPredicate) (resp ListByProductCompleteResult, err error) { - items := make([]ReportRecordContract, 0) - - page, err := c.ListByProduct(ctx, id, options) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListByProductCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/apimanagement/2022-08-01/reports/method_listbyrequest.go b/resource-manager/apimanagement/2022-08-01/reports/method_listbyrequest.go new file mode 100644 index 00000000000..bd4c8b54a0d --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/reports/method_listbyrequest.go @@ -0,0 +1,88 @@ +package reports + +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 ListByRequestOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *RequestReportCollection +} + +type ListByRequestOperationOptions struct { + Filter *string + Skip *int64 + Top *int64 +} + +func DefaultListByRequestOperationOptions() ListByRequestOperationOptions { + return ListByRequestOperationOptions{} +} + +func (o ListByRequestOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListByRequestOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListByRequestOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.Skip != nil { + out.Append("$skip", fmt.Sprintf("%v", *o.Skip)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +// ListByRequest ... +func (c ReportsClient) ListByRequest(ctx context.Context, id ServiceId, options ListByRequestOperationOptions) (result ListByRequestOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/reports/byRequest", id.ID()), + OptionsObject: options, + } + + 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/apimanagement/2022-08-01/reports/method_listbyrequest_autorest.go b/resource-manager/apimanagement/2022-08-01/reports/method_listbyrequest_autorest.go deleted file mode 100644 index 27f2a2395ef..00000000000 --- a/resource-manager/apimanagement/2022-08-01/reports/method_listbyrequest_autorest.go +++ /dev/null @@ -1,108 +0,0 @@ -package reports - -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 ListByRequestOperationResponse struct { - HttpResponse *http.Response - Model *RequestReportCollection -} - -type ListByRequestOperationOptions struct { - Filter *string - Skip *int64 - Top *int64 -} - -func DefaultListByRequestOperationOptions() ListByRequestOperationOptions { - return ListByRequestOperationOptions{} -} - -func (o ListByRequestOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o ListByRequestOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Filter != nil { - out["$filter"] = *o.Filter - } - - if o.Skip != nil { - out["$skip"] = *o.Skip - } - - if o.Top != nil { - out["$top"] = *o.Top - } - - return out -} - -// ListByRequest ... -func (c ReportsClient) ListByRequest(ctx context.Context, id ServiceId, options ListByRequestOperationOptions) (result ListByRequestOperationResponse, err error) { - req, err := c.preparerForListByRequest(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "reports.ReportsClient", "ListByRequest", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "reports.ReportsClient", "ListByRequest", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByRequest(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "reports.ReportsClient", "ListByRequest", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForListByRequest prepares the ListByRequest request. -func (c ReportsClient) preparerForListByRequest(ctx context.Context, id ServiceId, options ListByRequestOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/reports/byRequest", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListByRequest handles the response to the ListByRequest request. The method always -// closes the http.Response Body. -func (c ReportsClient) responderForListByRequest(resp *http.Response) (result ListByRequestOperationResponse, 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/apimanagement/2022-08-01/reports/method_listbysubscription.go b/resource-manager/apimanagement/2022-08-01/reports/method_listbysubscription.go new file mode 100644 index 00000000000..22df641c1c4 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/reports/method_listbysubscription.go @@ -0,0 +1,129 @@ +package reports + +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 ListBySubscriptionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ReportRecordContract +} + +type ListBySubscriptionCompleteResult struct { + Items []ReportRecordContract +} + +type ListBySubscriptionOperationOptions struct { + Filter *string + Orderby *string + Skip *int64 + Top *int64 +} + +func DefaultListBySubscriptionOperationOptions() ListBySubscriptionOperationOptions { + return ListBySubscriptionOperationOptions{} +} + +func (o ListBySubscriptionOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListBySubscriptionOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListBySubscriptionOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.Orderby != nil { + out.Append("$orderby", fmt.Sprintf("%v", *o.Orderby)) + } + if o.Skip != nil { + out.Append("$skip", fmt.Sprintf("%v", *o.Skip)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +// ListBySubscription ... +func (c ReportsClient) ListBySubscription(ctx context.Context, id ServiceId, options ListBySubscriptionOperationOptions) (result ListBySubscriptionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/reports/bySubscription", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ReportRecordContract `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 ReportsClient) ListBySubscriptionComplete(ctx context.Context, id ServiceId, options ListBySubscriptionOperationOptions) (ListBySubscriptionCompleteResult, error) { + return c.ListBySubscriptionCompleteMatchingPredicate(ctx, id, options, ReportRecordContractOperationPredicate{}) +} + +// ListBySubscriptionCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ReportsClient) ListBySubscriptionCompleteMatchingPredicate(ctx context.Context, id ServiceId, options ListBySubscriptionOperationOptions, predicate ReportRecordContractOperationPredicate) (result ListBySubscriptionCompleteResult, err error) { + items := make([]ReportRecordContract, 0) + + resp, err := c.ListBySubscription(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListBySubscriptionCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/apimanagement/2022-08-01/reports/method_listbysubscription_autorest.go b/resource-manager/apimanagement/2022-08-01/reports/method_listbysubscription_autorest.go deleted file mode 100644 index e0c5065d369..00000000000 --- a/resource-manager/apimanagement/2022-08-01/reports/method_listbysubscription_autorest.go +++ /dev/null @@ -1,230 +0,0 @@ -package reports - -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 ListBySubscriptionOperationResponse struct { - HttpResponse *http.Response - Model *[]ReportRecordContract - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListBySubscriptionOperationResponse, error) -} - -type ListBySubscriptionCompleteResult struct { - Items []ReportRecordContract -} - -func (r ListBySubscriptionOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListBySubscriptionOperationResponse) LoadMore(ctx context.Context) (resp ListBySubscriptionOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -type ListBySubscriptionOperationOptions struct { - Filter *string - Orderby *string - Skip *int64 - Top *int64 -} - -func DefaultListBySubscriptionOperationOptions() ListBySubscriptionOperationOptions { - return ListBySubscriptionOperationOptions{} -} - -func (o ListBySubscriptionOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o ListBySubscriptionOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Filter != nil { - out["$filter"] = *o.Filter - } - - if o.Orderby != nil { - out["$orderby"] = *o.Orderby - } - - if o.Skip != nil { - out["$skip"] = *o.Skip - } - - if o.Top != nil { - out["$top"] = *o.Top - } - - return out -} - -// ListBySubscription ... -func (c ReportsClient) ListBySubscription(ctx context.Context, id ServiceId, options ListBySubscriptionOperationOptions) (resp ListBySubscriptionOperationResponse, err error) { - req, err := c.preparerForListBySubscription(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "reports.ReportsClient", "ListBySubscription", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "reports.ReportsClient", "ListBySubscription", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListBySubscription(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "reports.ReportsClient", "ListBySubscription", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListBySubscription prepares the ListBySubscription request. -func (c ReportsClient) preparerForListBySubscription(ctx context.Context, id ServiceId, options ListBySubscriptionOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/reports/bySubscription", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListBySubscriptionWithNextLink prepares the ListBySubscription request with the given nextLink token. -func (c ReportsClient) 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 ReportsClient) responderForListBySubscription(resp *http.Response) (result ListBySubscriptionOperationResponse, err error) { - type page struct { - Values []ReportRecordContract `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, "reports.ReportsClient", "ListBySubscription", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "reports.ReportsClient", "ListBySubscription", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListBySubscription(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "reports.ReportsClient", "ListBySubscription", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListBySubscriptionComplete retrieves all of the results into a single object -func (c ReportsClient) ListBySubscriptionComplete(ctx context.Context, id ServiceId, options ListBySubscriptionOperationOptions) (ListBySubscriptionCompleteResult, error) { - return c.ListBySubscriptionCompleteMatchingPredicate(ctx, id, options, ReportRecordContractOperationPredicate{}) -} - -// ListBySubscriptionCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c ReportsClient) ListBySubscriptionCompleteMatchingPredicate(ctx context.Context, id ServiceId, options ListBySubscriptionOperationOptions, predicate ReportRecordContractOperationPredicate) (resp ListBySubscriptionCompleteResult, err error) { - items := make([]ReportRecordContract, 0) - - page, err := c.ListBySubscription(ctx, id, options) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListBySubscriptionCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/apimanagement/2022-08-01/reports/method_listbytime.go b/resource-manager/apimanagement/2022-08-01/reports/method_listbytime.go new file mode 100644 index 00000000000..7667748e6bb --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/reports/method_listbytime.go @@ -0,0 +1,133 @@ +package reports + +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 ListByTimeOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ReportRecordContract +} + +type ListByTimeCompleteResult struct { + Items []ReportRecordContract +} + +type ListByTimeOperationOptions struct { + Filter *string + Interval *string + Orderby *string + Skip *int64 + Top *int64 +} + +func DefaultListByTimeOperationOptions() ListByTimeOperationOptions { + return ListByTimeOperationOptions{} +} + +func (o ListByTimeOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListByTimeOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListByTimeOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.Interval != nil { + out.Append("interval", fmt.Sprintf("%v", *o.Interval)) + } + if o.Orderby != nil { + out.Append("$orderby", fmt.Sprintf("%v", *o.Orderby)) + } + if o.Skip != nil { + out.Append("$skip", fmt.Sprintf("%v", *o.Skip)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +// ListByTime ... +func (c ReportsClient) ListByTime(ctx context.Context, id ServiceId, options ListByTimeOperationOptions) (result ListByTimeOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/reports/byTime", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ReportRecordContract `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByTimeComplete retrieves all the results into a single object +func (c ReportsClient) ListByTimeComplete(ctx context.Context, id ServiceId, options ListByTimeOperationOptions) (ListByTimeCompleteResult, error) { + return c.ListByTimeCompleteMatchingPredicate(ctx, id, options, ReportRecordContractOperationPredicate{}) +} + +// ListByTimeCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ReportsClient) ListByTimeCompleteMatchingPredicate(ctx context.Context, id ServiceId, options ListByTimeOperationOptions, predicate ReportRecordContractOperationPredicate) (result ListByTimeCompleteResult, err error) { + items := make([]ReportRecordContract, 0) + + resp, err := c.ListByTime(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByTimeCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/apimanagement/2022-08-01/reports/method_listbytime_autorest.go b/resource-manager/apimanagement/2022-08-01/reports/method_listbytime_autorest.go deleted file mode 100644 index b13857ba750..00000000000 --- a/resource-manager/apimanagement/2022-08-01/reports/method_listbytime_autorest.go +++ /dev/null @@ -1,235 +0,0 @@ -package reports - -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 ListByTimeOperationResponse struct { - HttpResponse *http.Response - Model *[]ReportRecordContract - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListByTimeOperationResponse, error) -} - -type ListByTimeCompleteResult struct { - Items []ReportRecordContract -} - -func (r ListByTimeOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListByTimeOperationResponse) LoadMore(ctx context.Context) (resp ListByTimeOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -type ListByTimeOperationOptions struct { - Filter *string - Interval *string - Orderby *string - Skip *int64 - Top *int64 -} - -func DefaultListByTimeOperationOptions() ListByTimeOperationOptions { - return ListByTimeOperationOptions{} -} - -func (o ListByTimeOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o ListByTimeOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Filter != nil { - out["$filter"] = *o.Filter - } - - if o.Interval != nil { - out["interval"] = *o.Interval - } - - if o.Orderby != nil { - out["$orderby"] = *o.Orderby - } - - if o.Skip != nil { - out["$skip"] = *o.Skip - } - - if o.Top != nil { - out["$top"] = *o.Top - } - - return out -} - -// ListByTime ... -func (c ReportsClient) ListByTime(ctx context.Context, id ServiceId, options ListByTimeOperationOptions) (resp ListByTimeOperationResponse, err error) { - req, err := c.preparerForListByTime(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "reports.ReportsClient", "ListByTime", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "reports.ReportsClient", "ListByTime", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListByTime(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "reports.ReportsClient", "ListByTime", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListByTime prepares the ListByTime request. -func (c ReportsClient) preparerForListByTime(ctx context.Context, id ServiceId, options ListByTimeOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/reports/byTime", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListByTimeWithNextLink prepares the ListByTime request with the given nextLink token. -func (c ReportsClient) preparerForListByTimeWithNextLink(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)) -} - -// responderForListByTime handles the response to the ListByTime request. The method always -// closes the http.Response Body. -func (c ReportsClient) responderForListByTime(resp *http.Response) (result ListByTimeOperationResponse, err error) { - type page struct { - Values []ReportRecordContract `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 ListByTimeOperationResponse, err error) { - req, err := c.preparerForListByTimeWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "reports.ReportsClient", "ListByTime", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "reports.ReportsClient", "ListByTime", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByTime(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "reports.ReportsClient", "ListByTime", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListByTimeComplete retrieves all of the results into a single object -func (c ReportsClient) ListByTimeComplete(ctx context.Context, id ServiceId, options ListByTimeOperationOptions) (ListByTimeCompleteResult, error) { - return c.ListByTimeCompleteMatchingPredicate(ctx, id, options, ReportRecordContractOperationPredicate{}) -} - -// ListByTimeCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c ReportsClient) ListByTimeCompleteMatchingPredicate(ctx context.Context, id ServiceId, options ListByTimeOperationOptions, predicate ReportRecordContractOperationPredicate) (resp ListByTimeCompleteResult, err error) { - items := make([]ReportRecordContract, 0) - - page, err := c.ListByTime(ctx, id, options) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListByTimeCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/apimanagement/2022-08-01/reports/method_listbyuser.go b/resource-manager/apimanagement/2022-08-01/reports/method_listbyuser.go new file mode 100644 index 00000000000..66a39254bdc --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/reports/method_listbyuser.go @@ -0,0 +1,129 @@ +package reports + +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 ListByUserOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ReportRecordContract +} + +type ListByUserCompleteResult struct { + Items []ReportRecordContract +} + +type ListByUserOperationOptions struct { + Filter *string + Orderby *string + Skip *int64 + Top *int64 +} + +func DefaultListByUserOperationOptions() ListByUserOperationOptions { + return ListByUserOperationOptions{} +} + +func (o ListByUserOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListByUserOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListByUserOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.Orderby != nil { + out.Append("$orderby", fmt.Sprintf("%v", *o.Orderby)) + } + if o.Skip != nil { + out.Append("$skip", fmt.Sprintf("%v", *o.Skip)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +// ListByUser ... +func (c ReportsClient) ListByUser(ctx context.Context, id ServiceId, options ListByUserOperationOptions) (result ListByUserOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/reports/byUser", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ReportRecordContract `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByUserComplete retrieves all the results into a single object +func (c ReportsClient) ListByUserComplete(ctx context.Context, id ServiceId, options ListByUserOperationOptions) (ListByUserCompleteResult, error) { + return c.ListByUserCompleteMatchingPredicate(ctx, id, options, ReportRecordContractOperationPredicate{}) +} + +// ListByUserCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ReportsClient) ListByUserCompleteMatchingPredicate(ctx context.Context, id ServiceId, options ListByUserOperationOptions, predicate ReportRecordContractOperationPredicate) (result ListByUserCompleteResult, err error) { + items := make([]ReportRecordContract, 0) + + resp, err := c.ListByUser(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByUserCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/apimanagement/2022-08-01/reports/method_listbyuser_autorest.go b/resource-manager/apimanagement/2022-08-01/reports/method_listbyuser_autorest.go deleted file mode 100644 index 2bd9f434043..00000000000 --- a/resource-manager/apimanagement/2022-08-01/reports/method_listbyuser_autorest.go +++ /dev/null @@ -1,230 +0,0 @@ -package reports - -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 ListByUserOperationResponse struct { - HttpResponse *http.Response - Model *[]ReportRecordContract - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListByUserOperationResponse, error) -} - -type ListByUserCompleteResult struct { - Items []ReportRecordContract -} - -func (r ListByUserOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListByUserOperationResponse) LoadMore(ctx context.Context) (resp ListByUserOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -type ListByUserOperationOptions struct { - Filter *string - Orderby *string - Skip *int64 - Top *int64 -} - -func DefaultListByUserOperationOptions() ListByUserOperationOptions { - return ListByUserOperationOptions{} -} - -func (o ListByUserOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o ListByUserOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Filter != nil { - out["$filter"] = *o.Filter - } - - if o.Orderby != nil { - out["$orderby"] = *o.Orderby - } - - if o.Skip != nil { - out["$skip"] = *o.Skip - } - - if o.Top != nil { - out["$top"] = *o.Top - } - - return out -} - -// ListByUser ... -func (c ReportsClient) ListByUser(ctx context.Context, id ServiceId, options ListByUserOperationOptions) (resp ListByUserOperationResponse, err error) { - req, err := c.preparerForListByUser(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "reports.ReportsClient", "ListByUser", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "reports.ReportsClient", "ListByUser", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListByUser(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "reports.ReportsClient", "ListByUser", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListByUser prepares the ListByUser request. -func (c ReportsClient) preparerForListByUser(ctx context.Context, id ServiceId, options ListByUserOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/reports/byUser", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListByUserWithNextLink prepares the ListByUser request with the given nextLink token. -func (c ReportsClient) preparerForListByUserWithNextLink(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)) -} - -// responderForListByUser handles the response to the ListByUser request. The method always -// closes the http.Response Body. -func (c ReportsClient) responderForListByUser(resp *http.Response) (result ListByUserOperationResponse, err error) { - type page struct { - Values []ReportRecordContract `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 ListByUserOperationResponse, err error) { - req, err := c.preparerForListByUserWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "reports.ReportsClient", "ListByUser", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "reports.ReportsClient", "ListByUser", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByUser(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "reports.ReportsClient", "ListByUser", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListByUserComplete retrieves all of the results into a single object -func (c ReportsClient) ListByUserComplete(ctx context.Context, id ServiceId, options ListByUserOperationOptions) (ListByUserCompleteResult, error) { - return c.ListByUserCompleteMatchingPredicate(ctx, id, options, ReportRecordContractOperationPredicate{}) -} - -// ListByUserCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c ReportsClient) ListByUserCompleteMatchingPredicate(ctx context.Context, id ServiceId, options ListByUserOperationOptions, predicate ReportRecordContractOperationPredicate) (resp ListByUserCompleteResult, err error) { - items := make([]ReportRecordContract, 0) - - page, err := c.ListByUser(ctx, id, options) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListByUserCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/apimanagement/2022-08-01/schema/client.go b/resource-manager/apimanagement/2022-08-01/schema/client.go index 8905f2ce375..f9692a57f2f 100644 --- a/resource-manager/apimanagement/2022-08-01/schema/client.go +++ b/resource-manager/apimanagement/2022-08-01/schema/client.go @@ -1,18 +1,26 @@ package schema -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 SchemaClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewSchemaClientWithBaseURI(endpoint string) SchemaClient { - return SchemaClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewSchemaClientWithBaseURI(api environments.Api) (*SchemaClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "schema", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating SchemaClient: %+v", err) } + + return &SchemaClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2022-08-01/schema/constants.go b/resource-manager/apimanagement/2022-08-01/schema/constants.go index ab4513e2c37..fc6c0c9faf6 100644 --- a/resource-manager/apimanagement/2022-08-01/schema/constants.go +++ b/resource-manager/apimanagement/2022-08-01/schema/constants.go @@ -1,6 +1,10 @@ package schema -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 PossibleValuesForSchemaType() []string { } } +func (s *SchemaType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSchemaType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseSchemaType(input string) (*SchemaType, error) { vals := map[string]SchemaType{ "json": SchemaTypeJson, diff --git a/resource-manager/apimanagement/2022-08-01/schema/method_globalschemacreateorupdate.go b/resource-manager/apimanagement/2022-08-01/schema/method_globalschemacreateorupdate.go new file mode 100644 index 00000000000..3e9e658a682 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/schema/method_globalschemacreateorupdate.go @@ -0,0 +1,103 @@ +package schema + +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 GlobalSchemaCreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +type GlobalSchemaCreateOrUpdateOperationOptions struct { + IfMatch *string +} + +func DefaultGlobalSchemaCreateOrUpdateOperationOptions() GlobalSchemaCreateOrUpdateOperationOptions { + return GlobalSchemaCreateOrUpdateOperationOptions{} +} + +func (o GlobalSchemaCreateOrUpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o GlobalSchemaCreateOrUpdateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o GlobalSchemaCreateOrUpdateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// GlobalSchemaCreateOrUpdate ... +func (c SchemaClient) GlobalSchemaCreateOrUpdate(ctx context.Context, id SchemaId, input GlobalSchemaContract, options GlobalSchemaCreateOrUpdateOperationOptions) (result GlobalSchemaCreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + OptionsObject: options, + } + + 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 +} + +// GlobalSchemaCreateOrUpdateThenPoll performs GlobalSchemaCreateOrUpdate then polls until it's completed +func (c SchemaClient) GlobalSchemaCreateOrUpdateThenPoll(ctx context.Context, id SchemaId, input GlobalSchemaContract, options GlobalSchemaCreateOrUpdateOperationOptions) error { + result, err := c.GlobalSchemaCreateOrUpdate(ctx, id, input, options) + if err != nil { + return fmt.Errorf("performing GlobalSchemaCreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after GlobalSchemaCreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/apimanagement/2022-08-01/schema/method_globalschemacreateorupdate_autorest.go b/resource-manager/apimanagement/2022-08-01/schema/method_globalschemacreateorupdate_autorest.go deleted file mode 100644 index 169dc63374e..00000000000 --- a/resource-manager/apimanagement/2022-08-01/schema/method_globalschemacreateorupdate_autorest.go +++ /dev/null @@ -1,108 +0,0 @@ -package schema - -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 GlobalSchemaCreateOrUpdateOperationResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -type GlobalSchemaCreateOrUpdateOperationOptions struct { - IfMatch *string -} - -func DefaultGlobalSchemaCreateOrUpdateOperationOptions() GlobalSchemaCreateOrUpdateOperationOptions { - return GlobalSchemaCreateOrUpdateOperationOptions{} -} - -func (o GlobalSchemaCreateOrUpdateOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o GlobalSchemaCreateOrUpdateOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// GlobalSchemaCreateOrUpdate ... -func (c SchemaClient) GlobalSchemaCreateOrUpdate(ctx context.Context, id SchemaId, input GlobalSchemaContract, options GlobalSchemaCreateOrUpdateOperationOptions) (result GlobalSchemaCreateOrUpdateOperationResponse, err error) { - req, err := c.preparerForGlobalSchemaCreateOrUpdate(ctx, id, input, options) - if err != nil { - err = autorest.NewErrorWithError(err, "schema.SchemaClient", "GlobalSchemaCreateOrUpdate", nil, "Failure preparing request") - return - } - - result, err = c.senderForGlobalSchemaCreateOrUpdate(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "schema.SchemaClient", "GlobalSchemaCreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// GlobalSchemaCreateOrUpdateThenPoll performs GlobalSchemaCreateOrUpdate then polls until it's completed -func (c SchemaClient) GlobalSchemaCreateOrUpdateThenPoll(ctx context.Context, id SchemaId, input GlobalSchemaContract, options GlobalSchemaCreateOrUpdateOperationOptions) error { - result, err := c.GlobalSchemaCreateOrUpdate(ctx, id, input, options) - if err != nil { - return fmt.Errorf("performing GlobalSchemaCreateOrUpdate: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after GlobalSchemaCreateOrUpdate: %+v", err) - } - - return nil -} - -// preparerForGlobalSchemaCreateOrUpdate prepares the GlobalSchemaCreateOrUpdate request. -func (c SchemaClient) preparerForGlobalSchemaCreateOrUpdate(ctx context.Context, id SchemaId, input GlobalSchemaContract, options GlobalSchemaCreateOrUpdateOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForGlobalSchemaCreateOrUpdate sends the GlobalSchemaCreateOrUpdate request. The method will close the -// http.Response Body if it receives an error. -func (c SchemaClient) senderForGlobalSchemaCreateOrUpdate(ctx context.Context, req *http.Request) (future GlobalSchemaCreateOrUpdateOperationResponse, 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/apimanagement/2022-08-01/schema/method_globalschemadelete.go b/resource-manager/apimanagement/2022-08-01/schema/method_globalschemadelete.go new file mode 100644 index 00000000000..f7169489c2b --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/schema/method_globalschemadelete.go @@ -0,0 +1,76 @@ +package schema + +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 GlobalSchemaDeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +type GlobalSchemaDeleteOperationOptions struct { + IfMatch *string +} + +func DefaultGlobalSchemaDeleteOperationOptions() GlobalSchemaDeleteOperationOptions { + return GlobalSchemaDeleteOperationOptions{} +} + +func (o GlobalSchemaDeleteOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o GlobalSchemaDeleteOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o GlobalSchemaDeleteOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// GlobalSchemaDelete ... +func (c SchemaClient) GlobalSchemaDelete(ctx context.Context, id SchemaId, options GlobalSchemaDeleteOperationOptions) (result GlobalSchemaDeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2022-08-01/schema/method_globalschemadelete_autorest.go b/resource-manager/apimanagement/2022-08-01/schema/method_globalschemadelete_autorest.go deleted file mode 100644 index ec3f0417e40..00000000000 --- a/resource-manager/apimanagement/2022-08-01/schema/method_globalschemadelete_autorest.go +++ /dev/null @@ -1,95 +0,0 @@ -package schema - -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 GlobalSchemaDeleteOperationResponse struct { - HttpResponse *http.Response -} - -type GlobalSchemaDeleteOperationOptions struct { - IfMatch *string -} - -func DefaultGlobalSchemaDeleteOperationOptions() GlobalSchemaDeleteOperationOptions { - return GlobalSchemaDeleteOperationOptions{} -} - -func (o GlobalSchemaDeleteOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o GlobalSchemaDeleteOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// GlobalSchemaDelete ... -func (c SchemaClient) GlobalSchemaDelete(ctx context.Context, id SchemaId, options GlobalSchemaDeleteOperationOptions) (result GlobalSchemaDeleteOperationResponse, err error) { - req, err := c.preparerForGlobalSchemaDelete(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "schema.SchemaClient", "GlobalSchemaDelete", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "schema.SchemaClient", "GlobalSchemaDelete", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGlobalSchemaDelete(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "schema.SchemaClient", "GlobalSchemaDelete", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGlobalSchemaDelete prepares the GlobalSchemaDelete request. -func (c SchemaClient) preparerForGlobalSchemaDelete(ctx context.Context, id SchemaId, options GlobalSchemaDeleteOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGlobalSchemaDelete handles the response to the GlobalSchemaDelete request. The method always -// closes the http.Response Body. -func (c SchemaClient) responderForGlobalSchemaDelete(resp *http.Response) (result GlobalSchemaDeleteOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2022-08-01/schema/method_globalschemaget.go b/resource-manager/apimanagement/2022-08-01/schema/method_globalschemaget.go new file mode 100644 index 00000000000..3d7e9fd46ef --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/schema/method_globalschemaget.go @@ -0,0 +1,51 @@ +package schema + +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 GlobalSchemaGetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *GlobalSchemaContract +} + +// GlobalSchemaGet ... +func (c SchemaClient) GlobalSchemaGet(ctx context.Context, id SchemaId) (result GlobalSchemaGetOperationResponse, 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/apimanagement/2022-08-01/schema/method_globalschemaget_autorest.go b/resource-manager/apimanagement/2022-08-01/schema/method_globalschemaget_autorest.go deleted file mode 100644 index d87e67a9d30..00000000000 --- a/resource-manager/apimanagement/2022-08-01/schema/method_globalschemaget_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package schema - -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 GlobalSchemaGetOperationResponse struct { - HttpResponse *http.Response - Model *GlobalSchemaContract -} - -// GlobalSchemaGet ... -func (c SchemaClient) GlobalSchemaGet(ctx context.Context, id SchemaId) (result GlobalSchemaGetOperationResponse, err error) { - req, err := c.preparerForGlobalSchemaGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "schema.SchemaClient", "GlobalSchemaGet", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "schema.SchemaClient", "GlobalSchemaGet", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGlobalSchemaGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "schema.SchemaClient", "GlobalSchemaGet", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGlobalSchemaGet prepares the GlobalSchemaGet request. -func (c SchemaClient) preparerForGlobalSchemaGet(ctx context.Context, id SchemaId) (*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)) -} - -// responderForGlobalSchemaGet handles the response to the GlobalSchemaGet request. The method always -// closes the http.Response Body. -func (c SchemaClient) responderForGlobalSchemaGet(resp *http.Response) (result GlobalSchemaGetOperationResponse, 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/apimanagement/2022-08-01/schema/method_globalschemagetentitytag.go b/resource-manager/apimanagement/2022-08-01/schema/method_globalschemagetentitytag.go new file mode 100644 index 00000000000..b62a3956afc --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/schema/method_globalschemagetentitytag.go @@ -0,0 +1,46 @@ +package schema + +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 GlobalSchemaGetEntityTagOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// GlobalSchemaGetEntityTag ... +func (c SchemaClient) GlobalSchemaGetEntityTag(ctx context.Context, id SchemaId) (result GlobalSchemaGetEntityTagOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodHead, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2022-08-01/schema/method_globalschemagetentitytag_autorest.go b/resource-manager/apimanagement/2022-08-01/schema/method_globalschemagetentitytag_autorest.go deleted file mode 100644 index a02a95a3402..00000000000 --- a/resource-manager/apimanagement/2022-08-01/schema/method_globalschemagetentitytag_autorest.go +++ /dev/null @@ -1,66 +0,0 @@ -package schema - -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 GlobalSchemaGetEntityTagOperationResponse struct { - HttpResponse *http.Response -} - -// GlobalSchemaGetEntityTag ... -func (c SchemaClient) GlobalSchemaGetEntityTag(ctx context.Context, id SchemaId) (result GlobalSchemaGetEntityTagOperationResponse, err error) { - req, err := c.preparerForGlobalSchemaGetEntityTag(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "schema.SchemaClient", "GlobalSchemaGetEntityTag", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "schema.SchemaClient", "GlobalSchemaGetEntityTag", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGlobalSchemaGetEntityTag(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "schema.SchemaClient", "GlobalSchemaGetEntityTag", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGlobalSchemaGetEntityTag prepares the GlobalSchemaGetEntityTag request. -func (c SchemaClient) preparerForGlobalSchemaGetEntityTag(ctx context.Context, id SchemaId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsHead(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGlobalSchemaGetEntityTag handles the response to the GlobalSchemaGetEntityTag request. The method always -// closes the http.Response Body. -func (c SchemaClient) responderForGlobalSchemaGetEntityTag(resp *http.Response) (result GlobalSchemaGetEntityTagOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2022-08-01/schema/method_globalschemalistbyservice.go b/resource-manager/apimanagement/2022-08-01/schema/method_globalschemalistbyservice.go new file mode 100644 index 00000000000..739c27caee5 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/schema/method_globalschemalistbyservice.go @@ -0,0 +1,125 @@ +package schema + +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 GlobalSchemaListByServiceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]GlobalSchemaContract +} + +type GlobalSchemaListByServiceCompleteResult struct { + Items []GlobalSchemaContract +} + +type GlobalSchemaListByServiceOperationOptions struct { + Filter *string + Skip *int64 + Top *int64 +} + +func DefaultGlobalSchemaListByServiceOperationOptions() GlobalSchemaListByServiceOperationOptions { + return GlobalSchemaListByServiceOperationOptions{} +} + +func (o GlobalSchemaListByServiceOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o GlobalSchemaListByServiceOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o GlobalSchemaListByServiceOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.Skip != nil { + out.Append("$skip", fmt.Sprintf("%v", *o.Skip)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +// GlobalSchemaListByService ... +func (c SchemaClient) GlobalSchemaListByService(ctx context.Context, id ServiceId, options GlobalSchemaListByServiceOperationOptions) (result GlobalSchemaListByServiceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/schemas", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]GlobalSchemaContract `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// GlobalSchemaListByServiceComplete retrieves all the results into a single object +func (c SchemaClient) GlobalSchemaListByServiceComplete(ctx context.Context, id ServiceId, options GlobalSchemaListByServiceOperationOptions) (GlobalSchemaListByServiceCompleteResult, error) { + return c.GlobalSchemaListByServiceCompleteMatchingPredicate(ctx, id, options, GlobalSchemaContractOperationPredicate{}) +} + +// GlobalSchemaListByServiceCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c SchemaClient) GlobalSchemaListByServiceCompleteMatchingPredicate(ctx context.Context, id ServiceId, options GlobalSchemaListByServiceOperationOptions, predicate GlobalSchemaContractOperationPredicate) (result GlobalSchemaListByServiceCompleteResult, err error) { + items := make([]GlobalSchemaContract, 0) + + resp, err := c.GlobalSchemaListByService(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = GlobalSchemaListByServiceCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/apimanagement/2022-08-01/schema/method_globalschemalistbyservice_autorest.go b/resource-manager/apimanagement/2022-08-01/schema/method_globalschemalistbyservice_autorest.go deleted file mode 100644 index f69bb14a594..00000000000 --- a/resource-manager/apimanagement/2022-08-01/schema/method_globalschemalistbyservice_autorest.go +++ /dev/null @@ -1,225 +0,0 @@ -package schema - -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 GlobalSchemaListByServiceOperationResponse struct { - HttpResponse *http.Response - Model *[]GlobalSchemaContract - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (GlobalSchemaListByServiceOperationResponse, error) -} - -type GlobalSchemaListByServiceCompleteResult struct { - Items []GlobalSchemaContract -} - -func (r GlobalSchemaListByServiceOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r GlobalSchemaListByServiceOperationResponse) LoadMore(ctx context.Context) (resp GlobalSchemaListByServiceOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -type GlobalSchemaListByServiceOperationOptions struct { - Filter *string - Skip *int64 - Top *int64 -} - -func DefaultGlobalSchemaListByServiceOperationOptions() GlobalSchemaListByServiceOperationOptions { - return GlobalSchemaListByServiceOperationOptions{} -} - -func (o GlobalSchemaListByServiceOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o GlobalSchemaListByServiceOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Filter != nil { - out["$filter"] = *o.Filter - } - - if o.Skip != nil { - out["$skip"] = *o.Skip - } - - if o.Top != nil { - out["$top"] = *o.Top - } - - return out -} - -// GlobalSchemaListByService ... -func (c SchemaClient) GlobalSchemaListByService(ctx context.Context, id ServiceId, options GlobalSchemaListByServiceOperationOptions) (resp GlobalSchemaListByServiceOperationResponse, err error) { - req, err := c.preparerForGlobalSchemaListByService(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "schema.SchemaClient", "GlobalSchemaListByService", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "schema.SchemaClient", "GlobalSchemaListByService", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForGlobalSchemaListByService(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "schema.SchemaClient", "GlobalSchemaListByService", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForGlobalSchemaListByService prepares the GlobalSchemaListByService request. -func (c SchemaClient) preparerForGlobalSchemaListByService(ctx context.Context, id ServiceId, options GlobalSchemaListByServiceOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/schemas", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForGlobalSchemaListByServiceWithNextLink prepares the GlobalSchemaListByService request with the given nextLink token. -func (c SchemaClient) preparerForGlobalSchemaListByServiceWithNextLink(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)) -} - -// responderForGlobalSchemaListByService handles the response to the GlobalSchemaListByService request. The method always -// closes the http.Response Body. -func (c SchemaClient) responderForGlobalSchemaListByService(resp *http.Response) (result GlobalSchemaListByServiceOperationResponse, err error) { - type page struct { - Values []GlobalSchemaContract `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 GlobalSchemaListByServiceOperationResponse, err error) { - req, err := c.preparerForGlobalSchemaListByServiceWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "schema.SchemaClient", "GlobalSchemaListByService", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "schema.SchemaClient", "GlobalSchemaListByService", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGlobalSchemaListByService(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "schema.SchemaClient", "GlobalSchemaListByService", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// GlobalSchemaListByServiceComplete retrieves all of the results into a single object -func (c SchemaClient) GlobalSchemaListByServiceComplete(ctx context.Context, id ServiceId, options GlobalSchemaListByServiceOperationOptions) (GlobalSchemaListByServiceCompleteResult, error) { - return c.GlobalSchemaListByServiceCompleteMatchingPredicate(ctx, id, options, GlobalSchemaContractOperationPredicate{}) -} - -// GlobalSchemaListByServiceCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c SchemaClient) GlobalSchemaListByServiceCompleteMatchingPredicate(ctx context.Context, id ServiceId, options GlobalSchemaListByServiceOperationOptions, predicate GlobalSchemaContractOperationPredicate) (resp GlobalSchemaListByServiceCompleteResult, err error) { - items := make([]GlobalSchemaContract, 0) - - page, err := c.GlobalSchemaListByService(ctx, id, options) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := GlobalSchemaListByServiceCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/apimanagement/2022-08-01/signinsettings/client.go b/resource-manager/apimanagement/2022-08-01/signinsettings/client.go index b4213de27ba..56dc4b1871a 100644 --- a/resource-manager/apimanagement/2022-08-01/signinsettings/client.go +++ b/resource-manager/apimanagement/2022-08-01/signinsettings/client.go @@ -1,18 +1,26 @@ package signinsettings -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 SignInSettingsClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewSignInSettingsClientWithBaseURI(endpoint string) SignInSettingsClient { - return SignInSettingsClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewSignInSettingsClientWithBaseURI(api environments.Api) (*SignInSettingsClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "signinsettings", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating SignInSettingsClient: %+v", err) } + + return &SignInSettingsClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2022-08-01/signinsettings/method_createorupdate.go b/resource-manager/apimanagement/2022-08-01/signinsettings/method_createorupdate.go new file mode 100644 index 00000000000..7b9767c2fbe --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/signinsettings/method_createorupdate.go @@ -0,0 +1,84 @@ +package signinsettings + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PortalSigninSettings +} + +type CreateOrUpdateOperationOptions struct { + IfMatch *string +} + +func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { + return CreateOrUpdateOperationOptions{} +} + +func (o CreateOrUpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o CreateOrUpdateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o CreateOrUpdateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// CreateOrUpdate ... +func (c SignInSettingsClient) CreateOrUpdate(ctx context.Context, id ServiceId, input PortalSigninSettings, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/portalsettings/signin", id.ID()), + OptionsObject: options, + } + + 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/apimanagement/2022-08-01/signinsettings/method_createorupdate_autorest.go b/resource-manager/apimanagement/2022-08-01/signinsettings/method_createorupdate_autorest.go deleted file mode 100644 index b4f0296beba..00000000000 --- a/resource-manager/apimanagement/2022-08-01/signinsettings/method_createorupdate_autorest.go +++ /dev/null @@ -1,99 +0,0 @@ -package signinsettings - -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 CreateOrUpdateOperationResponse struct { - HttpResponse *http.Response - Model *PortalSigninSettings -} - -type CreateOrUpdateOperationOptions struct { - IfMatch *string -} - -func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { - return CreateOrUpdateOperationOptions{} -} - -func (o CreateOrUpdateOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o CreateOrUpdateOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// CreateOrUpdate ... -func (c SignInSettingsClient) CreateOrUpdate(ctx context.Context, id ServiceId, input PortalSigninSettings, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdate(ctx, id, input, options) - if err != nil { - err = autorest.NewErrorWithError(err, "signinsettings.SignInSettingsClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "signinsettings.SignInSettingsClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCreateOrUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "signinsettings.SignInSettingsClient", "CreateOrUpdate", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCreateOrUpdate prepares the CreateOrUpdate request. -func (c SignInSettingsClient) preparerForCreateOrUpdate(ctx context.Context, id ServiceId, input PortalSigninSettings, options CreateOrUpdateOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/portalsettings/signin", 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 SignInSettingsClient) 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/apimanagement/2022-08-01/signinsettings/method_get.go b/resource-manager/apimanagement/2022-08-01/signinsettings/method_get.go new file mode 100644 index 00000000000..173524f6cc7 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/signinsettings/method_get.go @@ -0,0 +1,52 @@ +package signinsettings + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PortalSigninSettings +} + +// Get ... +func (c SignInSettingsClient) 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: fmt.Sprintf("%s/portalsettings/signin", 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/apimanagement/2022-08-01/signinsettings/method_get_autorest.go b/resource-manager/apimanagement/2022-08-01/signinsettings/method_get_autorest.go deleted file mode 100644 index 3ac4891a75c..00000000000 --- a/resource-manager/apimanagement/2022-08-01/signinsettings/method_get_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package signinsettings - -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 GetOperationResponse struct { - HttpResponse *http.Response - Model *PortalSigninSettings -} - -// Get ... -func (c SignInSettingsClient) Get(ctx context.Context, id ServiceId) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "signinsettings.SignInSettingsClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "signinsettings.SignInSettingsClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "signinsettings.SignInSettingsClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c SignInSettingsClient) 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(fmt.Sprintf("%s/portalsettings/signin", 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 SignInSettingsClient) 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/apimanagement/2022-08-01/signinsettings/method_getentitytag.go b/resource-manager/apimanagement/2022-08-01/signinsettings/method_getentitytag.go new file mode 100644 index 00000000000..25861ccf2a4 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/signinsettings/method_getentitytag.go @@ -0,0 +1,47 @@ +package signinsettings + +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 GetEntityTagOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// GetEntityTag ... +func (c SignInSettingsClient) GetEntityTag(ctx context.Context, id ServiceId) (result GetEntityTagOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodHead, + Path: fmt.Sprintf("%s/portalsettings/signin", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2022-08-01/signinsettings/method_getentitytag_autorest.go b/resource-manager/apimanagement/2022-08-01/signinsettings/method_getentitytag_autorest.go deleted file mode 100644 index 1209ff66c99..00000000000 --- a/resource-manager/apimanagement/2022-08-01/signinsettings/method_getentitytag_autorest.go +++ /dev/null @@ -1,67 +0,0 @@ -package signinsettings - -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 GetEntityTagOperationResponse struct { - HttpResponse *http.Response -} - -// GetEntityTag ... -func (c SignInSettingsClient) GetEntityTag(ctx context.Context, id ServiceId) (result GetEntityTagOperationResponse, err error) { - req, err := c.preparerForGetEntityTag(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "signinsettings.SignInSettingsClient", "GetEntityTag", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "signinsettings.SignInSettingsClient", "GetEntityTag", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetEntityTag(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "signinsettings.SignInSettingsClient", "GetEntityTag", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetEntityTag prepares the GetEntityTag request. -func (c SignInSettingsClient) preparerForGetEntityTag(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.AsHead(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/portalsettings/signin", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetEntityTag handles the response to the GetEntityTag request. The method always -// closes the http.Response Body. -func (c SignInSettingsClient) responderForGetEntityTag(resp *http.Response) (result GetEntityTagOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2022-08-01/signinsettings/method_update.go b/resource-manager/apimanagement/2022-08-01/signinsettings/method_update.go new file mode 100644 index 00000000000..cdef3702ed0 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/signinsettings/method_update.go @@ -0,0 +1,79 @@ +package signinsettings + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +type UpdateOperationOptions struct { + IfMatch *string +} + +func DefaultUpdateOperationOptions() UpdateOperationOptions { + return UpdateOperationOptions{} +} + +func (o UpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o UpdateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o UpdateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// Update ... +func (c SignInSettingsClient) Update(ctx context.Context, id ServiceId, input PortalSigninSettings, options UpdateOperationOptions) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: http.MethodPatch, + Path: fmt.Sprintf("%s/portalsettings/signin", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2022-08-01/signinsettings/method_update_autorest.go b/resource-manager/apimanagement/2022-08-01/signinsettings/method_update_autorest.go deleted file mode 100644 index 0a95b9f7fa1..00000000000 --- a/resource-manager/apimanagement/2022-08-01/signinsettings/method_update_autorest.go +++ /dev/null @@ -1,97 +0,0 @@ -package signinsettings - -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 UpdateOperationResponse struct { - HttpResponse *http.Response -} - -type UpdateOperationOptions struct { - IfMatch *string -} - -func DefaultUpdateOperationOptions() UpdateOperationOptions { - return UpdateOperationOptions{} -} - -func (o UpdateOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o UpdateOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// Update ... -func (c SignInSettingsClient) Update(ctx context.Context, id ServiceId, input PortalSigninSettings, options UpdateOperationOptions) (result UpdateOperationResponse, err error) { - req, err := c.preparerForUpdate(ctx, id, input, options) - if err != nil { - err = autorest.NewErrorWithError(err, "signinsettings.SignInSettingsClient", "Update", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "signinsettings.SignInSettingsClient", "Update", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "signinsettings.SignInSettingsClient", "Update", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForUpdate prepares the Update request. -func (c SignInSettingsClient) preparerForUpdate(ctx context.Context, id ServiceId, input PortalSigninSettings, options UpdateOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPatch(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/portalsettings/signin", 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 SignInSettingsClient) responderForUpdate(resp *http.Response) (result UpdateOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2022-08-01/signupsettings/client.go b/resource-manager/apimanagement/2022-08-01/signupsettings/client.go index 539431c37b7..2926b188065 100644 --- a/resource-manager/apimanagement/2022-08-01/signupsettings/client.go +++ b/resource-manager/apimanagement/2022-08-01/signupsettings/client.go @@ -1,18 +1,26 @@ package signupsettings -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 SignUpSettingsClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewSignUpSettingsClientWithBaseURI(endpoint string) SignUpSettingsClient { - return SignUpSettingsClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewSignUpSettingsClientWithBaseURI(api environments.Api) (*SignUpSettingsClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "signupsettings", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating SignUpSettingsClient: %+v", err) } + + return &SignUpSettingsClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2022-08-01/signupsettings/method_createorupdate.go b/resource-manager/apimanagement/2022-08-01/signupsettings/method_createorupdate.go new file mode 100644 index 00000000000..7269ad66a33 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/signupsettings/method_createorupdate.go @@ -0,0 +1,84 @@ +package signupsettings + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PortalSignupSettings +} + +type CreateOrUpdateOperationOptions struct { + IfMatch *string +} + +func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { + return CreateOrUpdateOperationOptions{} +} + +func (o CreateOrUpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o CreateOrUpdateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o CreateOrUpdateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// CreateOrUpdate ... +func (c SignUpSettingsClient) CreateOrUpdate(ctx context.Context, id ServiceId, input PortalSignupSettings, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/portalsettings/signup", id.ID()), + OptionsObject: options, + } + + 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/apimanagement/2022-08-01/signupsettings/method_createorupdate_autorest.go b/resource-manager/apimanagement/2022-08-01/signupsettings/method_createorupdate_autorest.go deleted file mode 100644 index 096041ff364..00000000000 --- a/resource-manager/apimanagement/2022-08-01/signupsettings/method_createorupdate_autorest.go +++ /dev/null @@ -1,99 +0,0 @@ -package signupsettings - -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 CreateOrUpdateOperationResponse struct { - HttpResponse *http.Response - Model *PortalSignupSettings -} - -type CreateOrUpdateOperationOptions struct { - IfMatch *string -} - -func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { - return CreateOrUpdateOperationOptions{} -} - -func (o CreateOrUpdateOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o CreateOrUpdateOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// CreateOrUpdate ... -func (c SignUpSettingsClient) CreateOrUpdate(ctx context.Context, id ServiceId, input PortalSignupSettings, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdate(ctx, id, input, options) - if err != nil { - err = autorest.NewErrorWithError(err, "signupsettings.SignUpSettingsClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "signupsettings.SignUpSettingsClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCreateOrUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "signupsettings.SignUpSettingsClient", "CreateOrUpdate", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCreateOrUpdate prepares the CreateOrUpdate request. -func (c SignUpSettingsClient) preparerForCreateOrUpdate(ctx context.Context, id ServiceId, input PortalSignupSettings, options CreateOrUpdateOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/portalsettings/signup", 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 SignUpSettingsClient) 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/apimanagement/2022-08-01/signupsettings/method_get.go b/resource-manager/apimanagement/2022-08-01/signupsettings/method_get.go new file mode 100644 index 00000000000..9c83e5e83ec --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/signupsettings/method_get.go @@ -0,0 +1,52 @@ +package signupsettings + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PortalSignupSettings +} + +// Get ... +func (c SignUpSettingsClient) 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: fmt.Sprintf("%s/portalsettings/signup", 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/apimanagement/2022-08-01/signupsettings/method_get_autorest.go b/resource-manager/apimanagement/2022-08-01/signupsettings/method_get_autorest.go deleted file mode 100644 index 0f67ad8685a..00000000000 --- a/resource-manager/apimanagement/2022-08-01/signupsettings/method_get_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package signupsettings - -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 GetOperationResponse struct { - HttpResponse *http.Response - Model *PortalSignupSettings -} - -// Get ... -func (c SignUpSettingsClient) Get(ctx context.Context, id ServiceId) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "signupsettings.SignUpSettingsClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "signupsettings.SignUpSettingsClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "signupsettings.SignUpSettingsClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c SignUpSettingsClient) 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(fmt.Sprintf("%s/portalsettings/signup", 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 SignUpSettingsClient) 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/apimanagement/2022-08-01/signupsettings/method_getentitytag.go b/resource-manager/apimanagement/2022-08-01/signupsettings/method_getentitytag.go new file mode 100644 index 00000000000..c664f2c2ea8 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/signupsettings/method_getentitytag.go @@ -0,0 +1,47 @@ +package signupsettings + +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 GetEntityTagOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// GetEntityTag ... +func (c SignUpSettingsClient) GetEntityTag(ctx context.Context, id ServiceId) (result GetEntityTagOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodHead, + Path: fmt.Sprintf("%s/portalsettings/signup", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2022-08-01/signupsettings/method_getentitytag_autorest.go b/resource-manager/apimanagement/2022-08-01/signupsettings/method_getentitytag_autorest.go deleted file mode 100644 index 3fa59c81432..00000000000 --- a/resource-manager/apimanagement/2022-08-01/signupsettings/method_getentitytag_autorest.go +++ /dev/null @@ -1,67 +0,0 @@ -package signupsettings - -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 GetEntityTagOperationResponse struct { - HttpResponse *http.Response -} - -// GetEntityTag ... -func (c SignUpSettingsClient) GetEntityTag(ctx context.Context, id ServiceId) (result GetEntityTagOperationResponse, err error) { - req, err := c.preparerForGetEntityTag(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "signupsettings.SignUpSettingsClient", "GetEntityTag", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "signupsettings.SignUpSettingsClient", "GetEntityTag", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetEntityTag(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "signupsettings.SignUpSettingsClient", "GetEntityTag", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetEntityTag prepares the GetEntityTag request. -func (c SignUpSettingsClient) preparerForGetEntityTag(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.AsHead(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/portalsettings/signup", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetEntityTag handles the response to the GetEntityTag request. The method always -// closes the http.Response Body. -func (c SignUpSettingsClient) responderForGetEntityTag(resp *http.Response) (result GetEntityTagOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2022-08-01/signupsettings/method_update.go b/resource-manager/apimanagement/2022-08-01/signupsettings/method_update.go new file mode 100644 index 00000000000..fd56de21870 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/signupsettings/method_update.go @@ -0,0 +1,79 @@ +package signupsettings + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +type UpdateOperationOptions struct { + IfMatch *string +} + +func DefaultUpdateOperationOptions() UpdateOperationOptions { + return UpdateOperationOptions{} +} + +func (o UpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o UpdateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o UpdateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// Update ... +func (c SignUpSettingsClient) Update(ctx context.Context, id ServiceId, input PortalSignupSettings, options UpdateOperationOptions) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: http.MethodPatch, + Path: fmt.Sprintf("%s/portalsettings/signup", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2022-08-01/signupsettings/method_update_autorest.go b/resource-manager/apimanagement/2022-08-01/signupsettings/method_update_autorest.go deleted file mode 100644 index 6ab1c8cf856..00000000000 --- a/resource-manager/apimanagement/2022-08-01/signupsettings/method_update_autorest.go +++ /dev/null @@ -1,97 +0,0 @@ -package signupsettings - -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 UpdateOperationResponse struct { - HttpResponse *http.Response -} - -type UpdateOperationOptions struct { - IfMatch *string -} - -func DefaultUpdateOperationOptions() UpdateOperationOptions { - return UpdateOperationOptions{} -} - -func (o UpdateOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o UpdateOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// Update ... -func (c SignUpSettingsClient) Update(ctx context.Context, id ServiceId, input PortalSignupSettings, options UpdateOperationOptions) (result UpdateOperationResponse, err error) { - req, err := c.preparerForUpdate(ctx, id, input, options) - if err != nil { - err = autorest.NewErrorWithError(err, "signupsettings.SignUpSettingsClient", "Update", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "signupsettings.SignUpSettingsClient", "Update", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "signupsettings.SignUpSettingsClient", "Update", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForUpdate prepares the Update request. -func (c SignUpSettingsClient) preparerForUpdate(ctx context.Context, id ServiceId, input PortalSignupSettings, options UpdateOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPatch(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/portalsettings/signup", 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 SignUpSettingsClient) responderForUpdate(resp *http.Response) (result UpdateOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2022-08-01/skus/client.go b/resource-manager/apimanagement/2022-08-01/skus/client.go index bb4f8409006..a561bc4ec71 100644 --- a/resource-manager/apimanagement/2022-08-01/skus/client.go +++ b/resource-manager/apimanagement/2022-08-01/skus/client.go @@ -1,18 +1,26 @@ package skus -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 SkusClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewSkusClientWithBaseURI(endpoint string) SkusClient { - return SkusClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewSkusClientWithBaseURI(api environments.Api) (*SkusClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "skus", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating SkusClient: %+v", err) } + + return &SkusClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2022-08-01/skus/constants.go b/resource-manager/apimanagement/2022-08-01/skus/constants.go index 0e5b4b734b7..97daf30eeec 100644 --- a/resource-manager/apimanagement/2022-08-01/skus/constants.go +++ b/resource-manager/apimanagement/2022-08-01/skus/constants.go @@ -1,6 +1,10 @@ package skus -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 PossibleValuesForApiManagementSkuCapacityScaleType() []string { } } +func (s *ApiManagementSkuCapacityScaleType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseApiManagementSkuCapacityScaleType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseApiManagementSkuCapacityScaleType(input string) (*ApiManagementSkuCapacityScaleType, error) { vals := map[string]ApiManagementSkuCapacityScaleType{ "automatic": ApiManagementSkuCapacityScaleTypeAutomatic, @@ -50,6 +67,19 @@ func PossibleValuesForApiManagementSkuRestrictionsReasonCode() []string { } } +func (s *ApiManagementSkuRestrictionsReasonCode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseApiManagementSkuRestrictionsReasonCode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseApiManagementSkuRestrictionsReasonCode(input string) (*ApiManagementSkuRestrictionsReasonCode, error) { vals := map[string]ApiManagementSkuRestrictionsReasonCode{ "notavailableforsubscription": ApiManagementSkuRestrictionsReasonCodeNotAvailableForSubscription, @@ -78,6 +108,19 @@ func PossibleValuesForApiManagementSkuRestrictionsType() []string { } } +func (s *ApiManagementSkuRestrictionsType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseApiManagementSkuRestrictionsType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseApiManagementSkuRestrictionsType(input string) (*ApiManagementSkuRestrictionsType, error) { vals := map[string]ApiManagementSkuRestrictionsType{ "location": ApiManagementSkuRestrictionsTypeLocation, diff --git a/resource-manager/apimanagement/2022-08-01/skus/method_apimanagementskuslist.go b/resource-manager/apimanagement/2022-08-01/skus/method_apimanagementskuslist.go new file mode 100644 index 00000000000..4818d802b31 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/skus/method_apimanagementskuslist.go @@ -0,0 +1,90 @@ +package skus + +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 ApiManagementSkusListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ApiManagementSku +} + +type ApiManagementSkusListCompleteResult struct { + Items []ApiManagementSku +} + +// ApiManagementSkusList ... +func (c SkusClient) ApiManagementSkusList(ctx context.Context, id commonids.SubscriptionId) (result ApiManagementSkusListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.ApiManagement/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 *[]ApiManagementSku `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ApiManagementSkusListComplete retrieves all the results into a single object +func (c SkusClient) ApiManagementSkusListComplete(ctx context.Context, id commonids.SubscriptionId) (ApiManagementSkusListCompleteResult, error) { + return c.ApiManagementSkusListCompleteMatchingPredicate(ctx, id, ApiManagementSkuOperationPredicate{}) +} + +// ApiManagementSkusListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c SkusClient) ApiManagementSkusListCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate ApiManagementSkuOperationPredicate) (result ApiManagementSkusListCompleteResult, err error) { + items := make([]ApiManagementSku, 0) + + resp, err := c.ApiManagementSkusList(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 = ApiManagementSkusListCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/apimanagement/2022-08-01/skus/method_apimanagementskuslist_autorest.go b/resource-manager/apimanagement/2022-08-01/skus/method_apimanagementskuslist_autorest.go deleted file mode 100644 index d9bb79afd90..00000000000 --- a/resource-manager/apimanagement/2022-08-01/skus/method_apimanagementskuslist_autorest.go +++ /dev/null @@ -1,187 +0,0 @@ -package skus - -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 ApiManagementSkusListOperationResponse struct { - HttpResponse *http.Response - Model *[]ApiManagementSku - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ApiManagementSkusListOperationResponse, error) -} - -type ApiManagementSkusListCompleteResult struct { - Items []ApiManagementSku -} - -func (r ApiManagementSkusListOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ApiManagementSkusListOperationResponse) LoadMore(ctx context.Context) (resp ApiManagementSkusListOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ApiManagementSkusList ... -func (c SkusClient) ApiManagementSkusList(ctx context.Context, id commonids.SubscriptionId) (resp ApiManagementSkusListOperationResponse, err error) { - req, err := c.preparerForApiManagementSkusList(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "skus.SkusClient", "ApiManagementSkusList", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "skus.SkusClient", "ApiManagementSkusList", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForApiManagementSkusList(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "skus.SkusClient", "ApiManagementSkusList", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForApiManagementSkusList prepares the ApiManagementSkusList request. -func (c SkusClient) preparerForApiManagementSkusList(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.ApiManagement/skus", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForApiManagementSkusListWithNextLink prepares the ApiManagementSkusList request with the given nextLink token. -func (c SkusClient) preparerForApiManagementSkusListWithNextLink(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)) -} - -// responderForApiManagementSkusList handles the response to the ApiManagementSkusList request. The method always -// closes the http.Response Body. -func (c SkusClient) responderForApiManagementSkusList(resp *http.Response) (result ApiManagementSkusListOperationResponse, err error) { - type page struct { - Values []ApiManagementSku `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 ApiManagementSkusListOperationResponse, err error) { - req, err := c.preparerForApiManagementSkusListWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "skus.SkusClient", "ApiManagementSkusList", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "skus.SkusClient", "ApiManagementSkusList", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForApiManagementSkusList(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "skus.SkusClient", "ApiManagementSkusList", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ApiManagementSkusListComplete retrieves all of the results into a single object -func (c SkusClient) ApiManagementSkusListComplete(ctx context.Context, id commonids.SubscriptionId) (ApiManagementSkusListCompleteResult, error) { - return c.ApiManagementSkusListCompleteMatchingPredicate(ctx, id, ApiManagementSkuOperationPredicate{}) -} - -// ApiManagementSkusListCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c SkusClient) ApiManagementSkusListCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate ApiManagementSkuOperationPredicate) (resp ApiManagementSkusListCompleteResult, err error) { - items := make([]ApiManagementSku, 0) - - page, err := c.ApiManagementSkusList(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 := ApiManagementSkusListCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/apimanagement/2022-08-01/subscription/client.go b/resource-manager/apimanagement/2022-08-01/subscription/client.go index 9b6b77e38d7..da411d23aaa 100644 --- a/resource-manager/apimanagement/2022-08-01/subscription/client.go +++ b/resource-manager/apimanagement/2022-08-01/subscription/client.go @@ -1,18 +1,26 @@ package subscription -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 SubscriptionClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewSubscriptionClientWithBaseURI(endpoint string) SubscriptionClient { - return SubscriptionClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewSubscriptionClientWithBaseURI(api environments.Api) (*SubscriptionClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "subscription", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating SubscriptionClient: %+v", err) } + + return &SubscriptionClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2022-08-01/subscription/constants.go b/resource-manager/apimanagement/2022-08-01/subscription/constants.go index 720ab13b7df..71ac415eaca 100644 --- a/resource-manager/apimanagement/2022-08-01/subscription/constants.go +++ b/resource-manager/apimanagement/2022-08-01/subscription/constants.go @@ -1,6 +1,10 @@ package subscription -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 PossibleValuesForAppType() []string { } } +func (s *AppType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAppType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseAppType(input string) (*AppType, error) { vals := map[string]AppType{ "developerportal": AppTypeDeveloperPortal, @@ -55,6 +72,19 @@ func PossibleValuesForSubscriptionState() []string { } } +func (s *SubscriptionState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSubscriptionState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseSubscriptionState(input string) (*SubscriptionState, error) { vals := map[string]SubscriptionState{ "active": SubscriptionStateActive, diff --git a/resource-manager/apimanagement/2022-08-01/subscription/method_createorupdate.go b/resource-manager/apimanagement/2022-08-01/subscription/method_createorupdate.go new file mode 100644 index 00000000000..d69e1efca03 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/subscription/method_createorupdate.go @@ -0,0 +1,92 @@ +package subscription + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SubscriptionContract +} + +type CreateOrUpdateOperationOptions struct { + AppType *AppType + IfMatch *string + Notify *bool +} + +func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { + return CreateOrUpdateOperationOptions{} +} + +func (o CreateOrUpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o CreateOrUpdateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o CreateOrUpdateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.AppType != nil { + out.Append("appType", fmt.Sprintf("%v", *o.AppType)) + } + if o.Notify != nil { + out.Append("notify", fmt.Sprintf("%v", *o.Notify)) + } + return &out +} + +// CreateOrUpdate ... +func (c SubscriptionClient) CreateOrUpdate(ctx context.Context, id Subscriptions2Id, input SubscriptionCreateParameters, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + OptionsObject: options, + } + + 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/apimanagement/2022-08-01/subscription/method_createorupdate_autorest.go b/resource-manager/apimanagement/2022-08-01/subscription/method_createorupdate_autorest.go deleted file mode 100644 index a0ed6895a04..00000000000 --- a/resource-manager/apimanagement/2022-08-01/subscription/method_createorupdate_autorest.go +++ /dev/null @@ -1,108 +0,0 @@ -package subscription - -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 *SubscriptionContract -} - -type CreateOrUpdateOperationOptions struct { - AppType *AppType - IfMatch *string - Notify *bool -} - -func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { - return CreateOrUpdateOperationOptions{} -} - -func (o CreateOrUpdateOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o CreateOrUpdateOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.AppType != nil { - out["appType"] = *o.AppType - } - - if o.Notify != nil { - out["notify"] = *o.Notify - } - - return out -} - -// CreateOrUpdate ... -func (c SubscriptionClient) CreateOrUpdate(ctx context.Context, id Subscriptions2Id, input SubscriptionCreateParameters, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdate(ctx, id, input, options) - if err != nil { - err = autorest.NewErrorWithError(err, "subscription.SubscriptionClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "subscription.SubscriptionClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCreateOrUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "subscription.SubscriptionClient", "CreateOrUpdate", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCreateOrUpdate prepares the CreateOrUpdate request. -func (c SubscriptionClient) preparerForCreateOrUpdate(ctx context.Context, id Subscriptions2Id, input SubscriptionCreateParameters, options CreateOrUpdateOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - 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 SubscriptionClient) responderForCreateOrUpdate(resp *http.Response) (result CreateOrUpdateOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2022-08-01/subscription/method_delete.go b/resource-manager/apimanagement/2022-08-01/subscription/method_delete.go new file mode 100644 index 00000000000..a14c0ad04e1 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/subscription/method_delete.go @@ -0,0 +1,76 @@ +package subscription + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +type DeleteOperationOptions struct { + IfMatch *string +} + +func DefaultDeleteOperationOptions() DeleteOperationOptions { + return DeleteOperationOptions{} +} + +func (o DeleteOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o DeleteOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o DeleteOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// Delete ... +func (c SubscriptionClient) Delete(ctx context.Context, id Subscriptions2Id, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2022-08-01/subscription/method_delete_autorest.go b/resource-manager/apimanagement/2022-08-01/subscription/method_delete_autorest.go deleted file mode 100644 index e9f7fe282a7..00000000000 --- a/resource-manager/apimanagement/2022-08-01/subscription/method_delete_autorest.go +++ /dev/null @@ -1,95 +0,0 @@ -package subscription - -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 DeleteOperationResponse struct { - HttpResponse *http.Response -} - -type DeleteOperationOptions struct { - IfMatch *string -} - -func DefaultDeleteOperationOptions() DeleteOperationOptions { - return DeleteOperationOptions{} -} - -func (o DeleteOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o DeleteOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// Delete ... -func (c SubscriptionClient) Delete(ctx context.Context, id Subscriptions2Id, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { - req, err := c.preparerForDelete(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "subscription.SubscriptionClient", "Delete", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "subscription.SubscriptionClient", "Delete", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForDelete(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "subscription.SubscriptionClient", "Delete", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForDelete prepares the Delete request. -func (c SubscriptionClient) preparerForDelete(ctx context.Context, id Subscriptions2Id, options DeleteOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForDelete handles the response to the Delete request. The method always -// closes the http.Response Body. -func (c SubscriptionClient) responderForDelete(resp *http.Response) (result DeleteOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2022-08-01/subscription/method_get.go b/resource-manager/apimanagement/2022-08-01/subscription/method_get.go new file mode 100644 index 00000000000..8aabef6e59e --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/subscription/method_get.go @@ -0,0 +1,51 @@ +package subscription + +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 *SubscriptionContract +} + +// Get ... +func (c SubscriptionClient) Get(ctx context.Context, id Subscriptions2Id) (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/apimanagement/2022-08-01/subscription/method_get_autorest.go b/resource-manager/apimanagement/2022-08-01/subscription/method_get_autorest.go deleted file mode 100644 index 5c650032d00..00000000000 --- a/resource-manager/apimanagement/2022-08-01/subscription/method_get_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package subscription - -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 *SubscriptionContract -} - -// Get ... -func (c SubscriptionClient) Get(ctx context.Context, id Subscriptions2Id) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "subscription.SubscriptionClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "subscription.SubscriptionClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "subscription.SubscriptionClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c SubscriptionClient) preparerForGet(ctx context.Context, id Subscriptions2Id) (*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 SubscriptionClient) 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/apimanagement/2022-08-01/subscription/method_getentitytag.go b/resource-manager/apimanagement/2022-08-01/subscription/method_getentitytag.go new file mode 100644 index 00000000000..70173b87ce1 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/subscription/method_getentitytag.go @@ -0,0 +1,46 @@ +package subscription + +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 GetEntityTagOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// GetEntityTag ... +func (c SubscriptionClient) GetEntityTag(ctx context.Context, id Subscriptions2Id) (result GetEntityTagOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodHead, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2022-08-01/subscription/method_getentitytag_autorest.go b/resource-manager/apimanagement/2022-08-01/subscription/method_getentitytag_autorest.go deleted file mode 100644 index e088e054ada..00000000000 --- a/resource-manager/apimanagement/2022-08-01/subscription/method_getentitytag_autorest.go +++ /dev/null @@ -1,66 +0,0 @@ -package subscription - -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 GetEntityTagOperationResponse struct { - HttpResponse *http.Response -} - -// GetEntityTag ... -func (c SubscriptionClient) GetEntityTag(ctx context.Context, id Subscriptions2Id) (result GetEntityTagOperationResponse, err error) { - req, err := c.preparerForGetEntityTag(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "subscription.SubscriptionClient", "GetEntityTag", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "subscription.SubscriptionClient", "GetEntityTag", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetEntityTag(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "subscription.SubscriptionClient", "GetEntityTag", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetEntityTag prepares the GetEntityTag request. -func (c SubscriptionClient) preparerForGetEntityTag(ctx context.Context, id Subscriptions2Id) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsHead(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetEntityTag handles the response to the GetEntityTag request. The method always -// closes the http.Response Body. -func (c SubscriptionClient) responderForGetEntityTag(resp *http.Response) (result GetEntityTagOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2022-08-01/subscription/method_list.go b/resource-manager/apimanagement/2022-08-01/subscription/method_list.go new file mode 100644 index 00000000000..5a583cace4b --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/subscription/method_list.go @@ -0,0 +1,125 @@ +package subscription + +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 *[]SubscriptionContract +} + +type ListCompleteResult struct { + Items []SubscriptionContract +} + +type ListOperationOptions struct { + Filter *string + Skip *int64 + Top *int64 +} + +func DefaultListOperationOptions() ListOperationOptions { + return ListOperationOptions{} +} + +func (o ListOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.Skip != nil { + out.Append("$skip", fmt.Sprintf("%v", *o.Skip)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +// List ... +func (c SubscriptionClient) List(ctx context.Context, id ServiceId, options ListOperationOptions) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/subscriptions", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]SubscriptionContract `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 SubscriptionClient) ListComplete(ctx context.Context, id ServiceId, options ListOperationOptions) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, options, SubscriptionContractOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c SubscriptionClient) ListCompleteMatchingPredicate(ctx context.Context, id ServiceId, options ListOperationOptions, predicate SubscriptionContractOperationPredicate) (result ListCompleteResult, err error) { + items := make([]SubscriptionContract, 0) + + resp, err := c.List(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/apimanagement/2022-08-01/subscription/method_list_autorest.go b/resource-manager/apimanagement/2022-08-01/subscription/method_list_autorest.go deleted file mode 100644 index 7cf7939d59c..00000000000 --- a/resource-manager/apimanagement/2022-08-01/subscription/method_list_autorest.go +++ /dev/null @@ -1,225 +0,0 @@ -package subscription - -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 *[]SubscriptionContract - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListOperationResponse, error) -} - -type ListCompleteResult struct { - Items []SubscriptionContract -} - -func (r ListOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListOperationResponse) LoadMore(ctx context.Context) (resp ListOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -type ListOperationOptions struct { - Filter *string - Skip *int64 - Top *int64 -} - -func DefaultListOperationOptions() ListOperationOptions { - return ListOperationOptions{} -} - -func (o ListOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o ListOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Filter != nil { - out["$filter"] = *o.Filter - } - - if o.Skip != nil { - out["$skip"] = *o.Skip - } - - if o.Top != nil { - out["$top"] = *o.Top - } - - return out -} - -// List ... -func (c SubscriptionClient) List(ctx context.Context, id ServiceId, options ListOperationOptions) (resp ListOperationResponse, err error) { - req, err := c.preparerForList(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "subscription.SubscriptionClient", "List", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "subscription.SubscriptionClient", "List", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForList(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "subscription.SubscriptionClient", "List", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForList prepares the List request. -func (c SubscriptionClient) preparerForList(ctx context.Context, id ServiceId, options ListOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/subscriptions", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListWithNextLink prepares the List request with the given nextLink token. -func (c SubscriptionClient) 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 SubscriptionClient) responderForList(resp *http.Response) (result ListOperationResponse, err error) { - type page struct { - Values []SubscriptionContract `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, "subscription.SubscriptionClient", "List", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "subscription.SubscriptionClient", "List", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForList(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "subscription.SubscriptionClient", "List", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListComplete retrieves all of the results into a single object -func (c SubscriptionClient) ListComplete(ctx context.Context, id ServiceId, options ListOperationOptions) (ListCompleteResult, error) { - return c.ListCompleteMatchingPredicate(ctx, id, options, SubscriptionContractOperationPredicate{}) -} - -// ListCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c SubscriptionClient) ListCompleteMatchingPredicate(ctx context.Context, id ServiceId, options ListOperationOptions, predicate SubscriptionContractOperationPredicate) (resp ListCompleteResult, err error) { - items := make([]SubscriptionContract, 0) - - page, err := c.List(ctx, id, options) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/apimanagement/2022-08-01/subscription/method_listsecrets.go b/resource-manager/apimanagement/2022-08-01/subscription/method_listsecrets.go new file mode 100644 index 00000000000..f204e457940 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/subscription/method_listsecrets.go @@ -0,0 +1,52 @@ +package subscription + +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 ListSecretsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SubscriptionKeysContract +} + +// ListSecrets ... +func (c SubscriptionClient) ListSecrets(ctx context.Context, id Subscriptions2Id) (result ListSecretsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/listSecrets", 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/apimanagement/2022-08-01/subscription/method_listsecrets_autorest.go b/resource-manager/apimanagement/2022-08-01/subscription/method_listsecrets_autorest.go deleted file mode 100644 index 0e76aeca560..00000000000 --- a/resource-manager/apimanagement/2022-08-01/subscription/method_listsecrets_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package subscription - -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 ListSecretsOperationResponse struct { - HttpResponse *http.Response - Model *SubscriptionKeysContract -} - -// ListSecrets ... -func (c SubscriptionClient) ListSecrets(ctx context.Context, id Subscriptions2Id) (result ListSecretsOperationResponse, err error) { - req, err := c.preparerForListSecrets(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "subscription.SubscriptionClient", "ListSecrets", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "subscription.SubscriptionClient", "ListSecrets", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListSecrets(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "subscription.SubscriptionClient", "ListSecrets", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForListSecrets prepares the ListSecrets request. -func (c SubscriptionClient) preparerForListSecrets(ctx context.Context, id Subscriptions2Id) (*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/listSecrets", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListSecrets handles the response to the ListSecrets request. The method always -// closes the http.Response Body. -func (c SubscriptionClient) responderForListSecrets(resp *http.Response) (result ListSecretsOperationResponse, 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/apimanagement/2022-08-01/subscription/method_regenerateprimarykey.go b/resource-manager/apimanagement/2022-08-01/subscription/method_regenerateprimarykey.go new file mode 100644 index 00000000000..d2ae52bbb7c --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/subscription/method_regenerateprimarykey.go @@ -0,0 +1,47 @@ +package subscription + +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 RegeneratePrimaryKeyOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// RegeneratePrimaryKey ... +func (c SubscriptionClient) RegeneratePrimaryKey(ctx context.Context, id Subscriptions2Id) (result RegeneratePrimaryKeyOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/regeneratePrimaryKey", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2022-08-01/subscription/method_regenerateprimarykey_autorest.go b/resource-manager/apimanagement/2022-08-01/subscription/method_regenerateprimarykey_autorest.go deleted file mode 100644 index 846602df9ec..00000000000 --- a/resource-manager/apimanagement/2022-08-01/subscription/method_regenerateprimarykey_autorest.go +++ /dev/null @@ -1,67 +0,0 @@ -package subscription - -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 RegeneratePrimaryKeyOperationResponse struct { - HttpResponse *http.Response -} - -// RegeneratePrimaryKey ... -func (c SubscriptionClient) RegeneratePrimaryKey(ctx context.Context, id Subscriptions2Id) (result RegeneratePrimaryKeyOperationResponse, err error) { - req, err := c.preparerForRegeneratePrimaryKey(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "subscription.SubscriptionClient", "RegeneratePrimaryKey", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "subscription.SubscriptionClient", "RegeneratePrimaryKey", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForRegeneratePrimaryKey(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "subscription.SubscriptionClient", "RegeneratePrimaryKey", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForRegeneratePrimaryKey prepares the RegeneratePrimaryKey request. -func (c SubscriptionClient) preparerForRegeneratePrimaryKey(ctx context.Context, id Subscriptions2Id) (*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/regeneratePrimaryKey", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForRegeneratePrimaryKey handles the response to the RegeneratePrimaryKey request. The method always -// closes the http.Response Body. -func (c SubscriptionClient) responderForRegeneratePrimaryKey(resp *http.Response) (result RegeneratePrimaryKeyOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2022-08-01/subscription/method_regeneratesecondarykey.go b/resource-manager/apimanagement/2022-08-01/subscription/method_regeneratesecondarykey.go new file mode 100644 index 00000000000..7e3998ced00 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/subscription/method_regeneratesecondarykey.go @@ -0,0 +1,47 @@ +package subscription + +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 RegenerateSecondaryKeyOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// RegenerateSecondaryKey ... +func (c SubscriptionClient) RegenerateSecondaryKey(ctx context.Context, id Subscriptions2Id) (result RegenerateSecondaryKeyOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/regenerateSecondaryKey", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2022-08-01/subscription/method_regeneratesecondarykey_autorest.go b/resource-manager/apimanagement/2022-08-01/subscription/method_regeneratesecondarykey_autorest.go deleted file mode 100644 index 44faa9e3409..00000000000 --- a/resource-manager/apimanagement/2022-08-01/subscription/method_regeneratesecondarykey_autorest.go +++ /dev/null @@ -1,67 +0,0 @@ -package subscription - -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 RegenerateSecondaryKeyOperationResponse struct { - HttpResponse *http.Response -} - -// RegenerateSecondaryKey ... -func (c SubscriptionClient) RegenerateSecondaryKey(ctx context.Context, id Subscriptions2Id) (result RegenerateSecondaryKeyOperationResponse, err error) { - req, err := c.preparerForRegenerateSecondaryKey(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "subscription.SubscriptionClient", "RegenerateSecondaryKey", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "subscription.SubscriptionClient", "RegenerateSecondaryKey", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForRegenerateSecondaryKey(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "subscription.SubscriptionClient", "RegenerateSecondaryKey", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForRegenerateSecondaryKey prepares the RegenerateSecondaryKey request. -func (c SubscriptionClient) preparerForRegenerateSecondaryKey(ctx context.Context, id Subscriptions2Id) (*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/regenerateSecondaryKey", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForRegenerateSecondaryKey handles the response to the RegenerateSecondaryKey request. The method always -// closes the http.Response Body. -func (c SubscriptionClient) responderForRegenerateSecondaryKey(resp *http.Response) (result RegenerateSecondaryKeyOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2022-08-01/subscription/method_update.go b/resource-manager/apimanagement/2022-08-01/subscription/method_update.go new file mode 100644 index 00000000000..f01dc48db34 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/subscription/method_update.go @@ -0,0 +1,91 @@ +package subscription + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SubscriptionContract +} + +type UpdateOperationOptions struct { + AppType *AppType + IfMatch *string + Notify *bool +} + +func DefaultUpdateOperationOptions() UpdateOperationOptions { + return UpdateOperationOptions{} +} + +func (o UpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o UpdateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o UpdateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.AppType != nil { + out.Append("appType", fmt.Sprintf("%v", *o.AppType)) + } + if o.Notify != nil { + out.Append("notify", fmt.Sprintf("%v", *o.Notify)) + } + return &out +} + +// Update ... +func (c SubscriptionClient) Update(ctx context.Context, id Subscriptions2Id, input SubscriptionUpdateParameters, options UpdateOperationOptions) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + OptionsObject: options, + } + + 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/apimanagement/2022-08-01/subscription/method_update_autorest.go b/resource-manager/apimanagement/2022-08-01/subscription/method_update_autorest.go deleted file mode 100644 index 000a788ba77..00000000000 --- a/resource-manager/apimanagement/2022-08-01/subscription/method_update_autorest.go +++ /dev/null @@ -1,108 +0,0 @@ -package subscription - -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 *SubscriptionContract -} - -type UpdateOperationOptions struct { - AppType *AppType - IfMatch *string - Notify *bool -} - -func DefaultUpdateOperationOptions() UpdateOperationOptions { - return UpdateOperationOptions{} -} - -func (o UpdateOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o UpdateOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.AppType != nil { - out["appType"] = *o.AppType - } - - if o.Notify != nil { - out["notify"] = *o.Notify - } - - return out -} - -// Update ... -func (c SubscriptionClient) Update(ctx context.Context, id Subscriptions2Id, input SubscriptionUpdateParameters, options UpdateOperationOptions) (result UpdateOperationResponse, err error) { - req, err := c.preparerForUpdate(ctx, id, input, options) - if err != nil { - err = autorest.NewErrorWithError(err, "subscription.SubscriptionClient", "Update", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "subscription.SubscriptionClient", "Update", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "subscription.SubscriptionClient", "Update", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForUpdate prepares the Update request. -func (c SubscriptionClient) preparerForUpdate(ctx context.Context, id Subscriptions2Id, input SubscriptionUpdateParameters, options UpdateOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPatch(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - 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 SubscriptionClient) 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/apimanagement/2022-08-01/subscription/method_usersubscriptionget.go b/resource-manager/apimanagement/2022-08-01/subscription/method_usersubscriptionget.go new file mode 100644 index 00000000000..7553f7391d9 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/subscription/method_usersubscriptionget.go @@ -0,0 +1,51 @@ +package subscription + +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 UserSubscriptionGetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SubscriptionContract +} + +// UserSubscriptionGet ... +func (c SubscriptionClient) UserSubscriptionGet(ctx context.Context, id UserSubscriptions2Id) (result UserSubscriptionGetOperationResponse, 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/apimanagement/2022-08-01/subscription/method_usersubscriptionget_autorest.go b/resource-manager/apimanagement/2022-08-01/subscription/method_usersubscriptionget_autorest.go deleted file mode 100644 index cc4667c6c9c..00000000000 --- a/resource-manager/apimanagement/2022-08-01/subscription/method_usersubscriptionget_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package subscription - -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 UserSubscriptionGetOperationResponse struct { - HttpResponse *http.Response - Model *SubscriptionContract -} - -// UserSubscriptionGet ... -func (c SubscriptionClient) UserSubscriptionGet(ctx context.Context, id UserSubscriptions2Id) (result UserSubscriptionGetOperationResponse, err error) { - req, err := c.preparerForUserSubscriptionGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "subscription.SubscriptionClient", "UserSubscriptionGet", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "subscription.SubscriptionClient", "UserSubscriptionGet", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForUserSubscriptionGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "subscription.SubscriptionClient", "UserSubscriptionGet", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForUserSubscriptionGet prepares the UserSubscriptionGet request. -func (c SubscriptionClient) preparerForUserSubscriptionGet(ctx context.Context, id UserSubscriptions2Id) (*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)) -} - -// responderForUserSubscriptionGet handles the response to the UserSubscriptionGet request. The method always -// closes the http.Response Body. -func (c SubscriptionClient) responderForUserSubscriptionGet(resp *http.Response) (result UserSubscriptionGetOperationResponse, 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/apimanagement/2022-08-01/tag/client.go b/resource-manager/apimanagement/2022-08-01/tag/client.go index 859dfa3f85e..02bade47a01 100644 --- a/resource-manager/apimanagement/2022-08-01/tag/client.go +++ b/resource-manager/apimanagement/2022-08-01/tag/client.go @@ -1,18 +1,26 @@ package tag -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 TagClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewTagClientWithBaseURI(endpoint string) TagClient { - return TagClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewTagClientWithBaseURI(api environments.Api) (*TagClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "tag", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating TagClient: %+v", err) } + + return &TagClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2022-08-01/tag/method_createorupdate.go b/resource-manager/apimanagement/2022-08-01/tag/method_createorupdate.go new file mode 100644 index 00000000000..b7c955b4480 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/tag/method_createorupdate.go @@ -0,0 +1,85 @@ +package tag + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *TagContract +} + +type CreateOrUpdateOperationOptions struct { + IfMatch *string +} + +func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { + return CreateOrUpdateOperationOptions{} +} + +func (o CreateOrUpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o CreateOrUpdateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o CreateOrUpdateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// CreateOrUpdate ... +func (c TagClient) CreateOrUpdate(ctx context.Context, id TagId, input TagCreateUpdateParameters, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + OptionsObject: options, + } + + 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/apimanagement/2022-08-01/tag/method_createorupdate_autorest.go b/resource-manager/apimanagement/2022-08-01/tag/method_createorupdate_autorest.go deleted file mode 100644 index 48f02bbd515..00000000000 --- a/resource-manager/apimanagement/2022-08-01/tag/method_createorupdate_autorest.go +++ /dev/null @@ -1,98 +0,0 @@ -package tag - -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 *TagContract -} - -type CreateOrUpdateOperationOptions struct { - IfMatch *string -} - -func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { - return CreateOrUpdateOperationOptions{} -} - -func (o CreateOrUpdateOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o CreateOrUpdateOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// CreateOrUpdate ... -func (c TagClient) CreateOrUpdate(ctx context.Context, id TagId, input TagCreateUpdateParameters, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdate(ctx, id, input, options) - if err != nil { - err = autorest.NewErrorWithError(err, "tag.TagClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "tag.TagClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCreateOrUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "tag.TagClient", "CreateOrUpdate", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCreateOrUpdate prepares the CreateOrUpdate request. -func (c TagClient) preparerForCreateOrUpdate(ctx context.Context, id TagId, input TagCreateUpdateParameters, options CreateOrUpdateOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - 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 TagClient) responderForCreateOrUpdate(resp *http.Response) (result CreateOrUpdateOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2022-08-01/tag/method_delete.go b/resource-manager/apimanagement/2022-08-01/tag/method_delete.go new file mode 100644 index 00000000000..01b72128471 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/tag/method_delete.go @@ -0,0 +1,76 @@ +package tag + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +type DeleteOperationOptions struct { + IfMatch *string +} + +func DefaultDeleteOperationOptions() DeleteOperationOptions { + return DeleteOperationOptions{} +} + +func (o DeleteOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o DeleteOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o DeleteOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// Delete ... +func (c TagClient) Delete(ctx context.Context, id TagId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2022-08-01/tag/method_delete_autorest.go b/resource-manager/apimanagement/2022-08-01/tag/method_delete_autorest.go deleted file mode 100644 index fad1b450db3..00000000000 --- a/resource-manager/apimanagement/2022-08-01/tag/method_delete_autorest.go +++ /dev/null @@ -1,95 +0,0 @@ -package tag - -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 DeleteOperationResponse struct { - HttpResponse *http.Response -} - -type DeleteOperationOptions struct { - IfMatch *string -} - -func DefaultDeleteOperationOptions() DeleteOperationOptions { - return DeleteOperationOptions{} -} - -func (o DeleteOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o DeleteOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// Delete ... -func (c TagClient) Delete(ctx context.Context, id TagId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { - req, err := c.preparerForDelete(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "tag.TagClient", "Delete", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "tag.TagClient", "Delete", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForDelete(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "tag.TagClient", "Delete", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForDelete prepares the Delete request. -func (c TagClient) preparerForDelete(ctx context.Context, id TagId, options DeleteOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForDelete handles the response to the Delete request. The method always -// closes the http.Response Body. -func (c TagClient) responderForDelete(resp *http.Response) (result DeleteOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2022-08-01/tag/method_get.go b/resource-manager/apimanagement/2022-08-01/tag/method_get.go new file mode 100644 index 00000000000..340922be21e --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/tag/method_get.go @@ -0,0 +1,51 @@ +package tag + +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 *TagContract +} + +// Get ... +func (c TagClient) Get(ctx context.Context, id TagId) (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/apimanagement/2022-08-01/tag/method_get_autorest.go b/resource-manager/apimanagement/2022-08-01/tag/method_get_autorest.go deleted file mode 100644 index 0a9cd67ede7..00000000000 --- a/resource-manager/apimanagement/2022-08-01/tag/method_get_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package tag - -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 *TagContract -} - -// Get ... -func (c TagClient) Get(ctx context.Context, id TagId) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "tag.TagClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "tag.TagClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "tag.TagClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c TagClient) preparerForGet(ctx context.Context, id TagId) (*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 TagClient) 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/apimanagement/2022-08-01/tag/method_getentitystate.go b/resource-manager/apimanagement/2022-08-01/tag/method_getentitystate.go new file mode 100644 index 00000000000..b56c0026a99 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/tag/method_getentitystate.go @@ -0,0 +1,46 @@ +package tag + +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 GetEntityStateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// GetEntityState ... +func (c TagClient) GetEntityState(ctx context.Context, id TagId) (result GetEntityStateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodHead, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2022-08-01/tag/method_getentitystate_autorest.go b/resource-manager/apimanagement/2022-08-01/tag/method_getentitystate_autorest.go deleted file mode 100644 index a058ebd7e9b..00000000000 --- a/resource-manager/apimanagement/2022-08-01/tag/method_getentitystate_autorest.go +++ /dev/null @@ -1,66 +0,0 @@ -package tag - -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 GetEntityStateOperationResponse struct { - HttpResponse *http.Response -} - -// GetEntityState ... -func (c TagClient) GetEntityState(ctx context.Context, id TagId) (result GetEntityStateOperationResponse, err error) { - req, err := c.preparerForGetEntityState(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "tag.TagClient", "GetEntityState", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "tag.TagClient", "GetEntityState", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetEntityState(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "tag.TagClient", "GetEntityState", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetEntityState prepares the GetEntityState request. -func (c TagClient) preparerForGetEntityState(ctx context.Context, id TagId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsHead(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetEntityState handles the response to the GetEntityState request. The method always -// closes the http.Response Body. -func (c TagClient) responderForGetEntityState(resp *http.Response) (result GetEntityStateOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2022-08-01/tag/method_listbyservice.go b/resource-manager/apimanagement/2022-08-01/tag/method_listbyservice.go new file mode 100644 index 00000000000..110e8d13d3c --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/tag/method_listbyservice.go @@ -0,0 +1,129 @@ +package tag + +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 ListByServiceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]TagContract +} + +type ListByServiceCompleteResult struct { + Items []TagContract +} + +type ListByServiceOperationOptions struct { + Filter *string + Scope *string + Skip *int64 + Top *int64 +} + +func DefaultListByServiceOperationOptions() ListByServiceOperationOptions { + return ListByServiceOperationOptions{} +} + +func (o ListByServiceOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListByServiceOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListByServiceOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.Scope != nil { + out.Append("scope", fmt.Sprintf("%v", *o.Scope)) + } + if o.Skip != nil { + out.Append("$skip", fmt.Sprintf("%v", *o.Skip)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +// ListByService ... +func (c TagClient) ListByService(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (result ListByServiceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/tags", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]TagContract `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByServiceComplete retrieves all the results into a single object +func (c TagClient) ListByServiceComplete(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (ListByServiceCompleteResult, error) { + return c.ListByServiceCompleteMatchingPredicate(ctx, id, options, TagContractOperationPredicate{}) +} + +// ListByServiceCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c TagClient) ListByServiceCompleteMatchingPredicate(ctx context.Context, id ServiceId, options ListByServiceOperationOptions, predicate TagContractOperationPredicate) (result ListByServiceCompleteResult, err error) { + items := make([]TagContract, 0) + + resp, err := c.ListByService(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByServiceCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/apimanagement/2022-08-01/tag/method_listbyservice_autorest.go b/resource-manager/apimanagement/2022-08-01/tag/method_listbyservice_autorest.go deleted file mode 100644 index 1e241c14508..00000000000 --- a/resource-manager/apimanagement/2022-08-01/tag/method_listbyservice_autorest.go +++ /dev/null @@ -1,230 +0,0 @@ -package tag - -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 ListByServiceOperationResponse struct { - HttpResponse *http.Response - Model *[]TagContract - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListByServiceOperationResponse, error) -} - -type ListByServiceCompleteResult struct { - Items []TagContract -} - -func (r ListByServiceOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListByServiceOperationResponse) LoadMore(ctx context.Context) (resp ListByServiceOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -type ListByServiceOperationOptions struct { - Filter *string - Scope *string - Skip *int64 - Top *int64 -} - -func DefaultListByServiceOperationOptions() ListByServiceOperationOptions { - return ListByServiceOperationOptions{} -} - -func (o ListByServiceOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o ListByServiceOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Filter != nil { - out["$filter"] = *o.Filter - } - - if o.Scope != nil { - out["scope"] = *o.Scope - } - - if o.Skip != nil { - out["$skip"] = *o.Skip - } - - if o.Top != nil { - out["$top"] = *o.Top - } - - return out -} - -// ListByService ... -func (c TagClient) ListByService(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (resp ListByServiceOperationResponse, err error) { - req, err := c.preparerForListByService(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "tag.TagClient", "ListByService", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "tag.TagClient", "ListByService", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListByService(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "tag.TagClient", "ListByService", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListByService prepares the ListByService request. -func (c TagClient) preparerForListByService(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/tags", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListByServiceWithNextLink prepares the ListByService request with the given nextLink token. -func (c TagClient) preparerForListByServiceWithNextLink(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)) -} - -// responderForListByService handles the response to the ListByService request. The method always -// closes the http.Response Body. -func (c TagClient) responderForListByService(resp *http.Response) (result ListByServiceOperationResponse, err error) { - type page struct { - Values []TagContract `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 ListByServiceOperationResponse, err error) { - req, err := c.preparerForListByServiceWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "tag.TagClient", "ListByService", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "tag.TagClient", "ListByService", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByService(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "tag.TagClient", "ListByService", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListByServiceComplete retrieves all of the results into a single object -func (c TagClient) ListByServiceComplete(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (ListByServiceCompleteResult, error) { - return c.ListByServiceCompleteMatchingPredicate(ctx, id, options, TagContractOperationPredicate{}) -} - -// ListByServiceCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c TagClient) ListByServiceCompleteMatchingPredicate(ctx context.Context, id ServiceId, options ListByServiceOperationOptions, predicate TagContractOperationPredicate) (resp ListByServiceCompleteResult, err error) { - items := make([]TagContract, 0) - - page, err := c.ListByService(ctx, id, options) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListByServiceCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/apimanagement/2022-08-01/tag/method_update.go b/resource-manager/apimanagement/2022-08-01/tag/method_update.go new file mode 100644 index 00000000000..a301e054137 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/tag/method_update.go @@ -0,0 +1,84 @@ +package tag + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *TagContract +} + +type UpdateOperationOptions struct { + IfMatch *string +} + +func DefaultUpdateOperationOptions() UpdateOperationOptions { + return UpdateOperationOptions{} +} + +func (o UpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o UpdateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o UpdateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// Update ... +func (c TagClient) Update(ctx context.Context, id TagId, input TagCreateUpdateParameters, options UpdateOperationOptions) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + OptionsObject: options, + } + + 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/apimanagement/2022-08-01/tag/method_update_autorest.go b/resource-manager/apimanagement/2022-08-01/tag/method_update_autorest.go deleted file mode 100644 index 6a13a61027d..00000000000 --- a/resource-manager/apimanagement/2022-08-01/tag/method_update_autorest.go +++ /dev/null @@ -1,98 +0,0 @@ -package tag - -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 *TagContract -} - -type UpdateOperationOptions struct { - IfMatch *string -} - -func DefaultUpdateOperationOptions() UpdateOperationOptions { - return UpdateOperationOptions{} -} - -func (o UpdateOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o UpdateOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// Update ... -func (c TagClient) Update(ctx context.Context, id TagId, input TagCreateUpdateParameters, options UpdateOperationOptions) (result UpdateOperationResponse, err error) { - req, err := c.preparerForUpdate(ctx, id, input, options) - if err != nil { - err = autorest.NewErrorWithError(err, "tag.TagClient", "Update", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "tag.TagClient", "Update", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "tag.TagClient", "Update", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForUpdate prepares the Update request. -func (c TagClient) preparerForUpdate(ctx context.Context, id TagId, input TagCreateUpdateParameters, options UpdateOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPatch(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - 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 TagClient) 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/apimanagement/2022-08-01/tagresource/client.go b/resource-manager/apimanagement/2022-08-01/tagresource/client.go index 10f42e3996e..64e4eff38a8 100644 --- a/resource-manager/apimanagement/2022-08-01/tagresource/client.go +++ b/resource-manager/apimanagement/2022-08-01/tagresource/client.go @@ -1,18 +1,26 @@ package tagresource -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 TagResourceClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewTagResourceClientWithBaseURI(endpoint string) TagResourceClient { - return TagResourceClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewTagResourceClientWithBaseURI(api environments.Api) (*TagResourceClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "tagresource", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating TagResourceClient: %+v", err) } + + return &TagResourceClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2022-08-01/tagresource/constants.go b/resource-manager/apimanagement/2022-08-01/tagresource/constants.go index 97e2cdd7620..93cbbc002a0 100644 --- a/resource-manager/apimanagement/2022-08-01/tagresource/constants.go +++ b/resource-manager/apimanagement/2022-08-01/tagresource/constants.go @@ -1,6 +1,10 @@ package tagresource -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 PossibleValuesForApiType() []string { } } +func (s *ApiType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseApiType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseApiType(input string) (*ApiType, error) { vals := map[string]ApiType{ "graphql": ApiTypeGraphql, @@ -53,6 +70,19 @@ func PossibleValuesForBearerTokenSendingMethods() []string { } } +func (s *BearerTokenSendingMethods) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseBearerTokenSendingMethods(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseBearerTokenSendingMethods(input string) (*BearerTokenSendingMethods, error) { vals := map[string]BearerTokenSendingMethods{ "authorizationheader": BearerTokenSendingMethodsAuthorizationHeader, @@ -81,6 +111,19 @@ func PossibleValuesForProductState() []string { } } +func (s *ProductState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProductState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseProductState(input string) (*ProductState, error) { vals := map[string]ProductState{ "notpublished": ProductStateNotPublished, @@ -113,6 +156,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{ "http": ProtocolHTTP, diff --git a/resource-manager/apimanagement/2022-08-01/tagresource/method_listbyservice.go b/resource-manager/apimanagement/2022-08-01/tagresource/method_listbyservice.go new file mode 100644 index 00000000000..c896fcb2dfc --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/tagresource/method_listbyservice.go @@ -0,0 +1,125 @@ +package tagresource + +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 ListByServiceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]TagResourceContract +} + +type ListByServiceCompleteResult struct { + Items []TagResourceContract +} + +type ListByServiceOperationOptions struct { + Filter *string + Skip *int64 + Top *int64 +} + +func DefaultListByServiceOperationOptions() ListByServiceOperationOptions { + return ListByServiceOperationOptions{} +} + +func (o ListByServiceOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListByServiceOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListByServiceOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.Skip != nil { + out.Append("$skip", fmt.Sprintf("%v", *o.Skip)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +// ListByService ... +func (c TagResourceClient) ListByService(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (result ListByServiceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/tagResources", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]TagResourceContract `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByServiceComplete retrieves all the results into a single object +func (c TagResourceClient) ListByServiceComplete(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (ListByServiceCompleteResult, error) { + return c.ListByServiceCompleteMatchingPredicate(ctx, id, options, TagResourceContractOperationPredicate{}) +} + +// ListByServiceCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c TagResourceClient) ListByServiceCompleteMatchingPredicate(ctx context.Context, id ServiceId, options ListByServiceOperationOptions, predicate TagResourceContractOperationPredicate) (result ListByServiceCompleteResult, err error) { + items := make([]TagResourceContract, 0) + + resp, err := c.ListByService(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByServiceCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/apimanagement/2022-08-01/tagresource/method_listbyservice_autorest.go b/resource-manager/apimanagement/2022-08-01/tagresource/method_listbyservice_autorest.go deleted file mode 100644 index b86fedc24e7..00000000000 --- a/resource-manager/apimanagement/2022-08-01/tagresource/method_listbyservice_autorest.go +++ /dev/null @@ -1,225 +0,0 @@ -package tagresource - -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 ListByServiceOperationResponse struct { - HttpResponse *http.Response - Model *[]TagResourceContract - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListByServiceOperationResponse, error) -} - -type ListByServiceCompleteResult struct { - Items []TagResourceContract -} - -func (r ListByServiceOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListByServiceOperationResponse) LoadMore(ctx context.Context) (resp ListByServiceOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -type ListByServiceOperationOptions struct { - Filter *string - Skip *int64 - Top *int64 -} - -func DefaultListByServiceOperationOptions() ListByServiceOperationOptions { - return ListByServiceOperationOptions{} -} - -func (o ListByServiceOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o ListByServiceOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Filter != nil { - out["$filter"] = *o.Filter - } - - if o.Skip != nil { - out["$skip"] = *o.Skip - } - - if o.Top != nil { - out["$top"] = *o.Top - } - - return out -} - -// ListByService ... -func (c TagResourceClient) ListByService(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (resp ListByServiceOperationResponse, err error) { - req, err := c.preparerForListByService(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "tagresource.TagResourceClient", "ListByService", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "tagresource.TagResourceClient", "ListByService", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListByService(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "tagresource.TagResourceClient", "ListByService", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListByService prepares the ListByService request. -func (c TagResourceClient) preparerForListByService(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/tagResources", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListByServiceWithNextLink prepares the ListByService request with the given nextLink token. -func (c TagResourceClient) preparerForListByServiceWithNextLink(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)) -} - -// responderForListByService handles the response to the ListByService request. The method always -// closes the http.Response Body. -func (c TagResourceClient) responderForListByService(resp *http.Response) (result ListByServiceOperationResponse, err error) { - type page struct { - Values []TagResourceContract `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 ListByServiceOperationResponse, err error) { - req, err := c.preparerForListByServiceWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "tagresource.TagResourceClient", "ListByService", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "tagresource.TagResourceClient", "ListByService", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByService(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "tagresource.TagResourceClient", "ListByService", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListByServiceComplete retrieves all of the results into a single object -func (c TagResourceClient) ListByServiceComplete(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (ListByServiceCompleteResult, error) { - return c.ListByServiceCompleteMatchingPredicate(ctx, id, options, TagResourceContractOperationPredicate{}) -} - -// ListByServiceCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c TagResourceClient) ListByServiceCompleteMatchingPredicate(ctx context.Context, id ServiceId, options ListByServiceOperationOptions, predicate TagResourceContractOperationPredicate) (resp ListByServiceCompleteResult, err error) { - items := make([]TagResourceContract, 0) - - page, err := c.ListByService(ctx, id, options) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListByServiceCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/apimanagement/2022-08-01/tenantaccess/client.go b/resource-manager/apimanagement/2022-08-01/tenantaccess/client.go index 7a6208f3d69..57a892bf074 100644 --- a/resource-manager/apimanagement/2022-08-01/tenantaccess/client.go +++ b/resource-manager/apimanagement/2022-08-01/tenantaccess/client.go @@ -1,18 +1,26 @@ package tenantaccess -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 TenantAccessClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewTenantAccessClientWithBaseURI(endpoint string) TenantAccessClient { - return TenantAccessClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewTenantAccessClientWithBaseURI(api environments.Api) (*TenantAccessClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "tenantaccess", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating TenantAccessClient: %+v", err) } + + return &TenantAccessClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2022-08-01/tenantaccess/constants.go b/resource-manager/apimanagement/2022-08-01/tenantaccess/constants.go index 3fe8372dbcb..0a9a890aae2 100644 --- a/resource-manager/apimanagement/2022-08-01/tenantaccess/constants.go +++ b/resource-manager/apimanagement/2022-08-01/tenantaccess/constants.go @@ -1,6 +1,10 @@ package tenantaccess -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 PossibleValuesForAccessIdName() []string { } } +func (s *AccessIdName) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAccessIdName(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseAccessIdName(input string) (*AccessIdName, error) { vals := map[string]AccessIdName{ "access": AccessIdNameAccess, diff --git a/resource-manager/apimanagement/2022-08-01/tenantaccess/method_create.go b/resource-manager/apimanagement/2022-08-01/tenantaccess/method_create.go new file mode 100644 index 00000000000..cf2902da389 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/tenantaccess/method_create.go @@ -0,0 +1,84 @@ +package tenantaccess + +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 CreateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *AccessInformationContract +} + +type CreateOperationOptions struct { + IfMatch *string +} + +func DefaultCreateOperationOptions() CreateOperationOptions { + return CreateOperationOptions{} +} + +func (o CreateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o CreateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o CreateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// Create ... +func (c TenantAccessClient) Create(ctx context.Context, id AccessId, input AccessInformationCreateParameters, options CreateOperationOptions) (result CreateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + OptionsObject: options, + } + + 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/apimanagement/2022-08-01/tenantaccess/method_create_autorest.go b/resource-manager/apimanagement/2022-08-01/tenantaccess/method_create_autorest.go deleted file mode 100644 index cc2d34137c2..00000000000 --- a/resource-manager/apimanagement/2022-08-01/tenantaccess/method_create_autorest.go +++ /dev/null @@ -1,98 +0,0 @@ -package tenantaccess - -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 CreateOperationResponse struct { - HttpResponse *http.Response - Model *AccessInformationContract -} - -type CreateOperationOptions struct { - IfMatch *string -} - -func DefaultCreateOperationOptions() CreateOperationOptions { - return CreateOperationOptions{} -} - -func (o CreateOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o CreateOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// Create ... -func (c TenantAccessClient) Create(ctx context.Context, id AccessId, input AccessInformationCreateParameters, options CreateOperationOptions) (result CreateOperationResponse, err error) { - req, err := c.preparerForCreate(ctx, id, input, options) - if err != nil { - err = autorest.NewErrorWithError(err, "tenantaccess.TenantAccessClient", "Create", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "tenantaccess.TenantAccessClient", "Create", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCreate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "tenantaccess.TenantAccessClient", "Create", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCreate prepares the Create request. -func (c TenantAccessClient) preparerForCreate(ctx context.Context, id AccessId, input AccessInformationCreateParameters, options CreateOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForCreate handles the response to the Create request. The method always -// closes the http.Response Body. -func (c TenantAccessClient) responderForCreate(resp *http.Response) (result CreateOperationResponse, 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/apimanagement/2022-08-01/tenantaccess/method_get.go b/resource-manager/apimanagement/2022-08-01/tenantaccess/method_get.go new file mode 100644 index 00000000000..b1f7d18cc3b --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/tenantaccess/method_get.go @@ -0,0 +1,51 @@ +package tenantaccess + +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 *AccessInformationContract +} + +// Get ... +func (c TenantAccessClient) Get(ctx context.Context, id AccessId) (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/apimanagement/2022-08-01/tenantaccess/method_get_autorest.go b/resource-manager/apimanagement/2022-08-01/tenantaccess/method_get_autorest.go deleted file mode 100644 index 3a070ae9892..00000000000 --- a/resource-manager/apimanagement/2022-08-01/tenantaccess/method_get_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package tenantaccess - -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 *AccessInformationContract -} - -// Get ... -func (c TenantAccessClient) Get(ctx context.Context, id AccessId) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "tenantaccess.TenantAccessClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "tenantaccess.TenantAccessClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "tenantaccess.TenantAccessClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c TenantAccessClient) preparerForGet(ctx context.Context, id AccessId) (*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 TenantAccessClient) 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/apimanagement/2022-08-01/tenantaccess/method_getentitytag.go b/resource-manager/apimanagement/2022-08-01/tenantaccess/method_getentitytag.go new file mode 100644 index 00000000000..d1d42ee00fd --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/tenantaccess/method_getentitytag.go @@ -0,0 +1,46 @@ +package tenantaccess + +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 GetEntityTagOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// GetEntityTag ... +func (c TenantAccessClient) GetEntityTag(ctx context.Context, id AccessId) (result GetEntityTagOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodHead, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2022-08-01/tenantaccess/method_getentitytag_autorest.go b/resource-manager/apimanagement/2022-08-01/tenantaccess/method_getentitytag_autorest.go deleted file mode 100644 index 8300d23c3f6..00000000000 --- a/resource-manager/apimanagement/2022-08-01/tenantaccess/method_getentitytag_autorest.go +++ /dev/null @@ -1,66 +0,0 @@ -package tenantaccess - -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 GetEntityTagOperationResponse struct { - HttpResponse *http.Response -} - -// GetEntityTag ... -func (c TenantAccessClient) GetEntityTag(ctx context.Context, id AccessId) (result GetEntityTagOperationResponse, err error) { - req, err := c.preparerForGetEntityTag(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "tenantaccess.TenantAccessClient", "GetEntityTag", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "tenantaccess.TenantAccessClient", "GetEntityTag", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetEntityTag(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "tenantaccess.TenantAccessClient", "GetEntityTag", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetEntityTag prepares the GetEntityTag request. -func (c TenantAccessClient) preparerForGetEntityTag(ctx context.Context, id AccessId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsHead(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetEntityTag handles the response to the GetEntityTag request. The method always -// closes the http.Response Body. -func (c TenantAccessClient) responderForGetEntityTag(resp *http.Response) (result GetEntityTagOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2022-08-01/tenantaccess/method_listbyservice.go b/resource-manager/apimanagement/2022-08-01/tenantaccess/method_listbyservice.go new file mode 100644 index 00000000000..d332a10b9d5 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/tenantaccess/method_listbyservice.go @@ -0,0 +1,117 @@ +package tenantaccess + +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 ListByServiceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]AccessInformationContract +} + +type ListByServiceCompleteResult struct { + Items []AccessInformationContract +} + +type ListByServiceOperationOptions struct { + Filter *string +} + +func DefaultListByServiceOperationOptions() ListByServiceOperationOptions { + return ListByServiceOperationOptions{} +} + +func (o ListByServiceOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListByServiceOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListByServiceOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + return &out +} + +// ListByService ... +func (c TenantAccessClient) ListByService(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (result ListByServiceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/tenant", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]AccessInformationContract `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByServiceComplete retrieves all the results into a single object +func (c TenantAccessClient) ListByServiceComplete(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (ListByServiceCompleteResult, error) { + return c.ListByServiceCompleteMatchingPredicate(ctx, id, options, AccessInformationContractOperationPredicate{}) +} + +// ListByServiceCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c TenantAccessClient) ListByServiceCompleteMatchingPredicate(ctx context.Context, id ServiceId, options ListByServiceOperationOptions, predicate AccessInformationContractOperationPredicate) (result ListByServiceCompleteResult, err error) { + items := make([]AccessInformationContract, 0) + + resp, err := c.ListByService(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByServiceCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/apimanagement/2022-08-01/tenantaccess/method_listbyservice_autorest.go b/resource-manager/apimanagement/2022-08-01/tenantaccess/method_listbyservice_autorest.go deleted file mode 100644 index 8e83891260f..00000000000 --- a/resource-manager/apimanagement/2022-08-01/tenantaccess/method_listbyservice_autorest.go +++ /dev/null @@ -1,215 +0,0 @@ -package tenantaccess - -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 ListByServiceOperationResponse struct { - HttpResponse *http.Response - Model *[]AccessInformationContract - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListByServiceOperationResponse, error) -} - -type ListByServiceCompleteResult struct { - Items []AccessInformationContract -} - -func (r ListByServiceOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListByServiceOperationResponse) LoadMore(ctx context.Context) (resp ListByServiceOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -type ListByServiceOperationOptions struct { - Filter *string -} - -func DefaultListByServiceOperationOptions() ListByServiceOperationOptions { - return ListByServiceOperationOptions{} -} - -func (o ListByServiceOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o ListByServiceOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Filter != nil { - out["$filter"] = *o.Filter - } - - return out -} - -// ListByService ... -func (c TenantAccessClient) ListByService(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (resp ListByServiceOperationResponse, err error) { - req, err := c.preparerForListByService(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "tenantaccess.TenantAccessClient", "ListByService", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "tenantaccess.TenantAccessClient", "ListByService", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListByService(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "tenantaccess.TenantAccessClient", "ListByService", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListByService prepares the ListByService request. -func (c TenantAccessClient) preparerForListByService(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/tenant", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListByServiceWithNextLink prepares the ListByService request with the given nextLink token. -func (c TenantAccessClient) preparerForListByServiceWithNextLink(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)) -} - -// responderForListByService handles the response to the ListByService request. The method always -// closes the http.Response Body. -func (c TenantAccessClient) responderForListByService(resp *http.Response) (result ListByServiceOperationResponse, err error) { - type page struct { - Values []AccessInformationContract `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 ListByServiceOperationResponse, err error) { - req, err := c.preparerForListByServiceWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "tenantaccess.TenantAccessClient", "ListByService", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "tenantaccess.TenantAccessClient", "ListByService", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByService(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "tenantaccess.TenantAccessClient", "ListByService", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListByServiceComplete retrieves all of the results into a single object -func (c TenantAccessClient) ListByServiceComplete(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (ListByServiceCompleteResult, error) { - return c.ListByServiceCompleteMatchingPredicate(ctx, id, options, AccessInformationContractOperationPredicate{}) -} - -// ListByServiceCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c TenantAccessClient) ListByServiceCompleteMatchingPredicate(ctx context.Context, id ServiceId, options ListByServiceOperationOptions, predicate AccessInformationContractOperationPredicate) (resp ListByServiceCompleteResult, err error) { - items := make([]AccessInformationContract, 0) - - page, err := c.ListByService(ctx, id, options) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListByServiceCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/apimanagement/2022-08-01/tenantaccess/method_listsecrets.go b/resource-manager/apimanagement/2022-08-01/tenantaccess/method_listsecrets.go new file mode 100644 index 00000000000..67b0b5f3a0b --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/tenantaccess/method_listsecrets.go @@ -0,0 +1,52 @@ +package tenantaccess + +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 ListSecretsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *AccessInformationSecretsContract +} + +// ListSecrets ... +func (c TenantAccessClient) ListSecrets(ctx context.Context, id AccessId) (result ListSecretsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/listSecrets", 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/apimanagement/2022-08-01/tenantaccess/method_listsecrets_autorest.go b/resource-manager/apimanagement/2022-08-01/tenantaccess/method_listsecrets_autorest.go deleted file mode 100644 index 2a1515ff216..00000000000 --- a/resource-manager/apimanagement/2022-08-01/tenantaccess/method_listsecrets_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package tenantaccess - -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 ListSecretsOperationResponse struct { - HttpResponse *http.Response - Model *AccessInformationSecretsContract -} - -// ListSecrets ... -func (c TenantAccessClient) ListSecrets(ctx context.Context, id AccessId) (result ListSecretsOperationResponse, err error) { - req, err := c.preparerForListSecrets(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "tenantaccess.TenantAccessClient", "ListSecrets", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "tenantaccess.TenantAccessClient", "ListSecrets", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListSecrets(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "tenantaccess.TenantAccessClient", "ListSecrets", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForListSecrets prepares the ListSecrets request. -func (c TenantAccessClient) preparerForListSecrets(ctx context.Context, id AccessId) (*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/listSecrets", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListSecrets handles the response to the ListSecrets request. The method always -// closes the http.Response Body. -func (c TenantAccessClient) responderForListSecrets(resp *http.Response) (result ListSecretsOperationResponse, 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/apimanagement/2022-08-01/tenantaccess/method_regenerateprimarykey.go b/resource-manager/apimanagement/2022-08-01/tenantaccess/method_regenerateprimarykey.go new file mode 100644 index 00000000000..6d6aa0f1ccf --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/tenantaccess/method_regenerateprimarykey.go @@ -0,0 +1,47 @@ +package tenantaccess + +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 RegeneratePrimaryKeyOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// RegeneratePrimaryKey ... +func (c TenantAccessClient) RegeneratePrimaryKey(ctx context.Context, id AccessId) (result RegeneratePrimaryKeyOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/regeneratePrimaryKey", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2022-08-01/tenantaccess/method_regenerateprimarykey_autorest.go b/resource-manager/apimanagement/2022-08-01/tenantaccess/method_regenerateprimarykey_autorest.go deleted file mode 100644 index 18cb875e657..00000000000 --- a/resource-manager/apimanagement/2022-08-01/tenantaccess/method_regenerateprimarykey_autorest.go +++ /dev/null @@ -1,67 +0,0 @@ -package tenantaccess - -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 RegeneratePrimaryKeyOperationResponse struct { - HttpResponse *http.Response -} - -// RegeneratePrimaryKey ... -func (c TenantAccessClient) RegeneratePrimaryKey(ctx context.Context, id AccessId) (result RegeneratePrimaryKeyOperationResponse, err error) { - req, err := c.preparerForRegeneratePrimaryKey(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "tenantaccess.TenantAccessClient", "RegeneratePrimaryKey", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "tenantaccess.TenantAccessClient", "RegeneratePrimaryKey", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForRegeneratePrimaryKey(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "tenantaccess.TenantAccessClient", "RegeneratePrimaryKey", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForRegeneratePrimaryKey prepares the RegeneratePrimaryKey request. -func (c TenantAccessClient) preparerForRegeneratePrimaryKey(ctx context.Context, id AccessId) (*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/regeneratePrimaryKey", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForRegeneratePrimaryKey handles the response to the RegeneratePrimaryKey request. The method always -// closes the http.Response Body. -func (c TenantAccessClient) responderForRegeneratePrimaryKey(resp *http.Response) (result RegeneratePrimaryKeyOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2022-08-01/tenantaccess/method_regeneratesecondarykey.go b/resource-manager/apimanagement/2022-08-01/tenantaccess/method_regeneratesecondarykey.go new file mode 100644 index 00000000000..0fd0b8fd296 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/tenantaccess/method_regeneratesecondarykey.go @@ -0,0 +1,47 @@ +package tenantaccess + +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 RegenerateSecondaryKeyOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// RegenerateSecondaryKey ... +func (c TenantAccessClient) RegenerateSecondaryKey(ctx context.Context, id AccessId) (result RegenerateSecondaryKeyOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/regenerateSecondaryKey", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2022-08-01/tenantaccess/method_regeneratesecondarykey_autorest.go b/resource-manager/apimanagement/2022-08-01/tenantaccess/method_regeneratesecondarykey_autorest.go deleted file mode 100644 index 60839456731..00000000000 --- a/resource-manager/apimanagement/2022-08-01/tenantaccess/method_regeneratesecondarykey_autorest.go +++ /dev/null @@ -1,67 +0,0 @@ -package tenantaccess - -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 RegenerateSecondaryKeyOperationResponse struct { - HttpResponse *http.Response -} - -// RegenerateSecondaryKey ... -func (c TenantAccessClient) RegenerateSecondaryKey(ctx context.Context, id AccessId) (result RegenerateSecondaryKeyOperationResponse, err error) { - req, err := c.preparerForRegenerateSecondaryKey(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "tenantaccess.TenantAccessClient", "RegenerateSecondaryKey", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "tenantaccess.TenantAccessClient", "RegenerateSecondaryKey", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForRegenerateSecondaryKey(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "tenantaccess.TenantAccessClient", "RegenerateSecondaryKey", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForRegenerateSecondaryKey prepares the RegenerateSecondaryKey request. -func (c TenantAccessClient) preparerForRegenerateSecondaryKey(ctx context.Context, id AccessId) (*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/regenerateSecondaryKey", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForRegenerateSecondaryKey handles the response to the RegenerateSecondaryKey request. The method always -// closes the http.Response Body. -func (c TenantAccessClient) responderForRegenerateSecondaryKey(resp *http.Response) (result RegenerateSecondaryKeyOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2022-08-01/tenantaccess/method_update.go b/resource-manager/apimanagement/2022-08-01/tenantaccess/method_update.go new file mode 100644 index 00000000000..255888180b3 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/tenantaccess/method_update.go @@ -0,0 +1,84 @@ +package tenantaccess + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *AccessInformationContract +} + +type UpdateOperationOptions struct { + IfMatch *string +} + +func DefaultUpdateOperationOptions() UpdateOperationOptions { + return UpdateOperationOptions{} +} + +func (o UpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o UpdateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o UpdateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// Update ... +func (c TenantAccessClient) Update(ctx context.Context, id AccessId, input AccessInformationUpdateParameters, options UpdateOperationOptions) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + OptionsObject: options, + } + + 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/apimanagement/2022-08-01/tenantaccess/method_update_autorest.go b/resource-manager/apimanagement/2022-08-01/tenantaccess/method_update_autorest.go deleted file mode 100644 index 87eb5439426..00000000000 --- a/resource-manager/apimanagement/2022-08-01/tenantaccess/method_update_autorest.go +++ /dev/null @@ -1,98 +0,0 @@ -package tenantaccess - -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 *AccessInformationContract -} - -type UpdateOperationOptions struct { - IfMatch *string -} - -func DefaultUpdateOperationOptions() UpdateOperationOptions { - return UpdateOperationOptions{} -} - -func (o UpdateOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o UpdateOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// Update ... -func (c TenantAccessClient) Update(ctx context.Context, id AccessId, input AccessInformationUpdateParameters, options UpdateOperationOptions) (result UpdateOperationResponse, err error) { - req, err := c.preparerForUpdate(ctx, id, input, options) - if err != nil { - err = autorest.NewErrorWithError(err, "tenantaccess.TenantAccessClient", "Update", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "tenantaccess.TenantAccessClient", "Update", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "tenantaccess.TenantAccessClient", "Update", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForUpdate prepares the Update request. -func (c TenantAccessClient) preparerForUpdate(ctx context.Context, id AccessId, input AccessInformationUpdateParameters, options UpdateOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPatch(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - 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 TenantAccessClient) 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/apimanagement/2022-08-01/tenantaccessgit/client.go b/resource-manager/apimanagement/2022-08-01/tenantaccessgit/client.go index 015bab0d24f..91b616be2c8 100644 --- a/resource-manager/apimanagement/2022-08-01/tenantaccessgit/client.go +++ b/resource-manager/apimanagement/2022-08-01/tenantaccessgit/client.go @@ -1,18 +1,26 @@ package tenantaccessgit -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 TenantAccessGitClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewTenantAccessGitClientWithBaseURI(endpoint string) TenantAccessGitClient { - return TenantAccessGitClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewTenantAccessGitClientWithBaseURI(api environments.Api) (*TenantAccessGitClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "tenantaccessgit", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating TenantAccessGitClient: %+v", err) } + + return &TenantAccessGitClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2022-08-01/tenantaccessgit/constants.go b/resource-manager/apimanagement/2022-08-01/tenantaccessgit/constants.go index b35272377f3..0423218f1c5 100644 --- a/resource-manager/apimanagement/2022-08-01/tenantaccessgit/constants.go +++ b/resource-manager/apimanagement/2022-08-01/tenantaccessgit/constants.go @@ -1,6 +1,10 @@ package tenantaccessgit -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 PossibleValuesForAccessIdName() []string { } } +func (s *AccessIdName) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAccessIdName(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseAccessIdName(input string) (*AccessIdName, error) { vals := map[string]AccessIdName{ "access": AccessIdNameAccess, diff --git a/resource-manager/apimanagement/2022-08-01/tenantaccessgit/method_regenerateprimarykey.go b/resource-manager/apimanagement/2022-08-01/tenantaccessgit/method_regenerateprimarykey.go new file mode 100644 index 00000000000..5b6c503576f --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/tenantaccessgit/method_regenerateprimarykey.go @@ -0,0 +1,47 @@ +package tenantaccessgit + +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 RegeneratePrimaryKeyOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// RegeneratePrimaryKey ... +func (c TenantAccessGitClient) RegeneratePrimaryKey(ctx context.Context, id AccessId) (result RegeneratePrimaryKeyOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/git/regeneratePrimaryKey", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2022-08-01/tenantaccessgit/method_regenerateprimarykey_autorest.go b/resource-manager/apimanagement/2022-08-01/tenantaccessgit/method_regenerateprimarykey_autorest.go deleted file mode 100644 index 4783b820c9d..00000000000 --- a/resource-manager/apimanagement/2022-08-01/tenantaccessgit/method_regenerateprimarykey_autorest.go +++ /dev/null @@ -1,67 +0,0 @@ -package tenantaccessgit - -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 RegeneratePrimaryKeyOperationResponse struct { - HttpResponse *http.Response -} - -// RegeneratePrimaryKey ... -func (c TenantAccessGitClient) RegeneratePrimaryKey(ctx context.Context, id AccessId) (result RegeneratePrimaryKeyOperationResponse, err error) { - req, err := c.preparerForRegeneratePrimaryKey(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "tenantaccessgit.TenantAccessGitClient", "RegeneratePrimaryKey", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "tenantaccessgit.TenantAccessGitClient", "RegeneratePrimaryKey", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForRegeneratePrimaryKey(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "tenantaccessgit.TenantAccessGitClient", "RegeneratePrimaryKey", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForRegeneratePrimaryKey prepares the RegeneratePrimaryKey request. -func (c TenantAccessGitClient) preparerForRegeneratePrimaryKey(ctx context.Context, id AccessId) (*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/git/regeneratePrimaryKey", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForRegeneratePrimaryKey handles the response to the RegeneratePrimaryKey request. The method always -// closes the http.Response Body. -func (c TenantAccessGitClient) responderForRegeneratePrimaryKey(resp *http.Response) (result RegeneratePrimaryKeyOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2022-08-01/tenantaccessgit/method_regeneratesecondarykey.go b/resource-manager/apimanagement/2022-08-01/tenantaccessgit/method_regeneratesecondarykey.go new file mode 100644 index 00000000000..fa55bca8deb --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/tenantaccessgit/method_regeneratesecondarykey.go @@ -0,0 +1,47 @@ +package tenantaccessgit + +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 RegenerateSecondaryKeyOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// RegenerateSecondaryKey ... +func (c TenantAccessGitClient) RegenerateSecondaryKey(ctx context.Context, id AccessId) (result RegenerateSecondaryKeyOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/git/regenerateSecondaryKey", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2022-08-01/tenantaccessgit/method_regeneratesecondarykey_autorest.go b/resource-manager/apimanagement/2022-08-01/tenantaccessgit/method_regeneratesecondarykey_autorest.go deleted file mode 100644 index d0375fcb447..00000000000 --- a/resource-manager/apimanagement/2022-08-01/tenantaccessgit/method_regeneratesecondarykey_autorest.go +++ /dev/null @@ -1,67 +0,0 @@ -package tenantaccessgit - -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 RegenerateSecondaryKeyOperationResponse struct { - HttpResponse *http.Response -} - -// RegenerateSecondaryKey ... -func (c TenantAccessGitClient) RegenerateSecondaryKey(ctx context.Context, id AccessId) (result RegenerateSecondaryKeyOperationResponse, err error) { - req, err := c.preparerForRegenerateSecondaryKey(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "tenantaccessgit.TenantAccessGitClient", "RegenerateSecondaryKey", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "tenantaccessgit.TenantAccessGitClient", "RegenerateSecondaryKey", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForRegenerateSecondaryKey(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "tenantaccessgit.TenantAccessGitClient", "RegenerateSecondaryKey", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForRegenerateSecondaryKey prepares the RegenerateSecondaryKey request. -func (c TenantAccessGitClient) preparerForRegenerateSecondaryKey(ctx context.Context, id AccessId) (*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/git/regenerateSecondaryKey", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForRegenerateSecondaryKey handles the response to the RegenerateSecondaryKey request. The method always -// closes the http.Response Body. -func (c TenantAccessGitClient) responderForRegenerateSecondaryKey(resp *http.Response) (result RegenerateSecondaryKeyOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2022-08-01/tenantconfiguration/client.go b/resource-manager/apimanagement/2022-08-01/tenantconfiguration/client.go index b4cf4a17cf2..30299aa4773 100644 --- a/resource-manager/apimanagement/2022-08-01/tenantconfiguration/client.go +++ b/resource-manager/apimanagement/2022-08-01/tenantconfiguration/client.go @@ -1,18 +1,26 @@ package tenantconfiguration -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 TenantConfigurationClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewTenantConfigurationClientWithBaseURI(endpoint string) TenantConfigurationClient { - return TenantConfigurationClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewTenantConfigurationClientWithBaseURI(api environments.Api) (*TenantConfigurationClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "tenantconfiguration", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating TenantConfigurationClient: %+v", err) } + + return &TenantConfigurationClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2022-08-01/tenantconfiguration/constants.go b/resource-manager/apimanagement/2022-08-01/tenantconfiguration/constants.go index 68f7b36814f..c896fa35bce 100644 --- a/resource-manager/apimanagement/2022-08-01/tenantconfiguration/constants.go +++ b/resource-manager/apimanagement/2022-08-01/tenantconfiguration/constants.go @@ -1,6 +1,10 @@ package tenantconfiguration -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 PossibleValuesForAsyncOperationStatus() []string { } } +func (s *AsyncOperationStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAsyncOperationStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseAsyncOperationStatus(input string) (*AsyncOperationStatus, error) { vals := map[string]AsyncOperationStatus{ "failed": AsyncOperationStatusFailed, diff --git a/resource-manager/apimanagement/2022-08-01/tenantconfiguration/method_deploy.go b/resource-manager/apimanagement/2022-08-01/tenantconfiguration/method_deploy.go new file mode 100644 index 00000000000..e71bf7ad1b6 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/tenantconfiguration/method_deploy.go @@ -0,0 +1,74 @@ +package tenantconfiguration + +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 DeployOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Deploy ... +func (c TenantConfigurationClient) Deploy(ctx context.Context, id ServiceId, input DeployConfigurationParameters) (result DeployOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/tenant/configuration/deploy", 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 +} + +// DeployThenPoll performs Deploy then polls until it's completed +func (c TenantConfigurationClient) DeployThenPoll(ctx context.Context, id ServiceId, input DeployConfigurationParameters) error { + result, err := c.Deploy(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Deploy: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Deploy: %+v", err) + } + + return nil +} diff --git a/resource-manager/apimanagement/2022-08-01/tenantconfiguration/method_deploy_autorest.go b/resource-manager/apimanagement/2022-08-01/tenantconfiguration/method_deploy_autorest.go deleted file mode 100644 index 659a8ef5465..00000000000 --- a/resource-manager/apimanagement/2022-08-01/tenantconfiguration/method_deploy_autorest.go +++ /dev/null @@ -1,79 +0,0 @@ -package tenantconfiguration - -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 DeployOperationResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// Deploy ... -func (c TenantConfigurationClient) Deploy(ctx context.Context, id ServiceId, input DeployConfigurationParameters) (result DeployOperationResponse, err error) { - req, err := c.preparerForDeploy(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "tenantconfiguration.TenantConfigurationClient", "Deploy", nil, "Failure preparing request") - return - } - - result, err = c.senderForDeploy(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "tenantconfiguration.TenantConfigurationClient", "Deploy", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// DeployThenPoll performs Deploy then polls until it's completed -func (c TenantConfigurationClient) DeployThenPoll(ctx context.Context, id ServiceId, input DeployConfigurationParameters) error { - result, err := c.Deploy(ctx, id, input) - if err != nil { - return fmt.Errorf("performing Deploy: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after Deploy: %+v", err) - } - - return nil -} - -// preparerForDeploy prepares the Deploy request. -func (c TenantConfigurationClient) preparerForDeploy(ctx context.Context, id ServiceId, input DeployConfigurationParameters) (*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/tenant/configuration/deploy", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForDeploy sends the Deploy request. The method will close the -// http.Response Body if it receives an error. -func (c TenantConfigurationClient) senderForDeploy(ctx context.Context, req *http.Request) (future DeployOperationResponse, 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/apimanagement/2022-08-01/tenantconfiguration/method_save.go b/resource-manager/apimanagement/2022-08-01/tenantconfiguration/method_save.go new file mode 100644 index 00000000000..c261c455120 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/tenantconfiguration/method_save.go @@ -0,0 +1,74 @@ +package tenantconfiguration + +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 SaveOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Save ... +func (c TenantConfigurationClient) Save(ctx context.Context, id ServiceId, input SaveConfigurationParameter) (result SaveOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/tenant/configuration/save", 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 +} + +// SaveThenPoll performs Save then polls until it's completed +func (c TenantConfigurationClient) SaveThenPoll(ctx context.Context, id ServiceId, input SaveConfigurationParameter) error { + result, err := c.Save(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Save: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Save: %+v", err) + } + + return nil +} diff --git a/resource-manager/apimanagement/2022-08-01/tenantconfiguration/method_save_autorest.go b/resource-manager/apimanagement/2022-08-01/tenantconfiguration/method_save_autorest.go deleted file mode 100644 index 989e1db8216..00000000000 --- a/resource-manager/apimanagement/2022-08-01/tenantconfiguration/method_save_autorest.go +++ /dev/null @@ -1,79 +0,0 @@ -package tenantconfiguration - -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 SaveOperationResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// Save ... -func (c TenantConfigurationClient) Save(ctx context.Context, id ServiceId, input SaveConfigurationParameter) (result SaveOperationResponse, err error) { - req, err := c.preparerForSave(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "tenantconfiguration.TenantConfigurationClient", "Save", nil, "Failure preparing request") - return - } - - result, err = c.senderForSave(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "tenantconfiguration.TenantConfigurationClient", "Save", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// SaveThenPoll performs Save then polls until it's completed -func (c TenantConfigurationClient) SaveThenPoll(ctx context.Context, id ServiceId, input SaveConfigurationParameter) error { - result, err := c.Save(ctx, id, input) - if err != nil { - return fmt.Errorf("performing Save: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after Save: %+v", err) - } - - return nil -} - -// preparerForSave prepares the Save request. -func (c TenantConfigurationClient) preparerForSave(ctx context.Context, id ServiceId, input SaveConfigurationParameter) (*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/tenant/configuration/save", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForSave sends the Save request. The method will close the -// http.Response Body if it receives an error. -func (c TenantConfigurationClient) senderForSave(ctx context.Context, req *http.Request) (future SaveOperationResponse, 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/apimanagement/2022-08-01/tenantconfiguration/method_validate.go b/resource-manager/apimanagement/2022-08-01/tenantconfiguration/method_validate.go new file mode 100644 index 00000000000..26401e0e77f --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/tenantconfiguration/method_validate.go @@ -0,0 +1,74 @@ +package tenantconfiguration + +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 ValidateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Validate ... +func (c TenantConfigurationClient) Validate(ctx context.Context, id ServiceId, input DeployConfigurationParameters) (result ValidateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/tenant/configuration/validate", 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 +} + +// ValidateThenPoll performs Validate then polls until it's completed +func (c TenantConfigurationClient) ValidateThenPoll(ctx context.Context, id ServiceId, input DeployConfigurationParameters) error { + result, err := c.Validate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Validate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Validate: %+v", err) + } + + return nil +} diff --git a/resource-manager/apimanagement/2022-08-01/tenantconfiguration/method_validate_autorest.go b/resource-manager/apimanagement/2022-08-01/tenantconfiguration/method_validate_autorest.go deleted file mode 100644 index 64e2904b423..00000000000 --- a/resource-manager/apimanagement/2022-08-01/tenantconfiguration/method_validate_autorest.go +++ /dev/null @@ -1,79 +0,0 @@ -package tenantconfiguration - -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 ValidateOperationResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// Validate ... -func (c TenantConfigurationClient) Validate(ctx context.Context, id ServiceId, input DeployConfigurationParameters) (result ValidateOperationResponse, err error) { - req, err := c.preparerForValidate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "tenantconfiguration.TenantConfigurationClient", "Validate", nil, "Failure preparing request") - return - } - - result, err = c.senderForValidate(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "tenantconfiguration.TenantConfigurationClient", "Validate", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// ValidateThenPoll performs Validate then polls until it's completed -func (c TenantConfigurationClient) ValidateThenPoll(ctx context.Context, id ServiceId, input DeployConfigurationParameters) error { - result, err := c.Validate(ctx, id, input) - if err != nil { - return fmt.Errorf("performing Validate: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after Validate: %+v", err) - } - - return nil -} - -// preparerForValidate prepares the Validate request. -func (c TenantConfigurationClient) preparerForValidate(ctx context.Context, id ServiceId, input DeployConfigurationParameters) (*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/tenant/configuration/validate", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForValidate sends the Validate request. The method will close the -// http.Response Body if it receives an error. -func (c TenantConfigurationClient) senderForValidate(ctx context.Context, req *http.Request) (future ValidateOperationResponse, 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/apimanagement/2022-08-01/tenantconfigurationsyncstate/client.go b/resource-manager/apimanagement/2022-08-01/tenantconfigurationsyncstate/client.go index b005ecbaebc..a92b3f0029b 100644 --- a/resource-manager/apimanagement/2022-08-01/tenantconfigurationsyncstate/client.go +++ b/resource-manager/apimanagement/2022-08-01/tenantconfigurationsyncstate/client.go @@ -1,18 +1,26 @@ package tenantconfigurationsyncstate -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 TenantConfigurationSyncStateClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewTenantConfigurationSyncStateClientWithBaseURI(endpoint string) TenantConfigurationSyncStateClient { - return TenantConfigurationSyncStateClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewTenantConfigurationSyncStateClientWithBaseURI(api environments.Api) (*TenantConfigurationSyncStateClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "tenantconfigurationsyncstate", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating TenantConfigurationSyncStateClient: %+v", err) } + + return &TenantConfigurationSyncStateClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2022-08-01/tenantconfigurationsyncstate/method_tenantconfigurationgetsyncstate.go b/resource-manager/apimanagement/2022-08-01/tenantconfigurationsyncstate/method_tenantconfigurationgetsyncstate.go new file mode 100644 index 00000000000..4ea64f710b0 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/tenantconfigurationsyncstate/method_tenantconfigurationgetsyncstate.go @@ -0,0 +1,52 @@ +package tenantconfigurationsyncstate + +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 TenantConfigurationGetSyncStateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *TenantConfigurationSyncStateContract +} + +// TenantConfigurationGetSyncState ... +func (c TenantConfigurationSyncStateClient) TenantConfigurationGetSyncState(ctx context.Context, id ServiceId) (result TenantConfigurationGetSyncStateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/tenant/configuration/syncState", 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/apimanagement/2022-08-01/tenantconfigurationsyncstate/method_tenantconfigurationgetsyncstate_autorest.go b/resource-manager/apimanagement/2022-08-01/tenantconfigurationsyncstate/method_tenantconfigurationgetsyncstate_autorest.go deleted file mode 100644 index 8761b63aaa1..00000000000 --- a/resource-manager/apimanagement/2022-08-01/tenantconfigurationsyncstate/method_tenantconfigurationgetsyncstate_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package tenantconfigurationsyncstate - -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 TenantConfigurationGetSyncStateOperationResponse struct { - HttpResponse *http.Response - Model *TenantConfigurationSyncStateContract -} - -// TenantConfigurationGetSyncState ... -func (c TenantConfigurationSyncStateClient) TenantConfigurationGetSyncState(ctx context.Context, id ServiceId) (result TenantConfigurationGetSyncStateOperationResponse, err error) { - req, err := c.preparerForTenantConfigurationGetSyncState(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "tenantconfigurationsyncstate.TenantConfigurationSyncStateClient", "TenantConfigurationGetSyncState", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "tenantconfigurationsyncstate.TenantConfigurationSyncStateClient", "TenantConfigurationGetSyncState", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForTenantConfigurationGetSyncState(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "tenantconfigurationsyncstate.TenantConfigurationSyncStateClient", "TenantConfigurationGetSyncState", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForTenantConfigurationGetSyncState prepares the TenantConfigurationGetSyncState request. -func (c TenantConfigurationSyncStateClient) preparerForTenantConfigurationGetSyncState(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(fmt.Sprintf("%s/tenant/configuration/syncState", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForTenantConfigurationGetSyncState handles the response to the TenantConfigurationGetSyncState request. The method always -// closes the http.Response Body. -func (c TenantConfigurationSyncStateClient) responderForTenantConfigurationGetSyncState(resp *http.Response) (result TenantConfigurationGetSyncStateOperationResponse, 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/apimanagement/2022-08-01/tenantsettings/client.go b/resource-manager/apimanagement/2022-08-01/tenantsettings/client.go index 1e3e819d2fe..fe0b39c0a78 100644 --- a/resource-manager/apimanagement/2022-08-01/tenantsettings/client.go +++ b/resource-manager/apimanagement/2022-08-01/tenantsettings/client.go @@ -1,18 +1,26 @@ package tenantsettings -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 TenantSettingsClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewTenantSettingsClientWithBaseURI(endpoint string) TenantSettingsClient { - return TenantSettingsClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewTenantSettingsClientWithBaseURI(api environments.Api) (*TenantSettingsClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "tenantsettings", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating TenantSettingsClient: %+v", err) } + + return &TenantSettingsClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2022-08-01/tenantsettings/method_get.go b/resource-manager/apimanagement/2022-08-01/tenantsettings/method_get.go new file mode 100644 index 00000000000..9f42162d776 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/tenantsettings/method_get.go @@ -0,0 +1,52 @@ +package tenantsettings + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *TenantSettingsContract +} + +// Get ... +func (c TenantSettingsClient) 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: fmt.Sprintf("%s/settings/public", 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/apimanagement/2022-08-01/tenantsettings/method_get_autorest.go b/resource-manager/apimanagement/2022-08-01/tenantsettings/method_get_autorest.go deleted file mode 100644 index 5fe75ae615e..00000000000 --- a/resource-manager/apimanagement/2022-08-01/tenantsettings/method_get_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package tenantsettings - -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 GetOperationResponse struct { - HttpResponse *http.Response - Model *TenantSettingsContract -} - -// Get ... -func (c TenantSettingsClient) Get(ctx context.Context, id ServiceId) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "tenantsettings.TenantSettingsClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "tenantsettings.TenantSettingsClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "tenantsettings.TenantSettingsClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c TenantSettingsClient) 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(fmt.Sprintf("%s/settings/public", 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 TenantSettingsClient) 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/apimanagement/2022-08-01/tenantsettings/method_listbyservice.go b/resource-manager/apimanagement/2022-08-01/tenantsettings/method_listbyservice.go new file mode 100644 index 00000000000..6d94b36d733 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/tenantsettings/method_listbyservice.go @@ -0,0 +1,117 @@ +package tenantsettings + +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 ListByServiceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]TenantSettingsContract +} + +type ListByServiceCompleteResult struct { + Items []TenantSettingsContract +} + +type ListByServiceOperationOptions struct { + Filter *string +} + +func DefaultListByServiceOperationOptions() ListByServiceOperationOptions { + return ListByServiceOperationOptions{} +} + +func (o ListByServiceOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListByServiceOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListByServiceOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + return &out +} + +// ListByService ... +func (c TenantSettingsClient) ListByService(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (result ListByServiceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/settings", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]TenantSettingsContract `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByServiceComplete retrieves all the results into a single object +func (c TenantSettingsClient) ListByServiceComplete(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (ListByServiceCompleteResult, error) { + return c.ListByServiceCompleteMatchingPredicate(ctx, id, options, TenantSettingsContractOperationPredicate{}) +} + +// ListByServiceCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c TenantSettingsClient) ListByServiceCompleteMatchingPredicate(ctx context.Context, id ServiceId, options ListByServiceOperationOptions, predicate TenantSettingsContractOperationPredicate) (result ListByServiceCompleteResult, err error) { + items := make([]TenantSettingsContract, 0) + + resp, err := c.ListByService(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByServiceCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/apimanagement/2022-08-01/tenantsettings/method_listbyservice_autorest.go b/resource-manager/apimanagement/2022-08-01/tenantsettings/method_listbyservice_autorest.go deleted file mode 100644 index 1514f996e50..00000000000 --- a/resource-manager/apimanagement/2022-08-01/tenantsettings/method_listbyservice_autorest.go +++ /dev/null @@ -1,215 +0,0 @@ -package tenantsettings - -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 ListByServiceOperationResponse struct { - HttpResponse *http.Response - Model *[]TenantSettingsContract - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListByServiceOperationResponse, error) -} - -type ListByServiceCompleteResult struct { - Items []TenantSettingsContract -} - -func (r ListByServiceOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListByServiceOperationResponse) LoadMore(ctx context.Context) (resp ListByServiceOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -type ListByServiceOperationOptions struct { - Filter *string -} - -func DefaultListByServiceOperationOptions() ListByServiceOperationOptions { - return ListByServiceOperationOptions{} -} - -func (o ListByServiceOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o ListByServiceOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Filter != nil { - out["$filter"] = *o.Filter - } - - return out -} - -// ListByService ... -func (c TenantSettingsClient) ListByService(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (resp ListByServiceOperationResponse, err error) { - req, err := c.preparerForListByService(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "tenantsettings.TenantSettingsClient", "ListByService", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "tenantsettings.TenantSettingsClient", "ListByService", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListByService(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "tenantsettings.TenantSettingsClient", "ListByService", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListByService prepares the ListByService request. -func (c TenantSettingsClient) preparerForListByService(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/settings", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListByServiceWithNextLink prepares the ListByService request with the given nextLink token. -func (c TenantSettingsClient) preparerForListByServiceWithNextLink(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)) -} - -// responderForListByService handles the response to the ListByService request. The method always -// closes the http.Response Body. -func (c TenantSettingsClient) responderForListByService(resp *http.Response) (result ListByServiceOperationResponse, err error) { - type page struct { - Values []TenantSettingsContract `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 ListByServiceOperationResponse, err error) { - req, err := c.preparerForListByServiceWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "tenantsettings.TenantSettingsClient", "ListByService", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "tenantsettings.TenantSettingsClient", "ListByService", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByService(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "tenantsettings.TenantSettingsClient", "ListByService", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListByServiceComplete retrieves all of the results into a single object -func (c TenantSettingsClient) ListByServiceComplete(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (ListByServiceCompleteResult, error) { - return c.ListByServiceCompleteMatchingPredicate(ctx, id, options, TenantSettingsContractOperationPredicate{}) -} - -// ListByServiceCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c TenantSettingsClient) ListByServiceCompleteMatchingPredicate(ctx context.Context, id ServiceId, options ListByServiceOperationOptions, predicate TenantSettingsContractOperationPredicate) (resp ListByServiceCompleteResult, err error) { - items := make([]TenantSettingsContract, 0) - - page, err := c.ListByService(ctx, id, options) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListByServiceCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/apimanagement/2022-08-01/user/client.go b/resource-manager/apimanagement/2022-08-01/user/client.go index edf5ba84ceb..68cdf855892 100644 --- a/resource-manager/apimanagement/2022-08-01/user/client.go +++ b/resource-manager/apimanagement/2022-08-01/user/client.go @@ -1,18 +1,26 @@ package user -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 UserClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewUserClientWithBaseURI(endpoint string) UserClient { - return UserClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewUserClientWithBaseURI(api environments.Api) (*UserClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "user", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating UserClient: %+v", err) } + + return &UserClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2022-08-01/user/constants.go b/resource-manager/apimanagement/2022-08-01/user/constants.go index e5b9de9b614..83573cf87af 100644 --- a/resource-manager/apimanagement/2022-08-01/user/constants.go +++ b/resource-manager/apimanagement/2022-08-01/user/constants.go @@ -1,6 +1,10 @@ package user -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 PossibleValuesForAppType() []string { } } +func (s *AppType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAppType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseAppType(input string) (*AppType, error) { vals := map[string]AppType{ "developerportal": AppTypeDeveloperPortal, @@ -47,6 +64,19 @@ func PossibleValuesForConfirmation() []string { } } +func (s *Confirmation) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseConfirmation(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseConfirmation(input string) (*Confirmation, error) { vals := map[string]Confirmation{ "invite": ConfirmationInvite, @@ -77,6 +107,19 @@ func PossibleValuesForGroupType() []string { } } +func (s *GroupType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseGroupType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseGroupType(input string) (*GroupType, error) { vals := map[string]GroupType{ "custom": GroupTypeCustom, @@ -110,6 +153,19 @@ func PossibleValuesForUserState() []string { } } +func (s *UserState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseUserState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseUserState(input string) (*UserState, error) { vals := map[string]UserState{ "active": UserStateActive, diff --git a/resource-manager/apimanagement/2022-08-01/user/method_createorupdate.go b/resource-manager/apimanagement/2022-08-01/user/method_createorupdate.go new file mode 100644 index 00000000000..6ff0ddbf251 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/user/method_createorupdate.go @@ -0,0 +1,88 @@ +package user + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *UserContract +} + +type CreateOrUpdateOperationOptions struct { + IfMatch *string + Notify *bool +} + +func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { + return CreateOrUpdateOperationOptions{} +} + +func (o CreateOrUpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o CreateOrUpdateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o CreateOrUpdateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Notify != nil { + out.Append("notify", fmt.Sprintf("%v", *o.Notify)) + } + return &out +} + +// CreateOrUpdate ... +func (c UserClient) CreateOrUpdate(ctx context.Context, id UserId, input UserCreateParameters, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + OptionsObject: options, + } + + 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/apimanagement/2022-08-01/user/method_createorupdate_autorest.go b/resource-manager/apimanagement/2022-08-01/user/method_createorupdate_autorest.go deleted file mode 100644 index 2d354273eac..00000000000 --- a/resource-manager/apimanagement/2022-08-01/user/method_createorupdate_autorest.go +++ /dev/null @@ -1,103 +0,0 @@ -package user - -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 *UserContract -} - -type CreateOrUpdateOperationOptions struct { - IfMatch *string - Notify *bool -} - -func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { - return CreateOrUpdateOperationOptions{} -} - -func (o CreateOrUpdateOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o CreateOrUpdateOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Notify != nil { - out["notify"] = *o.Notify - } - - return out -} - -// CreateOrUpdate ... -func (c UserClient) CreateOrUpdate(ctx context.Context, id UserId, input UserCreateParameters, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdate(ctx, id, input, options) - if err != nil { - err = autorest.NewErrorWithError(err, "user.UserClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "user.UserClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCreateOrUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "user.UserClient", "CreateOrUpdate", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCreateOrUpdate prepares the CreateOrUpdate request. -func (c UserClient) preparerForCreateOrUpdate(ctx context.Context, id UserId, input UserCreateParameters, options CreateOrUpdateOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - 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 UserClient) responderForCreateOrUpdate(resp *http.Response) (result CreateOrUpdateOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2022-08-01/user/method_delete.go b/resource-manager/apimanagement/2022-08-01/user/method_delete.go new file mode 100644 index 00000000000..fd6b3518902 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/user/method_delete.go @@ -0,0 +1,87 @@ +package user + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +type DeleteOperationOptions struct { + AppType *AppType + DeleteSubscriptions *bool + IfMatch *string + Notify *bool +} + +func DefaultDeleteOperationOptions() DeleteOperationOptions { + return DeleteOperationOptions{} +} + +func (o DeleteOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o DeleteOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o DeleteOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.AppType != nil { + out.Append("appType", fmt.Sprintf("%v", *o.AppType)) + } + if o.DeleteSubscriptions != nil { + out.Append("deleteSubscriptions", fmt.Sprintf("%v", *o.DeleteSubscriptions)) + } + if o.Notify != nil { + out.Append("notify", fmt.Sprintf("%v", *o.Notify)) + } + return &out +} + +// Delete ... +func (c UserClient) Delete(ctx context.Context, id UserId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2022-08-01/user/method_delete_autorest.go b/resource-manager/apimanagement/2022-08-01/user/method_delete_autorest.go deleted file mode 100644 index 34b48b3fa26..00000000000 --- a/resource-manager/apimanagement/2022-08-01/user/method_delete_autorest.go +++ /dev/null @@ -1,110 +0,0 @@ -package user - -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 DeleteOperationResponse struct { - HttpResponse *http.Response -} - -type DeleteOperationOptions struct { - AppType *AppType - DeleteSubscriptions *bool - IfMatch *string - Notify *bool -} - -func DefaultDeleteOperationOptions() DeleteOperationOptions { - return DeleteOperationOptions{} -} - -func (o DeleteOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o DeleteOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.AppType != nil { - out["appType"] = *o.AppType - } - - if o.DeleteSubscriptions != nil { - out["deleteSubscriptions"] = *o.DeleteSubscriptions - } - - if o.Notify != nil { - out["notify"] = *o.Notify - } - - return out -} - -// Delete ... -func (c UserClient) Delete(ctx context.Context, id UserId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { - req, err := c.preparerForDelete(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "user.UserClient", "Delete", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "user.UserClient", "Delete", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForDelete(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "user.UserClient", "Delete", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForDelete prepares the Delete request. -func (c UserClient) preparerForDelete(ctx context.Context, id UserId, options DeleteOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForDelete handles the response to the Delete request. The method always -// closes the http.Response Body. -func (c UserClient) responderForDelete(resp *http.Response) (result DeleteOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2022-08-01/user/method_get.go b/resource-manager/apimanagement/2022-08-01/user/method_get.go new file mode 100644 index 00000000000..c70fed38ef8 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/user/method_get.go @@ -0,0 +1,51 @@ +package user + +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 *UserContract +} + +// Get ... +func (c UserClient) Get(ctx context.Context, id UserId) (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/apimanagement/2022-08-01/user/method_get_autorest.go b/resource-manager/apimanagement/2022-08-01/user/method_get_autorest.go deleted file mode 100644 index e3b8b477c77..00000000000 --- a/resource-manager/apimanagement/2022-08-01/user/method_get_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package user - -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 *UserContract -} - -// Get ... -func (c UserClient) Get(ctx context.Context, id UserId) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "user.UserClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "user.UserClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "user.UserClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c UserClient) preparerForGet(ctx context.Context, id UserId) (*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 UserClient) 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/apimanagement/2022-08-01/user/method_getentitytag.go b/resource-manager/apimanagement/2022-08-01/user/method_getentitytag.go new file mode 100644 index 00000000000..bc31a7c3697 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/user/method_getentitytag.go @@ -0,0 +1,46 @@ +package user + +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 GetEntityTagOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// GetEntityTag ... +func (c UserClient) GetEntityTag(ctx context.Context, id UserId) (result GetEntityTagOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodHead, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2022-08-01/user/method_getentitytag_autorest.go b/resource-manager/apimanagement/2022-08-01/user/method_getentitytag_autorest.go deleted file mode 100644 index ec2d361cccd..00000000000 --- a/resource-manager/apimanagement/2022-08-01/user/method_getentitytag_autorest.go +++ /dev/null @@ -1,66 +0,0 @@ -package user - -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 GetEntityTagOperationResponse struct { - HttpResponse *http.Response -} - -// GetEntityTag ... -func (c UserClient) GetEntityTag(ctx context.Context, id UserId) (result GetEntityTagOperationResponse, err error) { - req, err := c.preparerForGetEntityTag(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "user.UserClient", "GetEntityTag", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "user.UserClient", "GetEntityTag", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetEntityTag(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "user.UserClient", "GetEntityTag", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetEntityTag prepares the GetEntityTag request. -func (c UserClient) preparerForGetEntityTag(ctx context.Context, id UserId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsHead(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetEntityTag handles the response to the GetEntityTag request. The method always -// closes the http.Response Body. -func (c UserClient) responderForGetEntityTag(resp *http.Response) (result GetEntityTagOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2022-08-01/user/method_listbyservice.go b/resource-manager/apimanagement/2022-08-01/user/method_listbyservice.go new file mode 100644 index 00000000000..5882829e90c --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/user/method_listbyservice.go @@ -0,0 +1,129 @@ +package user + +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 ListByServiceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]UserContract +} + +type ListByServiceCompleteResult struct { + Items []UserContract +} + +type ListByServiceOperationOptions struct { + ExpandGroups *bool + Filter *string + Skip *int64 + Top *int64 +} + +func DefaultListByServiceOperationOptions() ListByServiceOperationOptions { + return ListByServiceOperationOptions{} +} + +func (o ListByServiceOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListByServiceOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListByServiceOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.ExpandGroups != nil { + out.Append("expandGroups", fmt.Sprintf("%v", *o.ExpandGroups)) + } + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.Skip != nil { + out.Append("$skip", fmt.Sprintf("%v", *o.Skip)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +// ListByService ... +func (c UserClient) ListByService(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (result ListByServiceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/users", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]UserContract `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByServiceComplete retrieves all the results into a single object +func (c UserClient) ListByServiceComplete(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (ListByServiceCompleteResult, error) { + return c.ListByServiceCompleteMatchingPredicate(ctx, id, options, UserContractOperationPredicate{}) +} + +// ListByServiceCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c UserClient) ListByServiceCompleteMatchingPredicate(ctx context.Context, id ServiceId, options ListByServiceOperationOptions, predicate UserContractOperationPredicate) (result ListByServiceCompleteResult, err error) { + items := make([]UserContract, 0) + + resp, err := c.ListByService(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByServiceCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/apimanagement/2022-08-01/user/method_listbyservice_autorest.go b/resource-manager/apimanagement/2022-08-01/user/method_listbyservice_autorest.go deleted file mode 100644 index 8304e22f9e4..00000000000 --- a/resource-manager/apimanagement/2022-08-01/user/method_listbyservice_autorest.go +++ /dev/null @@ -1,230 +0,0 @@ -package user - -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 ListByServiceOperationResponse struct { - HttpResponse *http.Response - Model *[]UserContract - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListByServiceOperationResponse, error) -} - -type ListByServiceCompleteResult struct { - Items []UserContract -} - -func (r ListByServiceOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListByServiceOperationResponse) LoadMore(ctx context.Context) (resp ListByServiceOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -type ListByServiceOperationOptions struct { - ExpandGroups *bool - Filter *string - Skip *int64 - Top *int64 -} - -func DefaultListByServiceOperationOptions() ListByServiceOperationOptions { - return ListByServiceOperationOptions{} -} - -func (o ListByServiceOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o ListByServiceOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.ExpandGroups != nil { - out["expandGroups"] = *o.ExpandGroups - } - - if o.Filter != nil { - out["$filter"] = *o.Filter - } - - if o.Skip != nil { - out["$skip"] = *o.Skip - } - - if o.Top != nil { - out["$top"] = *o.Top - } - - return out -} - -// ListByService ... -func (c UserClient) ListByService(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (resp ListByServiceOperationResponse, err error) { - req, err := c.preparerForListByService(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "user.UserClient", "ListByService", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "user.UserClient", "ListByService", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListByService(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "user.UserClient", "ListByService", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListByService prepares the ListByService request. -func (c UserClient) preparerForListByService(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/users", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListByServiceWithNextLink prepares the ListByService request with the given nextLink token. -func (c UserClient) preparerForListByServiceWithNextLink(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)) -} - -// responderForListByService handles the response to the ListByService request. The method always -// closes the http.Response Body. -func (c UserClient) responderForListByService(resp *http.Response) (result ListByServiceOperationResponse, err error) { - type page struct { - Values []UserContract `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 ListByServiceOperationResponse, err error) { - req, err := c.preparerForListByServiceWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "user.UserClient", "ListByService", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "user.UserClient", "ListByService", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByService(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "user.UserClient", "ListByService", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListByServiceComplete retrieves all of the results into a single object -func (c UserClient) ListByServiceComplete(ctx context.Context, id ServiceId, options ListByServiceOperationOptions) (ListByServiceCompleteResult, error) { - return c.ListByServiceCompleteMatchingPredicate(ctx, id, options, UserContractOperationPredicate{}) -} - -// ListByServiceCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c UserClient) ListByServiceCompleteMatchingPredicate(ctx context.Context, id ServiceId, options ListByServiceOperationOptions, predicate UserContractOperationPredicate) (resp ListByServiceCompleteResult, err error) { - items := make([]UserContract, 0) - - page, err := c.ListByService(ctx, id, options) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListByServiceCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/apimanagement/2022-08-01/user/method_update.go b/resource-manager/apimanagement/2022-08-01/user/method_update.go new file mode 100644 index 00000000000..ed43e43248d --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/user/method_update.go @@ -0,0 +1,84 @@ +package user + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *UserContract +} + +type UpdateOperationOptions struct { + IfMatch *string +} + +func DefaultUpdateOperationOptions() UpdateOperationOptions { + return UpdateOperationOptions{} +} + +func (o UpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o UpdateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o UpdateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// Update ... +func (c UserClient) Update(ctx context.Context, id UserId, input UserUpdateParameters, options UpdateOperationOptions) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + OptionsObject: options, + } + + 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/apimanagement/2022-08-01/user/method_update_autorest.go b/resource-manager/apimanagement/2022-08-01/user/method_update_autorest.go deleted file mode 100644 index 38f81f608fd..00000000000 --- a/resource-manager/apimanagement/2022-08-01/user/method_update_autorest.go +++ /dev/null @@ -1,98 +0,0 @@ -package user - -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 *UserContract -} - -type UpdateOperationOptions struct { - IfMatch *string -} - -func DefaultUpdateOperationOptions() UpdateOperationOptions { - return UpdateOperationOptions{} -} - -func (o UpdateOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o UpdateOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// Update ... -func (c UserClient) Update(ctx context.Context, id UserId, input UserUpdateParameters, options UpdateOperationOptions) (result UpdateOperationResponse, err error) { - req, err := c.preparerForUpdate(ctx, id, input, options) - if err != nil { - err = autorest.NewErrorWithError(err, "user.UserClient", "Update", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "user.UserClient", "Update", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "user.UserClient", "Update", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForUpdate prepares the Update request. -func (c UserClient) preparerForUpdate(ctx context.Context, id UserId, input UserUpdateParameters, options UpdateOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPatch(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - 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 UserClient) 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/apimanagement/2022-08-01/userconfirmationpasswordsend/client.go b/resource-manager/apimanagement/2022-08-01/userconfirmationpasswordsend/client.go index 756489454aa..3a81da4d203 100644 --- a/resource-manager/apimanagement/2022-08-01/userconfirmationpasswordsend/client.go +++ b/resource-manager/apimanagement/2022-08-01/userconfirmationpasswordsend/client.go @@ -1,18 +1,26 @@ package userconfirmationpasswordsend -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 UserConfirmationPasswordSendClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewUserConfirmationPasswordSendClientWithBaseURI(endpoint string) UserConfirmationPasswordSendClient { - return UserConfirmationPasswordSendClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewUserConfirmationPasswordSendClientWithBaseURI(api environments.Api) (*UserConfirmationPasswordSendClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "userconfirmationpasswordsend", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating UserConfirmationPasswordSendClient: %+v", err) } + + return &UserConfirmationPasswordSendClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2022-08-01/userconfirmationpasswordsend/constants.go b/resource-manager/apimanagement/2022-08-01/userconfirmationpasswordsend/constants.go index cc153945e69..c532eea3196 100644 --- a/resource-manager/apimanagement/2022-08-01/userconfirmationpasswordsend/constants.go +++ b/resource-manager/apimanagement/2022-08-01/userconfirmationpasswordsend/constants.go @@ -1,6 +1,10 @@ package userconfirmationpasswordsend -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 PossibleValuesForAppType() []string { } } +func (s *AppType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAppType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseAppType(input string) (*AppType, error) { vals := map[string]AppType{ "developerportal": AppTypeDeveloperPortal, diff --git a/resource-manager/apimanagement/2022-08-01/userconfirmationpasswordsend/method_userconfirmationpasswordsend.go b/resource-manager/apimanagement/2022-08-01/userconfirmationpasswordsend/method_userconfirmationpasswordsend.go new file mode 100644 index 00000000000..883292fd0c2 --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/userconfirmationpasswordsend/method_userconfirmationpasswordsend.go @@ -0,0 +1,75 @@ +package userconfirmationpasswordsend + +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 UserConfirmationPasswordSendOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +type UserConfirmationPasswordSendOperationOptions struct { + AppType *AppType +} + +func DefaultUserConfirmationPasswordSendOperationOptions() UserConfirmationPasswordSendOperationOptions { + return UserConfirmationPasswordSendOperationOptions{} +} + +func (o UserConfirmationPasswordSendOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o UserConfirmationPasswordSendOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o UserConfirmationPasswordSendOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.AppType != nil { + out.Append("appType", fmt.Sprintf("%v", *o.AppType)) + } + return &out +} + +// UserConfirmationPasswordSend ... +func (c UserConfirmationPasswordSendClient) UserConfirmationPasswordSend(ctx context.Context, id UserId, options UserConfirmationPasswordSendOperationOptions) (result UserConfirmationPasswordSendOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/confirmations/password/send", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/apimanagement/2022-08-01/userconfirmationpasswordsend/method_userconfirmationpasswordsend_autorest.go b/resource-manager/apimanagement/2022-08-01/userconfirmationpasswordsend/method_userconfirmationpasswordsend_autorest.go deleted file mode 100644 index 8a9f0a68633..00000000000 --- a/resource-manager/apimanagement/2022-08-01/userconfirmationpasswordsend/method_userconfirmationpasswordsend_autorest.go +++ /dev/null @@ -1,96 +0,0 @@ -package userconfirmationpasswordsend - -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 UserConfirmationPasswordSendOperationResponse struct { - HttpResponse *http.Response -} - -type UserConfirmationPasswordSendOperationOptions struct { - AppType *AppType -} - -func DefaultUserConfirmationPasswordSendOperationOptions() UserConfirmationPasswordSendOperationOptions { - return UserConfirmationPasswordSendOperationOptions{} -} - -func (o UserConfirmationPasswordSendOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o UserConfirmationPasswordSendOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.AppType != nil { - out["appType"] = *o.AppType - } - - return out -} - -// UserConfirmationPasswordSend ... -func (c UserConfirmationPasswordSendClient) UserConfirmationPasswordSend(ctx context.Context, id UserId, options UserConfirmationPasswordSendOperationOptions) (result UserConfirmationPasswordSendOperationResponse, err error) { - req, err := c.preparerForUserConfirmationPasswordSend(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "userconfirmationpasswordsend.UserConfirmationPasswordSendClient", "UserConfirmationPasswordSend", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "userconfirmationpasswordsend.UserConfirmationPasswordSendClient", "UserConfirmationPasswordSend", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForUserConfirmationPasswordSend(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "userconfirmationpasswordsend.UserConfirmationPasswordSendClient", "UserConfirmationPasswordSend", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForUserConfirmationPasswordSend prepares the UserConfirmationPasswordSend request. -func (c UserConfirmationPasswordSendClient) preparerForUserConfirmationPasswordSend(ctx context.Context, id UserId, options UserConfirmationPasswordSendOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/confirmations/password/send", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForUserConfirmationPasswordSend handles the response to the UserConfirmationPasswordSend request. The method always -// closes the http.Response Body. -func (c UserConfirmationPasswordSendClient) responderForUserConfirmationPasswordSend(resp *http.Response) (result UserConfirmationPasswordSendOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/apimanagement/2022-08-01/usergroup/client.go b/resource-manager/apimanagement/2022-08-01/usergroup/client.go index d08c65ca35c..c00726aa8ef 100644 --- a/resource-manager/apimanagement/2022-08-01/usergroup/client.go +++ b/resource-manager/apimanagement/2022-08-01/usergroup/client.go @@ -1,18 +1,26 @@ package usergroup -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 UserGroupClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewUserGroupClientWithBaseURI(endpoint string) UserGroupClient { - return UserGroupClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewUserGroupClientWithBaseURI(api environments.Api) (*UserGroupClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "usergroup", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating UserGroupClient: %+v", err) } + + return &UserGroupClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2022-08-01/usergroup/constants.go b/resource-manager/apimanagement/2022-08-01/usergroup/constants.go index ea114107530..8762d75fc71 100644 --- a/resource-manager/apimanagement/2022-08-01/usergroup/constants.go +++ b/resource-manager/apimanagement/2022-08-01/usergroup/constants.go @@ -1,6 +1,10 @@ package usergroup -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 PossibleValuesForGroupType() []string { } } +func (s *GroupType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseGroupType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseGroupType(input string) (*GroupType, error) { vals := map[string]GroupType{ "custom": GroupTypeCustom, diff --git a/resource-manager/apimanagement/2022-08-01/usergroup/method_list.go b/resource-manager/apimanagement/2022-08-01/usergroup/method_list.go new file mode 100644 index 00000000000..c59680e814a --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/usergroup/method_list.go @@ -0,0 +1,125 @@ +package usergroup + +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 *[]GroupContract +} + +type ListCompleteResult struct { + Items []GroupContract +} + +type ListOperationOptions struct { + Filter *string + Skip *int64 + Top *int64 +} + +func DefaultListOperationOptions() ListOperationOptions { + return ListOperationOptions{} +} + +func (o ListOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.Skip != nil { + out.Append("$skip", fmt.Sprintf("%v", *o.Skip)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +// List ... +func (c UserGroupClient) List(ctx context.Context, id UserId, options ListOperationOptions) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/groups", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]GroupContract `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 UserGroupClient) ListComplete(ctx context.Context, id UserId, options ListOperationOptions) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, options, GroupContractOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c UserGroupClient) ListCompleteMatchingPredicate(ctx context.Context, id UserId, options ListOperationOptions, predicate GroupContractOperationPredicate) (result ListCompleteResult, err error) { + items := make([]GroupContract, 0) + + resp, err := c.List(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/apimanagement/2022-08-01/usergroup/method_list_autorest.go b/resource-manager/apimanagement/2022-08-01/usergroup/method_list_autorest.go deleted file mode 100644 index 61e0bb9e690..00000000000 --- a/resource-manager/apimanagement/2022-08-01/usergroup/method_list_autorest.go +++ /dev/null @@ -1,225 +0,0 @@ -package usergroup - -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 *[]GroupContract - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListOperationResponse, error) -} - -type ListCompleteResult struct { - Items []GroupContract -} - -func (r ListOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListOperationResponse) LoadMore(ctx context.Context) (resp ListOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -type ListOperationOptions struct { - Filter *string - Skip *int64 - Top *int64 -} - -func DefaultListOperationOptions() ListOperationOptions { - return ListOperationOptions{} -} - -func (o ListOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o ListOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Filter != nil { - out["$filter"] = *o.Filter - } - - if o.Skip != nil { - out["$skip"] = *o.Skip - } - - if o.Top != nil { - out["$top"] = *o.Top - } - - return out -} - -// List ... -func (c UserGroupClient) List(ctx context.Context, id UserId, options ListOperationOptions) (resp ListOperationResponse, err error) { - req, err := c.preparerForList(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "usergroup.UserGroupClient", "List", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "usergroup.UserGroupClient", "List", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForList(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "usergroup.UserGroupClient", "List", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForList prepares the List request. -func (c UserGroupClient) preparerForList(ctx context.Context, id UserId, options ListOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/groups", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListWithNextLink prepares the List request with the given nextLink token. -func (c UserGroupClient) 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 UserGroupClient) responderForList(resp *http.Response) (result ListOperationResponse, err error) { - type page struct { - Values []GroupContract `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, "usergroup.UserGroupClient", "List", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "usergroup.UserGroupClient", "List", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForList(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "usergroup.UserGroupClient", "List", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListComplete retrieves all of the results into a single object -func (c UserGroupClient) ListComplete(ctx context.Context, id UserId, options ListOperationOptions) (ListCompleteResult, error) { - return c.ListCompleteMatchingPredicate(ctx, id, options, GroupContractOperationPredicate{}) -} - -// ListCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c UserGroupClient) ListCompleteMatchingPredicate(ctx context.Context, id UserId, options ListOperationOptions, predicate GroupContractOperationPredicate) (resp ListCompleteResult, err error) { - items := make([]GroupContract, 0) - - page, err := c.List(ctx, id, options) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/apimanagement/2022-08-01/useridentity/client.go b/resource-manager/apimanagement/2022-08-01/useridentity/client.go index 4ae90e35324..ba69a70cbf8 100644 --- a/resource-manager/apimanagement/2022-08-01/useridentity/client.go +++ b/resource-manager/apimanagement/2022-08-01/useridentity/client.go @@ -1,18 +1,26 @@ package useridentity -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 UserIdentityClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewUserIdentityClientWithBaseURI(endpoint string) UserIdentityClient { - return UserIdentityClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewUserIdentityClientWithBaseURI(api environments.Api) (*UserIdentityClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "useridentity", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating UserIdentityClient: %+v", err) } + + return &UserIdentityClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2022-08-01/useridentity/method_useridentitieslist.go b/resource-manager/apimanagement/2022-08-01/useridentity/method_useridentitieslist.go new file mode 100644 index 00000000000..74e3593f0ab --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/useridentity/method_useridentitieslist.go @@ -0,0 +1,89 @@ +package useridentity + +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 UserIdentitiesListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]UserIdentityContract +} + +type UserIdentitiesListCompleteResult struct { + Items []UserIdentityContract +} + +// UserIdentitiesList ... +func (c UserIdentityClient) UserIdentitiesList(ctx context.Context, id UserId) (result UserIdentitiesListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/identities", 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 *[]UserIdentityContract `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// UserIdentitiesListComplete retrieves all the results into a single object +func (c UserIdentityClient) UserIdentitiesListComplete(ctx context.Context, id UserId) (UserIdentitiesListCompleteResult, error) { + return c.UserIdentitiesListCompleteMatchingPredicate(ctx, id, UserIdentityContractOperationPredicate{}) +} + +// UserIdentitiesListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c UserIdentityClient) UserIdentitiesListCompleteMatchingPredicate(ctx context.Context, id UserId, predicate UserIdentityContractOperationPredicate) (result UserIdentitiesListCompleteResult, err error) { + items := make([]UserIdentityContract, 0) + + resp, err := c.UserIdentitiesList(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 = UserIdentitiesListCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/apimanagement/2022-08-01/useridentity/method_useridentitieslist_autorest.go b/resource-manager/apimanagement/2022-08-01/useridentity/method_useridentitieslist_autorest.go deleted file mode 100644 index 6374338ce31..00000000000 --- a/resource-manager/apimanagement/2022-08-01/useridentity/method_useridentitieslist_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package useridentity - -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 UserIdentitiesListOperationResponse struct { - HttpResponse *http.Response - Model *[]UserIdentityContract - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (UserIdentitiesListOperationResponse, error) -} - -type UserIdentitiesListCompleteResult struct { - Items []UserIdentityContract -} - -func (r UserIdentitiesListOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r UserIdentitiesListOperationResponse) LoadMore(ctx context.Context) (resp UserIdentitiesListOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// UserIdentitiesList ... -func (c UserIdentityClient) UserIdentitiesList(ctx context.Context, id UserId) (resp UserIdentitiesListOperationResponse, err error) { - req, err := c.preparerForUserIdentitiesList(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "useridentity.UserIdentityClient", "UserIdentitiesList", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "useridentity.UserIdentityClient", "UserIdentitiesList", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForUserIdentitiesList(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "useridentity.UserIdentityClient", "UserIdentitiesList", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForUserIdentitiesList prepares the UserIdentitiesList request. -func (c UserIdentityClient) preparerForUserIdentitiesList(ctx context.Context, id UserId) (*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/identities", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForUserIdentitiesListWithNextLink prepares the UserIdentitiesList request with the given nextLink token. -func (c UserIdentityClient) preparerForUserIdentitiesListWithNextLink(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)) -} - -// responderForUserIdentitiesList handles the response to the UserIdentitiesList request. The method always -// closes the http.Response Body. -func (c UserIdentityClient) responderForUserIdentitiesList(resp *http.Response) (result UserIdentitiesListOperationResponse, err error) { - type page struct { - Values []UserIdentityContract `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 UserIdentitiesListOperationResponse, err error) { - req, err := c.preparerForUserIdentitiesListWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "useridentity.UserIdentityClient", "UserIdentitiesList", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "useridentity.UserIdentityClient", "UserIdentitiesList", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForUserIdentitiesList(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "useridentity.UserIdentityClient", "UserIdentitiesList", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// UserIdentitiesListComplete retrieves all of the results into a single object -func (c UserIdentityClient) UserIdentitiesListComplete(ctx context.Context, id UserId) (UserIdentitiesListCompleteResult, error) { - return c.UserIdentitiesListCompleteMatchingPredicate(ctx, id, UserIdentityContractOperationPredicate{}) -} - -// UserIdentitiesListCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c UserIdentityClient) UserIdentitiesListCompleteMatchingPredicate(ctx context.Context, id UserId, predicate UserIdentityContractOperationPredicate) (resp UserIdentitiesListCompleteResult, err error) { - items := make([]UserIdentityContract, 0) - - page, err := c.UserIdentitiesList(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 := UserIdentitiesListCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/apimanagement/2022-08-01/users/client.go b/resource-manager/apimanagement/2022-08-01/users/client.go index eead37dfa09..b2fbba7618b 100644 --- a/resource-manager/apimanagement/2022-08-01/users/client.go +++ b/resource-manager/apimanagement/2022-08-01/users/client.go @@ -1,18 +1,26 @@ package users -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 UsersClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewUsersClientWithBaseURI(endpoint string) UsersClient { - return UsersClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewUsersClientWithBaseURI(api environments.Api) (*UsersClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "users", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating UsersClient: %+v", err) } + + return &UsersClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2022-08-01/users/method_usergeneratessourl.go b/resource-manager/apimanagement/2022-08-01/users/method_usergeneratessourl.go new file mode 100644 index 00000000000..9cf69e473cf --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/users/method_usergeneratessourl.go @@ -0,0 +1,52 @@ +package users + +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 UserGenerateSsoUrlOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *GenerateSsoUrlResult +} + +// UserGenerateSsoUrl ... +func (c UsersClient) UserGenerateSsoUrl(ctx context.Context, id UserId) (result UserGenerateSsoUrlOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/generateSsoUrl", 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/apimanagement/2022-08-01/users/method_usergeneratessourl_autorest.go b/resource-manager/apimanagement/2022-08-01/users/method_usergeneratessourl_autorest.go deleted file mode 100644 index 90bf6c3ad37..00000000000 --- a/resource-manager/apimanagement/2022-08-01/users/method_usergeneratessourl_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package users - -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 UserGenerateSsoUrlOperationResponse struct { - HttpResponse *http.Response - Model *GenerateSsoUrlResult -} - -// UserGenerateSsoUrl ... -func (c UsersClient) UserGenerateSsoUrl(ctx context.Context, id UserId) (result UserGenerateSsoUrlOperationResponse, err error) { - req, err := c.preparerForUserGenerateSsoUrl(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "users.UsersClient", "UserGenerateSsoUrl", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "users.UsersClient", "UserGenerateSsoUrl", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForUserGenerateSsoUrl(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "users.UsersClient", "UserGenerateSsoUrl", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForUserGenerateSsoUrl prepares the UserGenerateSsoUrl request. -func (c UsersClient) preparerForUserGenerateSsoUrl(ctx context.Context, id UserId) (*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/generateSsoUrl", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForUserGenerateSsoUrl handles the response to the UserGenerateSsoUrl request. The method always -// closes the http.Response Body. -func (c UsersClient) responderForUserGenerateSsoUrl(resp *http.Response) (result UserGenerateSsoUrlOperationResponse, 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/apimanagement/2022-08-01/usersubscription/client.go b/resource-manager/apimanagement/2022-08-01/usersubscription/client.go index d3ba8ac4ce8..2b0a8bfdf91 100644 --- a/resource-manager/apimanagement/2022-08-01/usersubscription/client.go +++ b/resource-manager/apimanagement/2022-08-01/usersubscription/client.go @@ -1,18 +1,26 @@ package usersubscription -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 UserSubscriptionClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewUserSubscriptionClientWithBaseURI(endpoint string) UserSubscriptionClient { - return UserSubscriptionClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewUserSubscriptionClientWithBaseURI(api environments.Api) (*UserSubscriptionClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "usersubscription", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating UserSubscriptionClient: %+v", err) } + + return &UserSubscriptionClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2022-08-01/usersubscription/constants.go b/resource-manager/apimanagement/2022-08-01/usersubscription/constants.go index f7ed9ea1ce6..8999ff3cae7 100644 --- a/resource-manager/apimanagement/2022-08-01/usersubscription/constants.go +++ b/resource-manager/apimanagement/2022-08-01/usersubscription/constants.go @@ -1,6 +1,10 @@ package usersubscription -import "strings" +import ( + "encoding/json" + "fmt" + "strings" +) // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See NOTICE.txt in the project root for license information. @@ -27,6 +31,19 @@ func PossibleValuesForSubscriptionState() []string { } } +func (s *SubscriptionState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSubscriptionState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseSubscriptionState(input string) (*SubscriptionState, error) { vals := map[string]SubscriptionState{ "active": SubscriptionStateActive, diff --git a/resource-manager/apimanagement/2022-08-01/usersubscription/method_list.go b/resource-manager/apimanagement/2022-08-01/usersubscription/method_list.go new file mode 100644 index 00000000000..e66d1f8242d --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/usersubscription/method_list.go @@ -0,0 +1,125 @@ +package usersubscription + +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 *[]SubscriptionContract +} + +type ListCompleteResult struct { + Items []SubscriptionContract +} + +type ListOperationOptions struct { + Filter *string + Skip *int64 + Top *int64 +} + +func DefaultListOperationOptions() ListOperationOptions { + return ListOperationOptions{} +} + +func (o ListOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.Skip != nil { + out.Append("$skip", fmt.Sprintf("%v", *o.Skip)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +// List ... +func (c UserSubscriptionClient) List(ctx context.Context, id UserId, options ListOperationOptions) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/subscriptions", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]SubscriptionContract `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 UserSubscriptionClient) ListComplete(ctx context.Context, id UserId, options ListOperationOptions) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, options, SubscriptionContractOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c UserSubscriptionClient) ListCompleteMatchingPredicate(ctx context.Context, id UserId, options ListOperationOptions, predicate SubscriptionContractOperationPredicate) (result ListCompleteResult, err error) { + items := make([]SubscriptionContract, 0) + + resp, err := c.List(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/apimanagement/2022-08-01/usersubscription/method_list_autorest.go b/resource-manager/apimanagement/2022-08-01/usersubscription/method_list_autorest.go deleted file mode 100644 index e7fd01255cc..00000000000 --- a/resource-manager/apimanagement/2022-08-01/usersubscription/method_list_autorest.go +++ /dev/null @@ -1,225 +0,0 @@ -package usersubscription - -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 *[]SubscriptionContract - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListOperationResponse, error) -} - -type ListCompleteResult struct { - Items []SubscriptionContract -} - -func (r ListOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListOperationResponse) LoadMore(ctx context.Context) (resp ListOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -type ListOperationOptions struct { - Filter *string - Skip *int64 - Top *int64 -} - -func DefaultListOperationOptions() ListOperationOptions { - return ListOperationOptions{} -} - -func (o ListOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o ListOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Filter != nil { - out["$filter"] = *o.Filter - } - - if o.Skip != nil { - out["$skip"] = *o.Skip - } - - if o.Top != nil { - out["$top"] = *o.Top - } - - return out -} - -// List ... -func (c UserSubscriptionClient) List(ctx context.Context, id UserId, options ListOperationOptions) (resp ListOperationResponse, err error) { - req, err := c.preparerForList(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "usersubscription.UserSubscriptionClient", "List", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "usersubscription.UserSubscriptionClient", "List", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForList(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "usersubscription.UserSubscriptionClient", "List", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForList prepares the List request. -func (c UserSubscriptionClient) preparerForList(ctx context.Context, id UserId, options ListOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/subscriptions", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListWithNextLink prepares the List request with the given nextLink token. -func (c UserSubscriptionClient) 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 UserSubscriptionClient) responderForList(resp *http.Response) (result ListOperationResponse, err error) { - type page struct { - Values []SubscriptionContract `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, "usersubscription.UserSubscriptionClient", "List", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "usersubscription.UserSubscriptionClient", "List", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForList(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "usersubscription.UserSubscriptionClient", "List", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListComplete retrieves all of the results into a single object -func (c UserSubscriptionClient) ListComplete(ctx context.Context, id UserId, options ListOperationOptions) (ListCompleteResult, error) { - return c.ListCompleteMatchingPredicate(ctx, id, options, SubscriptionContractOperationPredicate{}) -} - -// ListCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c UserSubscriptionClient) ListCompleteMatchingPredicate(ctx context.Context, id UserId, options ListOperationOptions, predicate SubscriptionContractOperationPredicate) (resp ListCompleteResult, err error) { - items := make([]SubscriptionContract, 0) - - page, err := c.List(ctx, id, options) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/apimanagement/2022-08-01/usertoken/client.go b/resource-manager/apimanagement/2022-08-01/usertoken/client.go index ba17707e000..d1c1e1db7b3 100644 --- a/resource-manager/apimanagement/2022-08-01/usertoken/client.go +++ b/resource-manager/apimanagement/2022-08-01/usertoken/client.go @@ -1,18 +1,26 @@ package usertoken -import "github.com/Azure/go-autorest/autorest" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 UserTokenClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewUserTokenClientWithBaseURI(endpoint string) UserTokenClient { - return UserTokenClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewUserTokenClientWithBaseURI(api environments.Api) (*UserTokenClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "usertoken", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating UserTokenClient: %+v", err) } + + return &UserTokenClient{ + Client: client, + }, nil } diff --git a/resource-manager/apimanagement/2022-08-01/usertoken/constants.go b/resource-manager/apimanagement/2022-08-01/usertoken/constants.go index 9a1db97e8df..9c811483fc3 100644 --- a/resource-manager/apimanagement/2022-08-01/usertoken/constants.go +++ b/resource-manager/apimanagement/2022-08-01/usertoken/constants.go @@ -1,6 +1,10 @@ package usertoken -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 PossibleValuesForKeyType() []string { } } +func (s *KeyType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseKeyType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseKeyType(input string) (*KeyType, error) { vals := map[string]KeyType{ "primary": KeyTypePrimary, diff --git a/resource-manager/apimanagement/2022-08-01/usertoken/method_usergetsharedaccesstoken.go b/resource-manager/apimanagement/2022-08-01/usertoken/method_usergetsharedaccesstoken.go new file mode 100644 index 00000000000..c4fe631328a --- /dev/null +++ b/resource-manager/apimanagement/2022-08-01/usertoken/method_usergetsharedaccesstoken.go @@ -0,0 +1,56 @@ +package usertoken + +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 UserGetSharedAccessTokenOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *UserTokenResult +} + +// UserGetSharedAccessToken ... +func (c UserTokenClient) UserGetSharedAccessToken(ctx context.Context, id UserId, input UserTokenParameters) (result UserGetSharedAccessTokenOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/token", 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/apimanagement/2022-08-01/usertoken/method_usergetsharedaccesstoken_autorest.go b/resource-manager/apimanagement/2022-08-01/usertoken/method_usergetsharedaccesstoken_autorest.go deleted file mode 100644 index 75e4e070eb0..00000000000 --- a/resource-manager/apimanagement/2022-08-01/usertoken/method_usergetsharedaccesstoken_autorest.go +++ /dev/null @@ -1,70 +0,0 @@ -package usertoken - -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 UserGetSharedAccessTokenOperationResponse struct { - HttpResponse *http.Response - Model *UserTokenResult -} - -// UserGetSharedAccessToken ... -func (c UserTokenClient) UserGetSharedAccessToken(ctx context.Context, id UserId, input UserTokenParameters) (result UserGetSharedAccessTokenOperationResponse, err error) { - req, err := c.preparerForUserGetSharedAccessToken(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "usertoken.UserTokenClient", "UserGetSharedAccessToken", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "usertoken.UserTokenClient", "UserGetSharedAccessToken", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForUserGetSharedAccessToken(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "usertoken.UserTokenClient", "UserGetSharedAccessToken", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForUserGetSharedAccessToken prepares the UserGetSharedAccessToken request. -func (c UserTokenClient) preparerForUserGetSharedAccessToken(ctx context.Context, id UserId, input UserTokenParameters) (*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/token", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForUserGetSharedAccessToken handles the response to the UserGetSharedAccessToken request. The method always -// closes the http.Response Body. -func (c UserTokenClient) responderForUserGetSharedAccessToken(resp *http.Response) (result UserGetSharedAccessTokenOperationResponse, 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/network/2023-04-01/applicationgateways/model_applicationgatewayfrontendipconfigurationpropertiesformat.go b/resource-manager/network/2023-04-01/applicationgateways/model_applicationgatewayfrontendipconfigurationpropertiesformat.go index 53872f5b7a8..45f83bbaa11 100644 --- a/resource-manager/network/2023-04-01/applicationgateways/model_applicationgatewayfrontendipconfigurationpropertiesformat.go +++ b/resource-manager/network/2023-04-01/applicationgateways/model_applicationgatewayfrontendipconfigurationpropertiesformat.go @@ -4,7 +4,6 @@ package applicationgateways // Licensed under the MIT License. See NOTICE.txt in the project root for license information. type ApplicationGatewayFrontendIPConfigurationPropertiesFormat struct { - HTTPListeners *SubResource `json:"httpListeners,omitempty"` PrivateIPAddress *string `json:"privateIPAddress,omitempty"` PrivateIPAllocationMethod *IPAllocationMethod `json:"privateIPAllocationMethod,omitempty"` PrivateLinkConfiguration *SubResource `json:"privateLinkConfiguration,omitempty"` diff --git a/resource-manager/network/2023-04-01/webapplicationfirewallpolicies/model_applicationgatewayfrontendipconfigurationpropertiesformat.go b/resource-manager/network/2023-04-01/webapplicationfirewallpolicies/model_applicationgatewayfrontendipconfigurationpropertiesformat.go index 254ea6c523d..1b61dc71c1d 100644 --- a/resource-manager/network/2023-04-01/webapplicationfirewallpolicies/model_applicationgatewayfrontendipconfigurationpropertiesformat.go +++ b/resource-manager/network/2023-04-01/webapplicationfirewallpolicies/model_applicationgatewayfrontendipconfigurationpropertiesformat.go @@ -4,7 +4,6 @@ package webapplicationfirewallpolicies // Licensed under the MIT License. See NOTICE.txt in the project root for license information. type ApplicationGatewayFrontendIPConfigurationPropertiesFormat struct { - HTTPListeners *SubResource `json:"httpListeners,omitempty"` PrivateIPAddress *string `json:"privateIPAddress,omitempty"` PrivateIPAllocationMethod *IPAllocationMethod `json:"privateIPAllocationMethod,omitempty"` PrivateLinkConfiguration *SubResource `json:"privateLinkConfiguration,omitempty"`