From cdb1f74bd4d005994e130b97c430c2f8da21fb0c Mon Sep 17 00:00:00 2001 From: xiaxin18 Date: Wed, 16 Feb 2022 09:32:41 +0800 Subject: [PATCH 01/22] hc dicom service --- internal/services/healthcare/client/client.go | 7 + .../healthcare_apis_dicom_resource.go | 121 ++++++ .../sdk/2021-01-11/collection/client.go | 15 + .../sdk/2021-01-11/collection/constants.go | 210 ++++++++++ .../method_serviceslist_autorest.go | 184 +++++++++ ...od_serviceslistbyresourcegroup_autorest.go | 184 +++++++++ .../collection/model_privateendpoint.go | 5 + .../model_privateendpointconnection.go | 8 + ...del_privateendpointconnectionproperties.go | 7 + ...model_privatelinkserviceconnectionstate.go | 7 + .../model_serviceaccesspolicyentry.go | 5 + .../model_serviceacrconfigurationinfo.go | 5 + ..._serviceauthenticationconfigurationinfo.go | 7 + .../model_servicecorsconfigurationinfo.go | 9 + .../model_servicecosmosdbconfigurationinfo.go | 6 + .../model_serviceexportconfigurationinfo.go | 5 + .../collection/model_servicesdescription.go | 18 + .../collection/model_servicesproperties.go | 13 + .../2021-01-11/collection/model_systemdata.go | 40 ++ .../sdk/2021-01-11/collection/predicates.go | 34 ++ .../sdk/2021-01-11/collection/version.go | 9 + .../privateendpointconnections/client.go | 15 + .../privateendpointconnections/constants.go | 102 +++++ .../id_privateendpointconnection.go | 137 +++++++ .../id_privateendpointconnection_test.go | 324 +++++++++++++++ .../privateendpointconnections/id_service.go | 124 ++++++ .../id_service_test.go | 279 +++++++++++++ .../method_createorupdate_autorest.go | 75 ++++ .../method_delete_autorest.go | 74 ++++ .../method_get_autorest.go | 64 +++ .../method_listbyservice_autorest.go | 65 +++ .../model_privateendpoint.go | 5 + .../model_privateendpointconnection.go | 8 + ...el_privateendpointconnectiondescription.go | 9 + ...endpointconnectionlistresultdescription.go | 5 + ...del_privateendpointconnectionproperties.go | 7 + ...model_privatelinkserviceconnectionstate.go | 7 + .../model_systemdata.go | 40 ++ .../privateendpointconnections/version.go | 9 + .../2021-01-11/privatelinkresources/client.go | 15 + .../privatelinkresources/constants.go | 37 ++ .../id_privatelinkresource.go | 137 +++++++ .../id_privatelinkresource_test.go | 324 +++++++++++++++ .../privatelinkresources/id_service.go | 124 ++++++ .../privatelinkresources/id_service_test.go | 279 +++++++++++++ .../method_get_autorest.go | 64 +++ .../method_listbyservice_autorest.go | 65 +++ .../model_privatelinkresourcedescription.go | 9 + ...rivatelinkresourcelistresultdescription.go | 5 + .../model_privatelinkresourceproperties.go | 7 + .../privatelinkresources/model_systemdata.go | 40 ++ .../privatelinkresources/version.go | 9 + .../healthcare/sdk/2021-01-11/proxy/client.go | 15 + .../sdk/2021-01-11/proxy/constants.go | 31 ++ ..._serviceschecknameavailability_autorest.go | 67 ++++ .../model_checknameavailabilityparameters.go | 6 + .../model_servicesnameavailabilityinfo.go | 7 + .../sdk/2021-01-11/proxy/version.go | 9 + .../sdk/2021-01-11/resource/client.go | 15 + .../sdk/2021-01-11/resource/constants.go | 210 ++++++++++ .../sdk/2021-01-11/resource/id_service.go | 124 ++++++ .../2021-01-11/resource/id_service_test.go | 279 +++++++++++++ .../method_servicescreateorupdate_autorest.go | 75 ++++ .../method_servicesdelete_autorest.go | 74 ++++ .../resource/method_servicesget_autorest.go | 64 +++ .../method_servicesupdate_autorest.go | 75 ++++ .../resource/model_privateendpoint.go | 5 + .../model_privateendpointconnection.go | 8 + ...del_privateendpointconnectionproperties.go | 7 + ...model_privatelinkserviceconnectionstate.go | 7 + .../model_serviceaccesspolicyentry.go | 5 + .../model_serviceacrconfigurationinfo.go | 5 + ..._serviceauthenticationconfigurationinfo.go | 7 + .../model_servicecorsconfigurationinfo.go | 9 + .../model_servicecosmosdbconfigurationinfo.go | 6 + .../model_serviceexportconfigurationinfo.go | 5 + .../resource/model_servicesdescription.go | 18 + .../model_servicespatchdescription.go | 6 + .../resource/model_servicesproperties.go | 13 + ...odel_servicespropertiesupdateparameters.go | 5 + .../2021-01-11/resource/model_systemdata.go | 40 ++ .../sdk/2021-01-11/resource/version.go | 9 + .../2021-06-01-preview/collection/client.go | 15 + .../collection/constants.go | 210 ++++++++++ .../method_serviceslist_autorest.go | 184 +++++++++ ...od_serviceslistbyresourcegroup_autorest.go | 184 +++++++++ .../collection/model_privateendpoint.go | 5 + .../model_privateendpointconnection.go | 8 + ...del_privateendpointconnectionproperties.go | 7 + ...model_privatelinkserviceconnectionstate.go | 7 + .../model_serviceaccesspolicyentry.go | 5 + .../model_serviceacrconfigurationinfo.go | 5 + ..._serviceauthenticationconfigurationinfo.go | 7 + .../model_servicecorsconfigurationinfo.go | 9 + .../model_servicecosmosdbconfigurationinfo.go | 6 + .../model_serviceexportconfigurationinfo.go | 5 + .../collection/model_servicesdescription.go | 18 + .../collection/model_servicesproperties.go | 13 + .../collection/model_systemdata.go | 40 ++ .../collection/predicates.go | 34 ++ .../2021-06-01-preview/collection/version.go | 9 + .../dicomservices/client.go | 15 + .../dicomservices/constants.go | 98 +++++ .../dicomservices/id_dicomservice.go | 137 +++++++ .../dicomservices/id_dicomservice_test.go | 324 +++++++++++++++ .../dicomservices/id_workspace.go | 124 ++++++ .../dicomservices/id_workspace_test.go | 279 +++++++++++++ .../method_createorupdate_autorest.go | 75 ++++ .../dicomservices/method_delete_autorest.go | 74 ++++ .../dicomservices/method_get_autorest.go | 64 +++ .../method_listbyworkspace_autorest.go | 183 +++++++++ .../dicomservices/method_update_autorest.go | 75 ++++ .../dicomservices/model_dicomservice.go | 12 + ...dicomserviceauthenticationconfiguration.go | 6 + .../model_dicomserviceproperties.go | 7 + .../dicomservices/model_resourcetags.go | 5 + .../dicomservices/model_systemdata.go | 40 ++ .../dicomservices/predicates.go | 34 ++ .../dicomservices/version.go | 9 + .../2021-06-01-preview/fhirservices/client.go | 15 + .../fhirservices/constants.go | 154 ++++++++ .../fhirservices/id_fhirservice.go | 137 +++++++ .../fhirservices/id_fhirservice_test.go | 324 +++++++++++++++ .../fhirservices/id_workspace.go | 124 ++++++ .../fhirservices/id_workspace_test.go | 279 +++++++++++++ .../method_createorupdate_autorest.go | 75 ++++ .../fhirservices/method_delete_autorest.go | 74 ++++ .../fhirservices/method_get_autorest.go | 64 +++ .../method_listbyworkspace_autorest.go | 183 +++++++++ .../fhirservices/method_update_autorest.go | 75 ++++ .../fhirservices/model_fhirservice.go | 14 + .../model_fhirserviceaccesspolicyentry.go | 5 + .../model_fhirserviceacrconfiguration.go | 5 + ..._fhirserviceauthenticationconfiguration.go | 7 + .../model_fhirservicecorsconfiguration.go | 9 + .../model_fhirserviceexportconfiguration.go | 5 + .../model_fhirservicepatchresource.go | 6 + .../model_fhirserviceproperties.go | 10 + .../model_servicemanagedidentityidentity.go | 5 + .../fhirservices/model_systemdata.go | 40 ++ .../fhirservices/predicates.go | 34 ++ .../fhirservices/version.go | 9 + .../iotconnectors/client.go | 15 + .../iotconnectors/constants.go | 154 ++++++++ .../iotconnectors/id_fhirdestination.go | 150 +++++++ .../iotconnectors/id_fhirdestination_test.go | 369 ++++++++++++++++++ .../iotconnectors/id_iotconnector.go | 137 +++++++ .../iotconnectors/id_iotconnector_test.go | 324 +++++++++++++++ .../iotconnectors/id_workspace.go | 124 ++++++ .../iotconnectors/id_workspace_test.go | 279 +++++++++++++ .../method_createorupdate_autorest.go | 75 ++++ .../iotconnectors/method_delete_autorest.go | 74 ++++ ...destinationslistbyiotconnector_autorest.go | 183 +++++++++ .../iotconnectors/method_get_autorest.go | 64 +++ ...rfhirdestinationcreateorupdate_autorest.go | 75 ++++ ...connectorfhirdestinationdelete_autorest.go | 74 ++++ ...iotconnectorfhirdestinationget_autorest.go | 64 +++ .../method_listbyworkspace_autorest.go | 183 +++++++++ .../iotconnectors/method_update_autorest.go | 75 ++++ .../iotconnectors/model_iotconnector.go | 13 + .../model_iotconnectorpatchresource.go | 6 + .../model_iotconnectorproperties.go | 7 + ...teventhubingestionendpointconfiguration.go | 7 + .../iotconnectors/model_iotfhirdestination.go | 11 + .../model_iotfhirdestinationproperties.go | 8 + .../model_iotmappingproperties.go | 5 + .../model_servicemanagedidentityidentity.go | 5 + .../iotconnectors/model_systemdata.go | 40 ++ .../iotconnectors/predicates.go | 67 ++++ .../iotconnectors/version.go | 9 + .../privateendpointconnections/client.go | 15 + .../privateendpointconnections/constants.go | 102 +++++ .../id_privateendpointconnection.go | 137 +++++++ .../id_privateendpointconnection_test.go | 324 +++++++++++++++ .../privateendpointconnections/id_service.go | 124 ++++++ .../id_service_test.go | 279 +++++++++++++ .../method_createorupdate_autorest.go | 75 ++++ .../method_delete_autorest.go | 74 ++++ .../method_get_autorest.go | 64 +++ .../method_listbyservice_autorest.go | 65 +++ .../model_privateendpoint.go | 5 + .../model_privateendpointconnection.go | 8 + ...el_privateendpointconnectiondescription.go | 9 + ...endpointconnectionlistresultdescription.go | 5 + ...del_privateendpointconnectionproperties.go | 7 + ...model_privatelinkserviceconnectionstate.go | 7 + .../model_systemdata.go | 40 ++ .../privateendpointconnections/version.go | 9 + .../privatelinkresources/client.go | 15 + .../privatelinkresources/constants.go | 37 ++ .../id_privatelinkresource.go | 137 +++++++ .../id_privatelinkresource_test.go | 324 +++++++++++++++ .../privatelinkresources/id_service.go | 124 ++++++ .../privatelinkresources/id_service_test.go | 279 +++++++++++++ .../method_get_autorest.go | 64 +++ .../method_listbyservice_autorest.go | 65 +++ .../model_privatelinkresourcedescription.go | 9 + ...rivatelinkresourcelistresultdescription.go | 5 + .../model_privatelinkresourceproperties.go | 7 + .../privatelinkresources/model_systemdata.go | 40 ++ .../privatelinkresources/version.go | 9 + .../sdk/2021-06-01-preview/proxy/client.go | 15 + .../sdk/2021-06-01-preview/proxy/constants.go | 31 ++ ..._serviceschecknameavailability_autorest.go | 67 ++++ .../model_checknameavailabilityparameters.go | 6 + .../model_servicesnameavailabilityinfo.go | 7 + .../sdk/2021-06-01-preview/proxy/version.go | 9 + .../sdk/2021-06-01-preview/resource/client.go | 15 + .../2021-06-01-preview/resource/constants.go | 210 ++++++++++ .../2021-06-01-preview/resource/id_service.go | 124 ++++++ .../resource/id_service_test.go | 279 +++++++++++++ .../method_servicescreateorupdate_autorest.go | 75 ++++ .../method_servicesdelete_autorest.go | 74 ++++ .../resource/method_servicesget_autorest.go | 64 +++ .../method_servicesupdate_autorest.go | 75 ++++ .../resource/model_privateendpoint.go | 5 + .../model_privateendpointconnection.go | 8 + ...del_privateendpointconnectionproperties.go | 7 + ...model_privatelinkserviceconnectionstate.go | 7 + .../model_serviceaccesspolicyentry.go | 5 + .../model_serviceacrconfigurationinfo.go | 5 + ..._serviceauthenticationconfigurationinfo.go | 7 + .../model_servicecorsconfigurationinfo.go | 9 + .../model_servicecosmosdbconfigurationinfo.go | 6 + .../model_serviceexportconfigurationinfo.go | 5 + .../resource/model_servicesdescription.go | 18 + .../model_servicespatchdescription.go | 6 + .../resource/model_servicesproperties.go | 13 + ...odel_servicespropertiesupdateparameters.go | 5 + .../resource/model_systemdata.go | 40 ++ .../2021-06-01-preview/resource/version.go | 9 + .../2021-06-01-preview/workspaces/client.go | 15 + .../workspaces/constants.go | 98 +++++ .../workspaces/id_workspace.go | 124 ++++++ .../workspaces/id_workspace_test.go | 279 +++++++++++++ .../method_createorupdate_autorest.go | 75 ++++ .../workspaces/method_delete_autorest.go | 74 ++++ .../workspaces/method_get_autorest.go | 64 +++ .../method_listbyresourcegroup_autorest.go | 184 +++++++++ .../method_listbysubscription_autorest.go | 184 +++++++++ .../workspaces/method_update_autorest.go | 75 ++++ .../workspaces/model_resourcetags.go | 5 + .../workspaces/model_systemdata.go | 40 ++ .../workspaces/model_workspace.go | 12 + .../workspaces/model_workspaceproperties.go | 5 + .../workspaces/predicates.go | 34 ++ .../2021-06-01-preview/workspaces/version.go | 9 + 247 files changed, 16098 insertions(+) create mode 100644 internal/services/healthcare/healthcare_apis_dicom_resource.go create mode 100644 internal/services/healthcare/sdk/2021-01-11/collection/client.go create mode 100644 internal/services/healthcare/sdk/2021-01-11/collection/constants.go create mode 100644 internal/services/healthcare/sdk/2021-01-11/collection/method_serviceslist_autorest.go create mode 100644 internal/services/healthcare/sdk/2021-01-11/collection/method_serviceslistbyresourcegroup_autorest.go create mode 100644 internal/services/healthcare/sdk/2021-01-11/collection/model_privateendpoint.go create mode 100644 internal/services/healthcare/sdk/2021-01-11/collection/model_privateendpointconnection.go create mode 100644 internal/services/healthcare/sdk/2021-01-11/collection/model_privateendpointconnectionproperties.go create mode 100644 internal/services/healthcare/sdk/2021-01-11/collection/model_privatelinkserviceconnectionstate.go create mode 100644 internal/services/healthcare/sdk/2021-01-11/collection/model_serviceaccesspolicyentry.go create mode 100644 internal/services/healthcare/sdk/2021-01-11/collection/model_serviceacrconfigurationinfo.go create mode 100644 internal/services/healthcare/sdk/2021-01-11/collection/model_serviceauthenticationconfigurationinfo.go create mode 100644 internal/services/healthcare/sdk/2021-01-11/collection/model_servicecorsconfigurationinfo.go create mode 100644 internal/services/healthcare/sdk/2021-01-11/collection/model_servicecosmosdbconfigurationinfo.go create mode 100644 internal/services/healthcare/sdk/2021-01-11/collection/model_serviceexportconfigurationinfo.go create mode 100644 internal/services/healthcare/sdk/2021-01-11/collection/model_servicesdescription.go create mode 100644 internal/services/healthcare/sdk/2021-01-11/collection/model_servicesproperties.go create mode 100644 internal/services/healthcare/sdk/2021-01-11/collection/model_systemdata.go create mode 100644 internal/services/healthcare/sdk/2021-01-11/collection/predicates.go create mode 100644 internal/services/healthcare/sdk/2021-01-11/collection/version.go create mode 100644 internal/services/healthcare/sdk/2021-01-11/privateendpointconnections/client.go create mode 100644 internal/services/healthcare/sdk/2021-01-11/privateendpointconnections/constants.go create mode 100644 internal/services/healthcare/sdk/2021-01-11/privateendpointconnections/id_privateendpointconnection.go create mode 100644 internal/services/healthcare/sdk/2021-01-11/privateendpointconnections/id_privateendpointconnection_test.go create mode 100644 internal/services/healthcare/sdk/2021-01-11/privateendpointconnections/id_service.go create mode 100644 internal/services/healthcare/sdk/2021-01-11/privateendpointconnections/id_service_test.go create mode 100644 internal/services/healthcare/sdk/2021-01-11/privateendpointconnections/method_createorupdate_autorest.go create mode 100644 internal/services/healthcare/sdk/2021-01-11/privateendpointconnections/method_delete_autorest.go create mode 100644 internal/services/healthcare/sdk/2021-01-11/privateendpointconnections/method_get_autorest.go create mode 100644 internal/services/healthcare/sdk/2021-01-11/privateendpointconnections/method_listbyservice_autorest.go create mode 100644 internal/services/healthcare/sdk/2021-01-11/privateendpointconnections/model_privateendpoint.go create mode 100644 internal/services/healthcare/sdk/2021-01-11/privateendpointconnections/model_privateendpointconnection.go create mode 100644 internal/services/healthcare/sdk/2021-01-11/privateendpointconnections/model_privateendpointconnectiondescription.go create mode 100644 internal/services/healthcare/sdk/2021-01-11/privateendpointconnections/model_privateendpointconnectionlistresultdescription.go create mode 100644 internal/services/healthcare/sdk/2021-01-11/privateendpointconnections/model_privateendpointconnectionproperties.go create mode 100644 internal/services/healthcare/sdk/2021-01-11/privateendpointconnections/model_privatelinkserviceconnectionstate.go create mode 100644 internal/services/healthcare/sdk/2021-01-11/privateendpointconnections/model_systemdata.go create mode 100644 internal/services/healthcare/sdk/2021-01-11/privateendpointconnections/version.go create mode 100644 internal/services/healthcare/sdk/2021-01-11/privatelinkresources/client.go create mode 100644 internal/services/healthcare/sdk/2021-01-11/privatelinkresources/constants.go create mode 100644 internal/services/healthcare/sdk/2021-01-11/privatelinkresources/id_privatelinkresource.go create mode 100644 internal/services/healthcare/sdk/2021-01-11/privatelinkresources/id_privatelinkresource_test.go create mode 100644 internal/services/healthcare/sdk/2021-01-11/privatelinkresources/id_service.go create mode 100644 internal/services/healthcare/sdk/2021-01-11/privatelinkresources/id_service_test.go create mode 100644 internal/services/healthcare/sdk/2021-01-11/privatelinkresources/method_get_autorest.go create mode 100644 internal/services/healthcare/sdk/2021-01-11/privatelinkresources/method_listbyservice_autorest.go create mode 100644 internal/services/healthcare/sdk/2021-01-11/privatelinkresources/model_privatelinkresourcedescription.go create mode 100644 internal/services/healthcare/sdk/2021-01-11/privatelinkresources/model_privatelinkresourcelistresultdescription.go create mode 100644 internal/services/healthcare/sdk/2021-01-11/privatelinkresources/model_privatelinkresourceproperties.go create mode 100644 internal/services/healthcare/sdk/2021-01-11/privatelinkresources/model_systemdata.go create mode 100644 internal/services/healthcare/sdk/2021-01-11/privatelinkresources/version.go create mode 100644 internal/services/healthcare/sdk/2021-01-11/proxy/client.go create mode 100644 internal/services/healthcare/sdk/2021-01-11/proxy/constants.go create mode 100644 internal/services/healthcare/sdk/2021-01-11/proxy/method_serviceschecknameavailability_autorest.go create mode 100644 internal/services/healthcare/sdk/2021-01-11/proxy/model_checknameavailabilityparameters.go create mode 100644 internal/services/healthcare/sdk/2021-01-11/proxy/model_servicesnameavailabilityinfo.go create mode 100644 internal/services/healthcare/sdk/2021-01-11/proxy/version.go create mode 100644 internal/services/healthcare/sdk/2021-01-11/resource/client.go create mode 100644 internal/services/healthcare/sdk/2021-01-11/resource/constants.go create mode 100644 internal/services/healthcare/sdk/2021-01-11/resource/id_service.go create mode 100644 internal/services/healthcare/sdk/2021-01-11/resource/id_service_test.go create mode 100644 internal/services/healthcare/sdk/2021-01-11/resource/method_servicescreateorupdate_autorest.go create mode 100644 internal/services/healthcare/sdk/2021-01-11/resource/method_servicesdelete_autorest.go create mode 100644 internal/services/healthcare/sdk/2021-01-11/resource/method_servicesget_autorest.go create mode 100644 internal/services/healthcare/sdk/2021-01-11/resource/method_servicesupdate_autorest.go create mode 100644 internal/services/healthcare/sdk/2021-01-11/resource/model_privateendpoint.go create mode 100644 internal/services/healthcare/sdk/2021-01-11/resource/model_privateendpointconnection.go create mode 100644 internal/services/healthcare/sdk/2021-01-11/resource/model_privateendpointconnectionproperties.go create mode 100644 internal/services/healthcare/sdk/2021-01-11/resource/model_privatelinkserviceconnectionstate.go create mode 100644 internal/services/healthcare/sdk/2021-01-11/resource/model_serviceaccesspolicyentry.go create mode 100644 internal/services/healthcare/sdk/2021-01-11/resource/model_serviceacrconfigurationinfo.go create mode 100644 internal/services/healthcare/sdk/2021-01-11/resource/model_serviceauthenticationconfigurationinfo.go create mode 100644 internal/services/healthcare/sdk/2021-01-11/resource/model_servicecorsconfigurationinfo.go create mode 100644 internal/services/healthcare/sdk/2021-01-11/resource/model_servicecosmosdbconfigurationinfo.go create mode 100644 internal/services/healthcare/sdk/2021-01-11/resource/model_serviceexportconfigurationinfo.go create mode 100644 internal/services/healthcare/sdk/2021-01-11/resource/model_servicesdescription.go create mode 100644 internal/services/healthcare/sdk/2021-01-11/resource/model_servicespatchdescription.go create mode 100644 internal/services/healthcare/sdk/2021-01-11/resource/model_servicesproperties.go create mode 100644 internal/services/healthcare/sdk/2021-01-11/resource/model_servicespropertiesupdateparameters.go create mode 100644 internal/services/healthcare/sdk/2021-01-11/resource/model_systemdata.go create mode 100644 internal/services/healthcare/sdk/2021-01-11/resource/version.go create mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/collection/client.go create mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/collection/constants.go create mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/collection/method_serviceslist_autorest.go create mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/collection/method_serviceslistbyresourcegroup_autorest.go create mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/collection/model_privateendpoint.go create mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/collection/model_privateendpointconnection.go create mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/collection/model_privateendpointconnectionproperties.go create mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/collection/model_privatelinkserviceconnectionstate.go create mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/collection/model_serviceaccesspolicyentry.go create mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/collection/model_serviceacrconfigurationinfo.go create mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/collection/model_serviceauthenticationconfigurationinfo.go create mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/collection/model_servicecorsconfigurationinfo.go create mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/collection/model_servicecosmosdbconfigurationinfo.go create mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/collection/model_serviceexportconfigurationinfo.go create mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/collection/model_servicesdescription.go create mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/collection/model_servicesproperties.go create mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/collection/model_systemdata.go create mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/collection/predicates.go create mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/collection/version.go create mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/dicomservices/client.go create mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/dicomservices/constants.go create mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/dicomservices/id_dicomservice.go create mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/dicomservices/id_dicomservice_test.go create mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/dicomservices/id_workspace.go create mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/dicomservices/id_workspace_test.go create mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/dicomservices/method_createorupdate_autorest.go create mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/dicomservices/method_delete_autorest.go create mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/dicomservices/method_get_autorest.go create mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/dicomservices/method_listbyworkspace_autorest.go create mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/dicomservices/method_update_autorest.go create mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/dicomservices/model_dicomservice.go create mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/dicomservices/model_dicomserviceauthenticationconfiguration.go create mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/dicomservices/model_dicomserviceproperties.go create mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/dicomservices/model_resourcetags.go create mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/dicomservices/model_systemdata.go create mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/dicomservices/predicates.go create mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/dicomservices/version.go create mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/client.go create mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/constants.go create mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/id_fhirservice.go create mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/id_fhirservice_test.go create mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/id_workspace.go create mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/id_workspace_test.go create mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/method_createorupdate_autorest.go create mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/method_delete_autorest.go create mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/method_get_autorest.go create mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/method_listbyworkspace_autorest.go create mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/method_update_autorest.go create mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/model_fhirservice.go create mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/model_fhirserviceaccesspolicyentry.go create mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/model_fhirserviceacrconfiguration.go create mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/model_fhirserviceauthenticationconfiguration.go create mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/model_fhirservicecorsconfiguration.go create mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/model_fhirserviceexportconfiguration.go create mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/model_fhirservicepatchresource.go create mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/model_fhirserviceproperties.go create mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/model_servicemanagedidentityidentity.go create mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/model_systemdata.go create mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/predicates.go create mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/version.go create mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/client.go create mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/constants.go create mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/id_fhirdestination.go create mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/id_fhirdestination_test.go create mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/id_iotconnector.go create mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/id_iotconnector_test.go create mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/id_workspace.go create mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/id_workspace_test.go create mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/method_createorupdate_autorest.go create mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/method_delete_autorest.go create mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/method_fhirdestinationslistbyiotconnector_autorest.go create mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/method_get_autorest.go create mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/method_iotconnectorfhirdestinationcreateorupdate_autorest.go create mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/method_iotconnectorfhirdestinationdelete_autorest.go create mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/method_iotconnectorfhirdestinationget_autorest.go create mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/method_listbyworkspace_autorest.go create mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/method_update_autorest.go create mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/model_iotconnector.go create mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/model_iotconnectorpatchresource.go create mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/model_iotconnectorproperties.go create mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/model_ioteventhubingestionendpointconfiguration.go create mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/model_iotfhirdestination.go create mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/model_iotfhirdestinationproperties.go create mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/model_iotmappingproperties.go create mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/model_servicemanagedidentityidentity.go create mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/model_systemdata.go create mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/predicates.go create mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/version.go create mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/privateendpointconnections/client.go create mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/privateendpointconnections/constants.go create mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/privateendpointconnections/id_privateendpointconnection.go create mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/privateendpointconnections/id_privateendpointconnection_test.go create mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/privateendpointconnections/id_service.go create mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/privateendpointconnections/id_service_test.go create mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/privateendpointconnections/method_createorupdate_autorest.go create mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/privateendpointconnections/method_delete_autorest.go create mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/privateendpointconnections/method_get_autorest.go create mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/privateendpointconnections/method_listbyservice_autorest.go create mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/privateendpointconnections/model_privateendpoint.go create mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/privateendpointconnections/model_privateendpointconnection.go create mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/privateendpointconnections/model_privateendpointconnectiondescription.go create mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/privateendpointconnections/model_privateendpointconnectionlistresultdescription.go create mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/privateendpointconnections/model_privateendpointconnectionproperties.go create mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/privateendpointconnections/model_privatelinkserviceconnectionstate.go create mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/privateendpointconnections/model_systemdata.go create mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/privateendpointconnections/version.go create mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/privatelinkresources/client.go create mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/privatelinkresources/constants.go create mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/privatelinkresources/id_privatelinkresource.go create mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/privatelinkresources/id_privatelinkresource_test.go create mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/privatelinkresources/id_service.go create mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/privatelinkresources/id_service_test.go create mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/privatelinkresources/method_get_autorest.go create mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/privatelinkresources/method_listbyservice_autorest.go create mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/privatelinkresources/model_privatelinkresourcedescription.go create mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/privatelinkresources/model_privatelinkresourcelistresultdescription.go create mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/privatelinkresources/model_privatelinkresourceproperties.go create mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/privatelinkresources/model_systemdata.go create mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/privatelinkresources/version.go create mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/proxy/client.go create mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/proxy/constants.go create mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/proxy/method_serviceschecknameavailability_autorest.go create mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/proxy/model_checknameavailabilityparameters.go create mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/proxy/model_servicesnameavailabilityinfo.go create mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/proxy/version.go create mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/resource/client.go create mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/resource/constants.go create mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/resource/id_service.go create mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/resource/id_service_test.go create mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/resource/method_servicescreateorupdate_autorest.go create mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/resource/method_servicesdelete_autorest.go create mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/resource/method_servicesget_autorest.go create mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/resource/method_servicesupdate_autorest.go create mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/resource/model_privateendpoint.go create mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/resource/model_privateendpointconnection.go create mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/resource/model_privateendpointconnectionproperties.go create mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/resource/model_privatelinkserviceconnectionstate.go create mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/resource/model_serviceaccesspolicyentry.go create mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/resource/model_serviceacrconfigurationinfo.go create mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/resource/model_serviceauthenticationconfigurationinfo.go create mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/resource/model_servicecorsconfigurationinfo.go create mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/resource/model_servicecosmosdbconfigurationinfo.go create mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/resource/model_serviceexportconfigurationinfo.go create mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/resource/model_servicesdescription.go create mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/resource/model_servicespatchdescription.go create mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/resource/model_servicesproperties.go create mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/resource/model_servicespropertiesupdateparameters.go create mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/resource/model_systemdata.go create mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/resource/version.go create mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/workspaces/client.go create mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/workspaces/constants.go create mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/workspaces/id_workspace.go create mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/workspaces/id_workspace_test.go create mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/workspaces/method_createorupdate_autorest.go create mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/workspaces/method_delete_autorest.go create mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/workspaces/method_get_autorest.go create mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/workspaces/method_listbyresourcegroup_autorest.go create mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/workspaces/method_listbysubscription_autorest.go create mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/workspaces/method_update_autorest.go create mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/workspaces/model_resourcetags.go create mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/workspaces/model_systemdata.go create mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/workspaces/model_workspace.go create mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/workspaces/model_workspaceproperties.go create mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/workspaces/predicates.go create mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/workspaces/version.go diff --git a/internal/services/healthcare/client/client.go b/internal/services/healthcare/client/client.go index 42c700678457..52a344a1bef5 100644 --- a/internal/services/healthcare/client/client.go +++ b/internal/services/healthcare/client/client.go @@ -3,17 +3,24 @@ package client import ( healthcare "github.com/Azure/azure-sdk-for-go/services/healthcareapis/mgmt/2020-03-30/healthcareapis" "github.com/hashicorp/terraform-provider-azurerm/internal/common" + healthcareWorkspaceDicom "github.com/hashicorp/terraform-provider-azurerm/internal/services/healthcare/sdk/2021-06-01-preview/dicomservices" + ) type Client struct { HealthcareServiceClient *healthcare.ServicesClient + HealthcareWorkspaceDicomServiceClient *healthcareWorkspaceDicom.DicomServicesClient } func NewClient(o *common.ClientOptions) *Client { HealthcareServiceClient := healthcare.NewServicesClientWithBaseURI(o.ResourceManagerEndpoint, o.SubscriptionId) o.ConfigureClient(&HealthcareServiceClient.Client, o.ResourceManagerAuthorizer) + HealthcareWorkspaceDicomServiceClient := healthcareWorkspaceDicom.NewDicomServicesClientWithBaseURI(o.ResourceManagerEndpoint) + o.ConfigureClient(&HealthcareWorkspaceDicomServiceClient.Client, o.ResourceManagerAuthorizer) + return &Client{ HealthcareServiceClient: &HealthcareServiceClient, + HealthcareWorkspaceDicomServiceClient: &HealthcareWorkspaceDicomServiceClient, } } diff --git a/internal/services/healthcare/healthcare_apis_dicom_resource.go b/internal/services/healthcare/healthcare_apis_dicom_resource.go new file mode 100644 index 000000000000..150b45d726b3 --- /dev/null +++ b/internal/services/healthcare/healthcare_apis_dicom_resource.go @@ -0,0 +1,121 @@ +package healthcare + +import ( + "fmt" + "github.com/hashicorp/go-azure-helpers/lang/response" + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema" + "github.com/hashicorp/terraform-provider-azurerm/helpers/azure" + "github.com/hashicorp/terraform-provider-azurerm/helpers/tf" + "github.com/hashicorp/terraform-provider-azurerm/internal/clients" + dicomService "github.com/hashicorp/terraform-provider-azurerm/internal/services/healthcare/sdk/2021-06-01-preview/dicomservices" + "github.com/hashicorp/terraform-provider-azurerm/internal/services/healthcare/sdk/2021-06-01-preview/workspaces" + "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" + "github.com/hashicorp/terraform-provider-azurerm/internal/timeouts" + "log" + "time" +) + +func resourceHealthcareApisDicomService() *pluginsdk.Resource { + return &pluginsdk.Resource{ + Create: resourceHealthcareApisDicomServiceCreateUpdate, + Read: resourceHealthcareApisDicomServiceRead, + Update: resourceHealthcareApisDicomServiceCreateUpdate, + Delete: resourceHealthcareApisDicomServiceDelete, + + Timeouts: &pluginsdk.ResourceTimeout{ + Create: pluginsdk.DefaultTimeout(30 * time.Minute), + Read: pluginsdk.DefaultTimeout(5 * time.Minute), + Update: pluginsdk.DefaultTimeout(30 * time.Minute), + Delete: pluginsdk.DefaultTimeout(30 * time.Minute), + }, + + Importer: pluginsdk.ImporterValidatingResourceId(func(id string) error { + _, err := dicomService.ParseDicomServiceID(id) + return err + }), + + Schema: map[string]*pluginsdk.Schema{ + "name": { + Type: pluginsdk.TypeString, + Required: true, + ForceNew: true, + //todo check the validation func + }, + + "workspace_id": { + Type: pluginsdk.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: workspaces.ValidateWorkspaceID, + }, + + "location": azure.SchemaLocation(), + + "authentication_configuration": { + Type: pluginsdk.TypeList, + Optional: true, + MaxItems: 1, + Elem: &pluginsdk.Resource{ + Schema: map[string]*pluginsdk.Schema{ + "authority": { + Type: pluginsdk.TypeString, + Optional: true, + //todo: must follow https://login.microsoft.com/tenantid + }, + "audience": { + Type: pluginsdk.TypeString, + Optional: true, + }, + "smart_proxy_enabled": { + Type: pluginsdk.TypeBool, + Optional: true, + }, + }, + }, + }, + + "tags": commonschema.Tags(), + }, + } +} + +func resourceHealthcareApisDicomServiceCreateUpdate(d *pluginsdk.ResourceData, meta interface{}) error { + client := meta.(*clients.Client).HealthCare.HealthcareWorkspaceDicomServiceClient + ctx, cancel := timeouts.ForCreateUpdate(meta.(*clients.Client).StopContext, d) + defer cancel() + log.Printf("[INFO] preparing arguments for AzureRM Healthcare Dicom Service creation.") + + workspace, err := workspaces.ParseWorkspaceIDInsensitively(d.Get("workspace_id").(string)) + if err != nil { + return fmt.Errorf("parsing healthcare workspace error: %+v", err) + } + + dicomServiceId := dicomService.NewDicomServiceID(workspace.SubscriptionId, workspace.ResourceGroupName, workspace.WorkspaceName, d.Get("name").(string)) + + if d.IsNewResource() { + existing, err := client.Get(ctx, dicomServiceId) + if err != nil { + if !response.WasNotFound(existing.HttpResponse) { + return fmt.Errorf("checking for presense of existing %s: %+v", dicomServiceId, err) + } + } + + if existing.Model != nil { + return tf.ImportAsExistsError("azurerm_healthcareapis_dicom_service", dicomServiceId.ID()) + } + } + + //parameters := dicomService.DicomService{ + // Name: utils.String(dicomServiceId.DicomServiceName), + // Location: utils.String(azure.NormalizeLocation(d.Get("location").(string))), + //} + return resourceHealthcareApisDicomServiceRead(d, meta) +} + +func resourceHealthcareApisDicomServiceRead(d *pluginsdk.ResourceData, meta interface{}) error { + return nil +} + +func resourceHealthcareApisDicomServiceDelete(d *pluginsdk.ResourceData, meta interface{}) error { + return nil +} diff --git a/internal/services/healthcare/sdk/2021-01-11/collection/client.go b/internal/services/healthcare/sdk/2021-01-11/collection/client.go new file mode 100644 index 000000000000..9c73b5b57183 --- /dev/null +++ b/internal/services/healthcare/sdk/2021-01-11/collection/client.go @@ -0,0 +1,15 @@ +package collection + +import "github.com/Azure/go-autorest/autorest" + +type CollectionClient struct { + Client autorest.Client + baseUri string +} + +func NewCollectionClientWithBaseURI(endpoint string) CollectionClient { + return CollectionClient{ + Client: autorest.NewClientWithUserAgent(userAgent()), + baseUri: endpoint, + } +} diff --git a/internal/services/healthcare/sdk/2021-01-11/collection/constants.go b/internal/services/healthcare/sdk/2021-01-11/collection/constants.go new file mode 100644 index 000000000000..b26711c9a119 --- /dev/null +++ b/internal/services/healthcare/sdk/2021-01-11/collection/constants.go @@ -0,0 +1,210 @@ +package collection + +import "strings" + +type CreatedByType string + +const ( + CreatedByTypeApplication CreatedByType = "Application" + CreatedByTypeKey CreatedByType = "Key" + CreatedByTypeManagedIdentity CreatedByType = "ManagedIdentity" + CreatedByTypeUser CreatedByType = "User" +) + +func PossibleValuesForCreatedByType() []string { + return []string{ + string(CreatedByTypeApplication), + string(CreatedByTypeKey), + string(CreatedByTypeManagedIdentity), + string(CreatedByTypeUser), + } +} + +func parseCreatedByType(input string) (*CreatedByType, error) { + vals := map[string]CreatedByType{ + "application": CreatedByTypeApplication, + "key": CreatedByTypeKey, + "managedidentity": CreatedByTypeManagedIdentity, + "user": CreatedByTypeUser, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := CreatedByType(input) + return &out, nil +} + +type Kind string + +const ( + KindFhir Kind = "fhir" + KindFhirNegativeRFour Kind = "fhir-R4" + KindFhirNegativeStuThree Kind = "fhir-Stu3" +) + +func PossibleValuesForKind() []string { + return []string{ + string(KindFhir), + string(KindFhirNegativeRFour), + string(KindFhirNegativeStuThree), + } +} + +func parseKind(input string) (*Kind, error) { + vals := map[string]Kind{ + "fhir": KindFhir, + "fhir-r4": KindFhirNegativeRFour, + "fhir-stu3": KindFhirNegativeStuThree, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := Kind(input) + return &out, nil +} + +type PrivateEndpointConnectionProvisioningState string + +const ( + PrivateEndpointConnectionProvisioningStateCreating PrivateEndpointConnectionProvisioningState = "Creating" + PrivateEndpointConnectionProvisioningStateDeleting PrivateEndpointConnectionProvisioningState = "Deleting" + PrivateEndpointConnectionProvisioningStateFailed PrivateEndpointConnectionProvisioningState = "Failed" + PrivateEndpointConnectionProvisioningStateSucceeded PrivateEndpointConnectionProvisioningState = "Succeeded" +) + +func PossibleValuesForPrivateEndpointConnectionProvisioningState() []string { + return []string{ + string(PrivateEndpointConnectionProvisioningStateCreating), + string(PrivateEndpointConnectionProvisioningStateDeleting), + string(PrivateEndpointConnectionProvisioningStateFailed), + string(PrivateEndpointConnectionProvisioningStateSucceeded), + } +} + +func parsePrivateEndpointConnectionProvisioningState(input string) (*PrivateEndpointConnectionProvisioningState, error) { + vals := map[string]PrivateEndpointConnectionProvisioningState{ + "creating": PrivateEndpointConnectionProvisioningStateCreating, + "deleting": PrivateEndpointConnectionProvisioningStateDeleting, + "failed": PrivateEndpointConnectionProvisioningStateFailed, + "succeeded": PrivateEndpointConnectionProvisioningStateSucceeded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PrivateEndpointConnectionProvisioningState(input) + return &out, nil +} + +type PrivateEndpointServiceConnectionStatus string + +const ( + PrivateEndpointServiceConnectionStatusApproved PrivateEndpointServiceConnectionStatus = "Approved" + PrivateEndpointServiceConnectionStatusPending PrivateEndpointServiceConnectionStatus = "Pending" + PrivateEndpointServiceConnectionStatusRejected PrivateEndpointServiceConnectionStatus = "Rejected" +) + +func PossibleValuesForPrivateEndpointServiceConnectionStatus() []string { + return []string{ + string(PrivateEndpointServiceConnectionStatusApproved), + string(PrivateEndpointServiceConnectionStatusPending), + string(PrivateEndpointServiceConnectionStatusRejected), + } +} + +func parsePrivateEndpointServiceConnectionStatus(input string) (*PrivateEndpointServiceConnectionStatus, error) { + vals := map[string]PrivateEndpointServiceConnectionStatus{ + "approved": PrivateEndpointServiceConnectionStatusApproved, + "pending": PrivateEndpointServiceConnectionStatusPending, + "rejected": PrivateEndpointServiceConnectionStatusRejected, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PrivateEndpointServiceConnectionStatus(input) + return &out, nil +} + +type ProvisioningState string + +const ( + ProvisioningStateAccepted ProvisioningState = "Accepted" + ProvisioningStateCanceled ProvisioningState = "Canceled" + ProvisioningStateCreating ProvisioningState = "Creating" + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateDeprovisioned ProvisioningState = "Deprovisioned" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + ProvisioningStateUpdating ProvisioningState = "Updating" + ProvisioningStateVerifying ProvisioningState = "Verifying" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateAccepted), + string(ProvisioningStateCanceled), + string(ProvisioningStateCreating), + string(ProvisioningStateDeleting), + string(ProvisioningStateDeprovisioned), + string(ProvisioningStateFailed), + string(ProvisioningStateSucceeded), + string(ProvisioningStateUpdating), + string(ProvisioningStateVerifying), + } +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "accepted": ProvisioningStateAccepted, + "canceled": ProvisioningStateCanceled, + "creating": ProvisioningStateCreating, + "deleting": ProvisioningStateDeleting, + "deprovisioned": ProvisioningStateDeprovisioned, + "failed": ProvisioningStateFailed, + "succeeded": ProvisioningStateSucceeded, + "updating": ProvisioningStateUpdating, + "verifying": ProvisioningStateVerifying, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} + +type PublicNetworkAccess string + +const ( + PublicNetworkAccessDisabled PublicNetworkAccess = "Disabled" + PublicNetworkAccessEnabled PublicNetworkAccess = "Enabled" +) + +func PossibleValuesForPublicNetworkAccess() []string { + return []string{ + string(PublicNetworkAccessDisabled), + string(PublicNetworkAccessEnabled), + } +} + +func parsePublicNetworkAccess(input string) (*PublicNetworkAccess, error) { + vals := map[string]PublicNetworkAccess{ + "disabled": PublicNetworkAccessDisabled, + "enabled": PublicNetworkAccessEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PublicNetworkAccess(input) + return &out, nil +} diff --git a/internal/services/healthcare/sdk/2021-01-11/collection/method_serviceslist_autorest.go b/internal/services/healthcare/sdk/2021-01-11/collection/method_serviceslist_autorest.go new file mode 100644 index 000000000000..43106463a451 --- /dev/null +++ b/internal/services/healthcare/sdk/2021-01-11/collection/method_serviceslist_autorest.go @@ -0,0 +1,184 @@ +package collection + +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" +) + +type ServicesListResponse struct { + HttpResponse *http.Response + Model *[]ServicesDescription + + nextLink *string + nextPageFunc func(ctx context.Context, nextLink string) (ServicesListResponse, error) +} + +type ServicesListCompleteResult struct { + Items []ServicesDescription +} + +func (r ServicesListResponse) HasMore() bool { + return r.nextLink != nil +} + +func (r ServicesListResponse) LoadMore(ctx context.Context) (resp ServicesListResponse, err error) { + if !r.HasMore() { + err = fmt.Errorf("no more pages returned") + return + } + return r.nextPageFunc(ctx, *r.nextLink) +} + +// ServicesList ... +func (c CollectionClient) ServicesList(ctx context.Context, id commonids.SubscriptionId) (resp ServicesListResponse, err error) { + req, err := c.preparerForServicesList(ctx, id) + if err != nil { + err = autorest.NewErrorWithError(err, "collection.CollectionClient", "ServicesList", nil, "Failure preparing request") + return + } + + resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "collection.CollectionClient", "ServicesList", resp.HttpResponse, "Failure sending request") + return + } + + resp, err = c.responderForServicesList(resp.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "collection.CollectionClient", "ServicesList", resp.HttpResponse, "Failure responding to request") + return + } + return +} + +// ServicesListComplete retrieves all of the results into a single object +func (c CollectionClient) ServicesListComplete(ctx context.Context, id commonids.SubscriptionId) (ServicesListCompleteResult, error) { + return c.ServicesListCompleteMatchingPredicate(ctx, id, ServicesDescriptionPredicate{}) +} + +// ServicesListCompleteMatchingPredicate retrieves all of the results and then applied the predicate +func (c CollectionClient) ServicesListCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate ServicesDescriptionPredicate) (resp ServicesListCompleteResult, err error) { + items := make([]ServicesDescription, 0) + + page, err := c.ServicesList(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 := ServicesListCompleteResult{ + Items: items, + } + return out, nil +} + +// preparerForServicesList prepares the ServicesList request. +func (c CollectionClient) preparerForServicesList(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.HealthcareApis/services", id.ID())), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// preparerForServicesListWithNextLink prepares the ServicesList request with the given nextLink token. +func (c CollectionClient) preparerForServicesListWithNextLink(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)) +} + +// responderForServicesList handles the response to the ServicesList request. The method always +// closes the http.Response Body. +func (c CollectionClient) responderForServicesList(resp *http.Response) (result ServicesListResponse, err error) { + type page struct { + Values []ServicesDescription `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 ServicesListResponse, err error) { + req, err := c.preparerForServicesListWithNextLink(ctx, nextLink) + if err != nil { + err = autorest.NewErrorWithError(err, "collection.CollectionClient", "ServicesList", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "collection.CollectionClient", "ServicesList", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForServicesList(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "collection.CollectionClient", "ServicesList", result.HttpResponse, "Failure responding to request") + return + } + + return + } + } + return +} diff --git a/internal/services/healthcare/sdk/2021-01-11/collection/method_serviceslistbyresourcegroup_autorest.go b/internal/services/healthcare/sdk/2021-01-11/collection/method_serviceslistbyresourcegroup_autorest.go new file mode 100644 index 000000000000..b57331bf1292 --- /dev/null +++ b/internal/services/healthcare/sdk/2021-01-11/collection/method_serviceslistbyresourcegroup_autorest.go @@ -0,0 +1,184 @@ +package collection + +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" +) + +type ServicesListByResourceGroupResponse struct { + HttpResponse *http.Response + Model *[]ServicesDescription + + nextLink *string + nextPageFunc func(ctx context.Context, nextLink string) (ServicesListByResourceGroupResponse, error) +} + +type ServicesListByResourceGroupCompleteResult struct { + Items []ServicesDescription +} + +func (r ServicesListByResourceGroupResponse) HasMore() bool { + return r.nextLink != nil +} + +func (r ServicesListByResourceGroupResponse) LoadMore(ctx context.Context) (resp ServicesListByResourceGroupResponse, err error) { + if !r.HasMore() { + err = fmt.Errorf("no more pages returned") + return + } + return r.nextPageFunc(ctx, *r.nextLink) +} + +// ServicesListByResourceGroup ... +func (c CollectionClient) ServicesListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (resp ServicesListByResourceGroupResponse, err error) { + req, err := c.preparerForServicesListByResourceGroup(ctx, id) + if err != nil { + err = autorest.NewErrorWithError(err, "collection.CollectionClient", "ServicesListByResourceGroup", nil, "Failure preparing request") + return + } + + resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "collection.CollectionClient", "ServicesListByResourceGroup", resp.HttpResponse, "Failure sending request") + return + } + + resp, err = c.responderForServicesListByResourceGroup(resp.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "collection.CollectionClient", "ServicesListByResourceGroup", resp.HttpResponse, "Failure responding to request") + return + } + return +} + +// ServicesListByResourceGroupComplete retrieves all of the results into a single object +func (c CollectionClient) ServicesListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (ServicesListByResourceGroupCompleteResult, error) { + return c.ServicesListByResourceGroupCompleteMatchingPredicate(ctx, id, ServicesDescriptionPredicate{}) +} + +// ServicesListByResourceGroupCompleteMatchingPredicate retrieves all of the results and then applied the predicate +func (c CollectionClient) ServicesListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate ServicesDescriptionPredicate) (resp ServicesListByResourceGroupCompleteResult, err error) { + items := make([]ServicesDescription, 0) + + page, err := c.ServicesListByResourceGroup(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 := ServicesListByResourceGroupCompleteResult{ + Items: items, + } + return out, nil +} + +// preparerForServicesListByResourceGroup prepares the ServicesListByResourceGroup request. +func (c CollectionClient) preparerForServicesListByResourceGroup(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.HealthcareApis/services", id.ID())), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// preparerForServicesListByResourceGroupWithNextLink prepares the ServicesListByResourceGroup request with the given nextLink token. +func (c CollectionClient) preparerForServicesListByResourceGroupWithNextLink(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)) +} + +// responderForServicesListByResourceGroup handles the response to the ServicesListByResourceGroup request. The method always +// closes the http.Response Body. +func (c CollectionClient) responderForServicesListByResourceGroup(resp *http.Response) (result ServicesListByResourceGroupResponse, err error) { + type page struct { + Values []ServicesDescription `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 ServicesListByResourceGroupResponse, err error) { + req, err := c.preparerForServicesListByResourceGroupWithNextLink(ctx, nextLink) + if err != nil { + err = autorest.NewErrorWithError(err, "collection.CollectionClient", "ServicesListByResourceGroup", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "collection.CollectionClient", "ServicesListByResourceGroup", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForServicesListByResourceGroup(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "collection.CollectionClient", "ServicesListByResourceGroup", result.HttpResponse, "Failure responding to request") + return + } + + return + } + } + return +} diff --git a/internal/services/healthcare/sdk/2021-01-11/collection/model_privateendpoint.go b/internal/services/healthcare/sdk/2021-01-11/collection/model_privateendpoint.go new file mode 100644 index 000000000000..4fbaafd6baef --- /dev/null +++ b/internal/services/healthcare/sdk/2021-01-11/collection/model_privateendpoint.go @@ -0,0 +1,5 @@ +package collection + +type PrivateEndpoint struct { + Id *string `json:"id,omitempty"` +} diff --git a/internal/services/healthcare/sdk/2021-01-11/collection/model_privateendpointconnection.go b/internal/services/healthcare/sdk/2021-01-11/collection/model_privateendpointconnection.go new file mode 100644 index 000000000000..bb27ca23f744 --- /dev/null +++ b/internal/services/healthcare/sdk/2021-01-11/collection/model_privateendpointconnection.go @@ -0,0 +1,8 @@ +package collection + +type PrivateEndpointConnection struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateEndpointConnectionProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/internal/services/healthcare/sdk/2021-01-11/collection/model_privateendpointconnectionproperties.go b/internal/services/healthcare/sdk/2021-01-11/collection/model_privateendpointconnectionproperties.go new file mode 100644 index 000000000000..4610ed7818db --- /dev/null +++ b/internal/services/healthcare/sdk/2021-01-11/collection/model_privateendpointconnectionproperties.go @@ -0,0 +1,7 @@ +package collection + +type PrivateEndpointConnectionProperties struct { + PrivateEndpoint *PrivateEndpoint `json:"privateEndpoint,omitempty"` + PrivateLinkServiceConnectionState PrivateLinkServiceConnectionState `json:"privateLinkServiceConnectionState"` + ProvisioningState *PrivateEndpointConnectionProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/internal/services/healthcare/sdk/2021-01-11/collection/model_privatelinkserviceconnectionstate.go b/internal/services/healthcare/sdk/2021-01-11/collection/model_privatelinkserviceconnectionstate.go new file mode 100644 index 000000000000..fe6619d2e5b3 --- /dev/null +++ b/internal/services/healthcare/sdk/2021-01-11/collection/model_privatelinkserviceconnectionstate.go @@ -0,0 +1,7 @@ +package collection + +type PrivateLinkServiceConnectionState struct { + ActionsRequired *string `json:"actionsRequired,omitempty"` + Description *string `json:"description,omitempty"` + Status *PrivateEndpointServiceConnectionStatus `json:"status,omitempty"` +} diff --git a/internal/services/healthcare/sdk/2021-01-11/collection/model_serviceaccesspolicyentry.go b/internal/services/healthcare/sdk/2021-01-11/collection/model_serviceaccesspolicyentry.go new file mode 100644 index 000000000000..788b9abe36c4 --- /dev/null +++ b/internal/services/healthcare/sdk/2021-01-11/collection/model_serviceaccesspolicyentry.go @@ -0,0 +1,5 @@ +package collection + +type ServiceAccessPolicyEntry struct { + ObjectId string `json:"objectId"` +} diff --git a/internal/services/healthcare/sdk/2021-01-11/collection/model_serviceacrconfigurationinfo.go b/internal/services/healthcare/sdk/2021-01-11/collection/model_serviceacrconfigurationinfo.go new file mode 100644 index 000000000000..e6aba5385d12 --- /dev/null +++ b/internal/services/healthcare/sdk/2021-01-11/collection/model_serviceacrconfigurationinfo.go @@ -0,0 +1,5 @@ +package collection + +type ServiceAcrConfigurationInfo struct { + LoginServers *[]string `json:"loginServers,omitempty"` +} diff --git a/internal/services/healthcare/sdk/2021-01-11/collection/model_serviceauthenticationconfigurationinfo.go b/internal/services/healthcare/sdk/2021-01-11/collection/model_serviceauthenticationconfigurationinfo.go new file mode 100644 index 000000000000..817440eddd27 --- /dev/null +++ b/internal/services/healthcare/sdk/2021-01-11/collection/model_serviceauthenticationconfigurationinfo.go @@ -0,0 +1,7 @@ +package collection + +type ServiceAuthenticationConfigurationInfo struct { + Audience *string `json:"audience,omitempty"` + Authority *string `json:"authority,omitempty"` + SmartProxyEnabled *bool `json:"smartProxyEnabled,omitempty"` +} diff --git a/internal/services/healthcare/sdk/2021-01-11/collection/model_servicecorsconfigurationinfo.go b/internal/services/healthcare/sdk/2021-01-11/collection/model_servicecorsconfigurationinfo.go new file mode 100644 index 000000000000..c8c1e73b44ad --- /dev/null +++ b/internal/services/healthcare/sdk/2021-01-11/collection/model_servicecorsconfigurationinfo.go @@ -0,0 +1,9 @@ +package collection + +type ServiceCorsConfigurationInfo struct { + AllowCredentials *bool `json:"allowCredentials,omitempty"` + Headers *[]string `json:"headers,omitempty"` + MaxAge *int64 `json:"maxAge,omitempty"` + Methods *[]string `json:"methods,omitempty"` + Origins *[]string `json:"origins,omitempty"` +} diff --git a/internal/services/healthcare/sdk/2021-01-11/collection/model_servicecosmosdbconfigurationinfo.go b/internal/services/healthcare/sdk/2021-01-11/collection/model_servicecosmosdbconfigurationinfo.go new file mode 100644 index 000000000000..eec76c56a531 --- /dev/null +++ b/internal/services/healthcare/sdk/2021-01-11/collection/model_servicecosmosdbconfigurationinfo.go @@ -0,0 +1,6 @@ +package collection + +type ServiceCosmosDbConfigurationInfo struct { + KeyVaultKeyUri *string `json:"keyVaultKeyUri,omitempty"` + OfferThroughput *int64 `json:"offerThroughput,omitempty"` +} diff --git a/internal/services/healthcare/sdk/2021-01-11/collection/model_serviceexportconfigurationinfo.go b/internal/services/healthcare/sdk/2021-01-11/collection/model_serviceexportconfigurationinfo.go new file mode 100644 index 000000000000..eee5a8843e2b --- /dev/null +++ b/internal/services/healthcare/sdk/2021-01-11/collection/model_serviceexportconfigurationinfo.go @@ -0,0 +1,5 @@ +package collection + +type ServiceExportConfigurationInfo struct { + StorageAccountName *string `json:"storageAccountName,omitempty"` +} diff --git a/internal/services/healthcare/sdk/2021-01-11/collection/model_servicesdescription.go b/internal/services/healthcare/sdk/2021-01-11/collection/model_servicesdescription.go new file mode 100644 index 000000000000..0571a820794e --- /dev/null +++ b/internal/services/healthcare/sdk/2021-01-11/collection/model_servicesdescription.go @@ -0,0 +1,18 @@ +package collection + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/identity" +) + +type ServicesDescription struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Identity *identity.SystemAssigned `json:"identity,omitempty"` + Kind Kind `json:"kind"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties *ServicesProperties `json:"properties,omitempty"` + SystemData *SystemData `json:"systemData,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/internal/services/healthcare/sdk/2021-01-11/collection/model_servicesproperties.go b/internal/services/healthcare/sdk/2021-01-11/collection/model_servicesproperties.go new file mode 100644 index 000000000000..aa60431aa653 --- /dev/null +++ b/internal/services/healthcare/sdk/2021-01-11/collection/model_servicesproperties.go @@ -0,0 +1,13 @@ +package collection + +type ServicesProperties struct { + AccessPolicies *[]ServiceAccessPolicyEntry `json:"accessPolicies,omitempty"` + AcrConfiguration *ServiceAcrConfigurationInfo `json:"acrConfiguration,omitempty"` + AuthenticationConfiguration *ServiceAuthenticationConfigurationInfo `json:"authenticationConfiguration,omitempty"` + CorsConfiguration *ServiceCorsConfigurationInfo `json:"corsConfiguration,omitempty"` + CosmosDbConfiguration *ServiceCosmosDbConfigurationInfo `json:"cosmosDbConfiguration,omitempty"` + ExportConfiguration *ServiceExportConfigurationInfo `json:"exportConfiguration,omitempty"` + PrivateEndpointConnections *[]PrivateEndpointConnection `json:"privateEndpointConnections,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + PublicNetworkAccess *PublicNetworkAccess `json:"publicNetworkAccess,omitempty"` +} diff --git a/internal/services/healthcare/sdk/2021-01-11/collection/model_systemdata.go b/internal/services/healthcare/sdk/2021-01-11/collection/model_systemdata.go new file mode 100644 index 000000000000..a8361db52cda --- /dev/null +++ b/internal/services/healthcare/sdk/2021-01-11/collection/model_systemdata.go @@ -0,0 +1,40 @@ +package collection + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +type SystemData struct { + CreatedAt *string `json:"createdAt,omitempty"` + CreatedBy *string `json:"createdBy,omitempty"` + CreatedByType *CreatedByType `json:"createdByType,omitempty"` + LastModifiedAt *string `json:"lastModifiedAt,omitempty"` + LastModifiedBy *string `json:"lastModifiedBy,omitempty"` + LastModifiedByType *CreatedByType `json:"lastModifiedByType,omitempty"` +} + +func (o SystemData) GetCreatedAtAsTime() (*time.Time, error) { + if o.CreatedAt == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreatedAt, "2006-01-02T15:04:05Z07:00") +} + +func (o SystemData) SetCreatedAtAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreatedAt = &formatted +} + +func (o SystemData) GetLastModifiedAtAsTime() (*time.Time, error) { + if o.LastModifiedAt == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastModifiedAt, "2006-01-02T15:04:05Z07:00") +} + +func (o SystemData) SetLastModifiedAtAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastModifiedAt = &formatted +} diff --git a/internal/services/healthcare/sdk/2021-01-11/collection/predicates.go b/internal/services/healthcare/sdk/2021-01-11/collection/predicates.go new file mode 100644 index 000000000000..b62be96254a8 --- /dev/null +++ b/internal/services/healthcare/sdk/2021-01-11/collection/predicates.go @@ -0,0 +1,34 @@ +package collection + +type ServicesDescriptionPredicate struct { + Etag *string + Id *string + Location *string + Name *string + Type *string +} + +func (p ServicesDescriptionPredicate) Matches(input ServicesDescription) bool { + + if p.Etag != nil && (input.Etag == nil && *p.Etag != *input.Etag) { + return false + } + + if p.Id != nil && (input.Id == nil && *p.Id != *input.Id) { + return false + } + + if p.Location != nil && *p.Location != input.Location { + return false + } + + if p.Name != nil && (input.Name == nil && *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil && *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/internal/services/healthcare/sdk/2021-01-11/collection/version.go b/internal/services/healthcare/sdk/2021-01-11/collection/version.go new file mode 100644 index 000000000000..39cc3a1800db --- /dev/null +++ b/internal/services/healthcare/sdk/2021-01-11/collection/version.go @@ -0,0 +1,9 @@ +package collection + +import "fmt" + +const defaultApiVersion = "2021-01-11" + +func userAgent() string { + return fmt.Sprintf("pandora/collection/%s", defaultApiVersion) +} diff --git a/internal/services/healthcare/sdk/2021-01-11/privateendpointconnections/client.go b/internal/services/healthcare/sdk/2021-01-11/privateendpointconnections/client.go new file mode 100644 index 000000000000..adc4283affb2 --- /dev/null +++ b/internal/services/healthcare/sdk/2021-01-11/privateendpointconnections/client.go @@ -0,0 +1,15 @@ +package privateendpointconnections + +import "github.com/Azure/go-autorest/autorest" + +type PrivateEndpointConnectionsClient struct { + Client autorest.Client + baseUri string +} + +func NewPrivateEndpointConnectionsClientWithBaseURI(endpoint string) PrivateEndpointConnectionsClient { + return PrivateEndpointConnectionsClient{ + Client: autorest.NewClientWithUserAgent(userAgent()), + baseUri: endpoint, + } +} diff --git a/internal/services/healthcare/sdk/2021-01-11/privateendpointconnections/constants.go b/internal/services/healthcare/sdk/2021-01-11/privateendpointconnections/constants.go new file mode 100644 index 000000000000..32001a4a5e77 --- /dev/null +++ b/internal/services/healthcare/sdk/2021-01-11/privateendpointconnections/constants.go @@ -0,0 +1,102 @@ +package privateendpointconnections + +import "strings" + +type CreatedByType string + +const ( + CreatedByTypeApplication CreatedByType = "Application" + CreatedByTypeKey CreatedByType = "Key" + CreatedByTypeManagedIdentity CreatedByType = "ManagedIdentity" + CreatedByTypeUser CreatedByType = "User" +) + +func PossibleValuesForCreatedByType() []string { + return []string{ + string(CreatedByTypeApplication), + string(CreatedByTypeKey), + string(CreatedByTypeManagedIdentity), + string(CreatedByTypeUser), + } +} + +func parseCreatedByType(input string) (*CreatedByType, error) { + vals := map[string]CreatedByType{ + "application": CreatedByTypeApplication, + "key": CreatedByTypeKey, + "managedidentity": CreatedByTypeManagedIdentity, + "user": CreatedByTypeUser, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := CreatedByType(input) + return &out, nil +} + +type PrivateEndpointConnectionProvisioningState string + +const ( + PrivateEndpointConnectionProvisioningStateCreating PrivateEndpointConnectionProvisioningState = "Creating" + PrivateEndpointConnectionProvisioningStateDeleting PrivateEndpointConnectionProvisioningState = "Deleting" + PrivateEndpointConnectionProvisioningStateFailed PrivateEndpointConnectionProvisioningState = "Failed" + PrivateEndpointConnectionProvisioningStateSucceeded PrivateEndpointConnectionProvisioningState = "Succeeded" +) + +func PossibleValuesForPrivateEndpointConnectionProvisioningState() []string { + return []string{ + string(PrivateEndpointConnectionProvisioningStateCreating), + string(PrivateEndpointConnectionProvisioningStateDeleting), + string(PrivateEndpointConnectionProvisioningStateFailed), + string(PrivateEndpointConnectionProvisioningStateSucceeded), + } +} + +func parsePrivateEndpointConnectionProvisioningState(input string) (*PrivateEndpointConnectionProvisioningState, error) { + vals := map[string]PrivateEndpointConnectionProvisioningState{ + "creating": PrivateEndpointConnectionProvisioningStateCreating, + "deleting": PrivateEndpointConnectionProvisioningStateDeleting, + "failed": PrivateEndpointConnectionProvisioningStateFailed, + "succeeded": PrivateEndpointConnectionProvisioningStateSucceeded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PrivateEndpointConnectionProvisioningState(input) + return &out, nil +} + +type PrivateEndpointServiceConnectionStatus string + +const ( + PrivateEndpointServiceConnectionStatusApproved PrivateEndpointServiceConnectionStatus = "Approved" + PrivateEndpointServiceConnectionStatusPending PrivateEndpointServiceConnectionStatus = "Pending" + PrivateEndpointServiceConnectionStatusRejected PrivateEndpointServiceConnectionStatus = "Rejected" +) + +func PossibleValuesForPrivateEndpointServiceConnectionStatus() []string { + return []string{ + string(PrivateEndpointServiceConnectionStatusApproved), + string(PrivateEndpointServiceConnectionStatusPending), + string(PrivateEndpointServiceConnectionStatusRejected), + } +} + +func parsePrivateEndpointServiceConnectionStatus(input string) (*PrivateEndpointServiceConnectionStatus, error) { + vals := map[string]PrivateEndpointServiceConnectionStatus{ + "approved": PrivateEndpointServiceConnectionStatusApproved, + "pending": PrivateEndpointServiceConnectionStatusPending, + "rejected": PrivateEndpointServiceConnectionStatusRejected, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PrivateEndpointServiceConnectionStatus(input) + return &out, nil +} diff --git a/internal/services/healthcare/sdk/2021-01-11/privateendpointconnections/id_privateendpointconnection.go b/internal/services/healthcare/sdk/2021-01-11/privateendpointconnections/id_privateendpointconnection.go new file mode 100644 index 000000000000..f6e6cb11f4d1 --- /dev/null +++ b/internal/services/healthcare/sdk/2021-01-11/privateendpointconnections/id_privateendpointconnection.go @@ -0,0 +1,137 @@ +package privateendpointconnections + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +var _ resourceids.ResourceId = PrivateEndpointConnectionId{} + +// PrivateEndpointConnectionId is a struct representing the Resource ID for a Private Endpoint Connection +type PrivateEndpointConnectionId struct { + SubscriptionId string + ResourceGroupName string + ResourceName string + PrivateEndpointConnectionName string +} + +// NewPrivateEndpointConnectionID returns a new PrivateEndpointConnectionId struct +func NewPrivateEndpointConnectionID(subscriptionId string, resourceGroupName string, resourceName string, privateEndpointConnectionName string) PrivateEndpointConnectionId { + return PrivateEndpointConnectionId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ResourceName: resourceName, + PrivateEndpointConnectionName: privateEndpointConnectionName, + } +} + +// ParsePrivateEndpointConnectionID parses 'input' into a PrivateEndpointConnectionId +func ParsePrivateEndpointConnectionID(input string) (*PrivateEndpointConnectionId, error) { + parser := resourceids.NewParserFromResourceIdType(PrivateEndpointConnectionId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := PrivateEndpointConnectionId{} + + if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { + return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) + } + + if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { + return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) + } + + if id.ResourceName, ok = parsed.Parsed["resourceName"]; !ok { + return nil, fmt.Errorf("the segment 'resourceName' was not found in the resource id %q", input) + } + + if id.PrivateEndpointConnectionName, ok = parsed.Parsed["privateEndpointConnectionName"]; !ok { + return nil, fmt.Errorf("the segment 'privateEndpointConnectionName' was not found in the resource id %q", input) + } + + return &id, nil +} + +// ParsePrivateEndpointConnectionIDInsensitively parses 'input' case-insensitively into a PrivateEndpointConnectionId +// note: this method should only be used for API response data and not user input +func ParsePrivateEndpointConnectionIDInsensitively(input string) (*PrivateEndpointConnectionId, error) { + parser := resourceids.NewParserFromResourceIdType(PrivateEndpointConnectionId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := PrivateEndpointConnectionId{} + + if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { + return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) + } + + if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { + return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) + } + + if id.ResourceName, ok = parsed.Parsed["resourceName"]; !ok { + return nil, fmt.Errorf("the segment 'resourceName' was not found in the resource id %q", input) + } + + if id.PrivateEndpointConnectionName, ok = parsed.Parsed["privateEndpointConnectionName"]; !ok { + return nil, fmt.Errorf("the segment 'privateEndpointConnectionName' was not found in the resource id %q", input) + } + + return &id, nil +} + +// ValidatePrivateEndpointConnectionID checks that 'input' can be parsed as a Private Endpoint Connection ID +func ValidatePrivateEndpointConnectionID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParsePrivateEndpointConnectionID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Private Endpoint Connection ID +func (id PrivateEndpointConnectionId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.HealthcareApis/services/%s/privateEndpointConnections/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ResourceName, id.PrivateEndpointConnectionName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Private Endpoint Connection ID +func (id PrivateEndpointConnectionId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftHealthcareApis", "Microsoft.HealthcareApis", "Microsoft.HealthcareApis"), + resourceids.StaticSegment("staticServices", "services", "services"), + resourceids.UserSpecifiedSegment("resourceName", "resourceValue"), + resourceids.StaticSegment("staticPrivateEndpointConnections", "privateEndpointConnections", "privateEndpointConnections"), + resourceids.UserSpecifiedSegment("privateEndpointConnectionName", "privateEndpointConnectionValue"), + } +} + +// String returns a human-readable description of this Private Endpoint Connection ID +func (id PrivateEndpointConnectionId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Resource Name: %q", id.ResourceName), + fmt.Sprintf("Private Endpoint Connection Name: %q", id.PrivateEndpointConnectionName), + } + return fmt.Sprintf("Private Endpoint Connection (%s)", strings.Join(components, "\n")) +} diff --git a/internal/services/healthcare/sdk/2021-01-11/privateendpointconnections/id_privateendpointconnection_test.go b/internal/services/healthcare/sdk/2021-01-11/privateendpointconnections/id_privateendpointconnection_test.go new file mode 100644 index 000000000000..7876560ae7a7 --- /dev/null +++ b/internal/services/healthcare/sdk/2021-01-11/privateendpointconnections/id_privateendpointconnection_test.go @@ -0,0 +1,324 @@ +package privateendpointconnections + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +var _ resourceids.ResourceId = PrivateEndpointConnectionId{} + +func TestNewPrivateEndpointConnectionID(t *testing.T) { + id := NewPrivateEndpointConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "resourceValue", "privateEndpointConnectionValue") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.ResourceName != "resourceValue" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceName'", id.ResourceName, "resourceValue") + } + + if id.PrivateEndpointConnectionName != "privateEndpointConnectionValue" { + t.Fatalf("Expected %q but got %q for Segment 'PrivateEndpointConnectionName'", id.PrivateEndpointConnectionName, "privateEndpointConnectionValue") + } +} + +func TestFormatPrivateEndpointConnectionID(t *testing.T) { + actual := NewPrivateEndpointConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "resourceValue", "privateEndpointConnectionValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/services/resourceValue/privateEndpointConnections/privateEndpointConnectionValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParsePrivateEndpointConnectionID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *PrivateEndpointConnectionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/services", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/services/resourceValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/services/resourceValue/privateEndpointConnections", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/services/resourceValue/privateEndpointConnections/privateEndpointConnectionValue", + Expected: &PrivateEndpointConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ResourceName: "resourceValue", + PrivateEndpointConnectionName: "privateEndpointConnectionValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/services/resourceValue/privateEndpointConnections/privateEndpointConnectionValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParsePrivateEndpointConnectionID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ResourceName != v.Expected.ResourceName { + t.Fatalf("Expected %q but got %q for ResourceName", v.Expected.ResourceName, actual.ResourceName) + } + + if actual.PrivateEndpointConnectionName != v.Expected.PrivateEndpointConnectionName { + t.Fatalf("Expected %q but got %q for PrivateEndpointConnectionName", v.Expected.PrivateEndpointConnectionName, actual.PrivateEndpointConnectionName) + } + + } +} + +func TestParsePrivateEndpointConnectionIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *PrivateEndpointConnectionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hEaLtHcArEaPiS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/services", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hEaLtHcArEaPiS/sErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/services/resourceValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hEaLtHcArEaPiS/sErViCeS/rEsOuRcEvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/services/resourceValue/privateEndpointConnections", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hEaLtHcArEaPiS/sErViCeS/rEsOuRcEvAlUe/pRiVaTeEnDpOiNtCoNnEcTiOnS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/services/resourceValue/privateEndpointConnections/privateEndpointConnectionValue", + Expected: &PrivateEndpointConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ResourceName: "resourceValue", + PrivateEndpointConnectionName: "privateEndpointConnectionValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/services/resourceValue/privateEndpointConnections/privateEndpointConnectionValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hEaLtHcArEaPiS/sErViCeS/rEsOuRcEvAlUe/pRiVaTeEnDpOiNtCoNnEcTiOnS/pRiVaTeEnDpOiNtCoNnEcTiOnVaLuE", + Expected: &PrivateEndpointConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ResourceName: "rEsOuRcEvAlUe", + PrivateEndpointConnectionName: "pRiVaTeEnDpOiNtCoNnEcTiOnVaLuE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hEaLtHcArEaPiS/sErViCeS/rEsOuRcEvAlUe/pRiVaTeEnDpOiNtCoNnEcTiOnS/pRiVaTeEnDpOiNtCoNnEcTiOnVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParsePrivateEndpointConnectionIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ResourceName != v.Expected.ResourceName { + t.Fatalf("Expected %q but got %q for ResourceName", v.Expected.ResourceName, actual.ResourceName) + } + + if actual.PrivateEndpointConnectionName != v.Expected.PrivateEndpointConnectionName { + t.Fatalf("Expected %q but got %q for PrivateEndpointConnectionName", v.Expected.PrivateEndpointConnectionName, actual.PrivateEndpointConnectionName) + } + + } +} + +func TestSegmentsForPrivateEndpointConnectionId(t *testing.T) { + segments := PrivateEndpointConnectionId{}.Segments() + if len(segments) == 0 { + t.Fatalf("PrivateEndpointConnectionId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/internal/services/healthcare/sdk/2021-01-11/privateendpointconnections/id_service.go b/internal/services/healthcare/sdk/2021-01-11/privateendpointconnections/id_service.go new file mode 100644 index 000000000000..cb8692be3199 --- /dev/null +++ b/internal/services/healthcare/sdk/2021-01-11/privateendpointconnections/id_service.go @@ -0,0 +1,124 @@ +package privateendpointconnections + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +var _ resourceids.ResourceId = ServiceId{} + +// ServiceId is a struct representing the Resource ID for a Service +type ServiceId struct { + SubscriptionId string + ResourceGroupName string + ResourceName string +} + +// NewServiceID returns a new ServiceId struct +func NewServiceID(subscriptionId string, resourceGroupName string, resourceName string) ServiceId { + return ServiceId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ResourceName: resourceName, + } +} + +// ParseServiceID parses 'input' into a ServiceId +func ParseServiceID(input string) (*ServiceId, error) { + parser := resourceids.NewParserFromResourceIdType(ServiceId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := ServiceId{} + + if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { + return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) + } + + if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { + return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) + } + + if id.ResourceName, ok = parsed.Parsed["resourceName"]; !ok { + return nil, fmt.Errorf("the segment 'resourceName' was not found in the resource id %q", input) + } + + return &id, nil +} + +// ParseServiceIDInsensitively parses 'input' case-insensitively into a ServiceId +// note: this method should only be used for API response data and not user input +func ParseServiceIDInsensitively(input string) (*ServiceId, error) { + parser := resourceids.NewParserFromResourceIdType(ServiceId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := ServiceId{} + + if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { + return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) + } + + if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { + return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) + } + + if id.ResourceName, ok = parsed.Parsed["resourceName"]; !ok { + return nil, fmt.Errorf("the segment 'resourceName' was not found in the resource id %q", input) + } + + return &id, nil +} + +// ValidateServiceID checks that 'input' can be parsed as a Service ID +func ValidateServiceID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseServiceID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Service ID +func (id ServiceId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.HealthcareApis/services/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ResourceName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Service ID +func (id ServiceId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftHealthcareApis", "Microsoft.HealthcareApis", "Microsoft.HealthcareApis"), + resourceids.StaticSegment("staticServices", "services", "services"), + resourceids.UserSpecifiedSegment("resourceName", "resourceValue"), + } +} + +// String returns a human-readable description of this Service ID +func (id ServiceId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Resource Name: %q", id.ResourceName), + } + return fmt.Sprintf("Service (%s)", strings.Join(components, "\n")) +} diff --git a/internal/services/healthcare/sdk/2021-01-11/privateendpointconnections/id_service_test.go b/internal/services/healthcare/sdk/2021-01-11/privateendpointconnections/id_service_test.go new file mode 100644 index 000000000000..d879c6948696 --- /dev/null +++ b/internal/services/healthcare/sdk/2021-01-11/privateendpointconnections/id_service_test.go @@ -0,0 +1,279 @@ +package privateendpointconnections + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +var _ resourceids.ResourceId = ServiceId{} + +func TestNewServiceID(t *testing.T) { + id := NewServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "resourceValue") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.ResourceName != "resourceValue" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceName'", id.ResourceName, "resourceValue") + } +} + +func TestFormatServiceID(t *testing.T) { + actual := NewServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "resourceValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/services/resourceValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseServiceID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ServiceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/services", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/services/resourceValue", + Expected: &ServiceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ResourceName: "resourceValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/services/resourceValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseServiceID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ResourceName != v.Expected.ResourceName { + t.Fatalf("Expected %q but got %q for ResourceName", v.Expected.ResourceName, actual.ResourceName) + } + + } +} + +func TestParseServiceIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ServiceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hEaLtHcArEaPiS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/services", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hEaLtHcArEaPiS/sErViCeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/services/resourceValue", + Expected: &ServiceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ResourceName: "resourceValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/services/resourceValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hEaLtHcArEaPiS/sErViCeS/rEsOuRcEvAlUe", + Expected: &ServiceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ResourceName: "rEsOuRcEvAlUe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hEaLtHcArEaPiS/sErViCeS/rEsOuRcEvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseServiceIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ResourceName != v.Expected.ResourceName { + t.Fatalf("Expected %q but got %q for ResourceName", v.Expected.ResourceName, actual.ResourceName) + } + + } +} + +func TestSegmentsForServiceId(t *testing.T) { + segments := ServiceId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ServiceId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/internal/services/healthcare/sdk/2021-01-11/privateendpointconnections/method_createorupdate_autorest.go b/internal/services/healthcare/sdk/2021-01-11/privateendpointconnections/method_createorupdate_autorest.go new file mode 100644 index 000000000000..986cb8f4f626 --- /dev/null +++ b/internal/services/healthcare/sdk/2021-01-11/privateendpointconnections/method_createorupdate_autorest.go @@ -0,0 +1,75 @@ +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" +) + +type CreateOrUpdateResponse struct { + Poller polling.LongRunningPoller + HttpResponse *http.Response +} + +// CreateOrUpdate ... +func (c PrivateEndpointConnectionsClient) CreateOrUpdate(ctx context.Context, id PrivateEndpointConnectionId, input PrivateEndpointConnection) (result CreateOrUpdateResponse, err error) { + req, err := c.preparerForCreateOrUpdate(ctx, id, input) + if err != nil { + err = autorest.NewErrorWithError(err, "privateendpointconnections.PrivateEndpointConnectionsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = c.senderForCreateOrUpdate(ctx, req) + if err != nil { + err = autorest.NewErrorWithError(err, "privateendpointconnections.PrivateEndpointConnectionsClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") + return + } + + return +} + +// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed +func (c PrivateEndpointConnectionsClient) CreateOrUpdateThenPoll(ctx context.Context, id PrivateEndpointConnectionId, input PrivateEndpointConnection) 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 PrivateEndpointConnectionsClient) preparerForCreateOrUpdate(ctx context.Context, id PrivateEndpointConnectionId, input PrivateEndpointConnection) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(id.ID()), + autorest.WithJSON(input), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// senderForCreateOrUpdate sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (c PrivateEndpointConnectionsClient) senderForCreateOrUpdate(ctx context.Context, req *http.Request) (future CreateOrUpdateResponse, err error) { + var resp *http.Response + resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + return + } + future.Poller, err = polling.NewLongRunningPollerFromResponse(ctx, resp, c.Client) + return +} diff --git a/internal/services/healthcare/sdk/2021-01-11/privateendpointconnections/method_delete_autorest.go b/internal/services/healthcare/sdk/2021-01-11/privateendpointconnections/method_delete_autorest.go new file mode 100644 index 000000000000..3c4a86df694f --- /dev/null +++ b/internal/services/healthcare/sdk/2021-01-11/privateendpointconnections/method_delete_autorest.go @@ -0,0 +1,74 @@ +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" +) + +type DeleteResponse struct { + Poller polling.LongRunningPoller + HttpResponse *http.Response +} + +// Delete ... +func (c PrivateEndpointConnectionsClient) Delete(ctx context.Context, id PrivateEndpointConnectionId) (result DeleteResponse, err error) { + req, err := c.preparerForDelete(ctx, id) + if err != nil { + err = autorest.NewErrorWithError(err, "privateendpointconnections.PrivateEndpointConnectionsClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = c.senderForDelete(ctx, req) + if err != nil { + err = autorest.NewErrorWithError(err, "privateendpointconnections.PrivateEndpointConnectionsClient", "Delete", result.HttpResponse, "Failure sending request") + return + } + + return +} + +// DeleteThenPoll performs Delete then polls until it's completed +func (c PrivateEndpointConnectionsClient) DeleteThenPoll(ctx context.Context, id PrivateEndpointConnectionId) error { + result, err := c.Delete(ctx, id) + if err != nil { + return fmt.Errorf("performing Delete: %+v", err) + } + + if err := result.Poller.PollUntilDone(); err != nil { + return fmt.Errorf("polling after Delete: %+v", err) + } + + return nil +} + +// preparerForDelete prepares the Delete request. +func (c PrivateEndpointConnectionsClient) preparerForDelete(ctx context.Context, id PrivateEndpointConnectionId) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsDelete(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(id.ID()), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// senderForDelete sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (c PrivateEndpointConnectionsClient) senderForDelete(ctx context.Context, req *http.Request) (future DeleteResponse, err error) { + var resp *http.Response + resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + return + } + future.Poller, err = polling.NewLongRunningPollerFromResponse(ctx, resp, c.Client) + return +} diff --git a/internal/services/healthcare/sdk/2021-01-11/privateendpointconnections/method_get_autorest.go b/internal/services/healthcare/sdk/2021-01-11/privateendpointconnections/method_get_autorest.go new file mode 100644 index 000000000000..349a61376bc5 --- /dev/null +++ b/internal/services/healthcare/sdk/2021-01-11/privateendpointconnections/method_get_autorest.go @@ -0,0 +1,64 @@ +package privateendpointconnections + +import ( + "context" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +type GetResponse struct { + HttpResponse *http.Response + Model *PrivateEndpointConnectionDescription +} + +// Get ... +func (c PrivateEndpointConnectionsClient) Get(ctx context.Context, id PrivateEndpointConnectionId) (result GetResponse, err error) { + req, err := c.preparerForGet(ctx, id) + if err != nil { + err = autorest.NewErrorWithError(err, "privateendpointconnections.PrivateEndpointConnectionsClient", "Get", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "privateendpointconnections.PrivateEndpointConnectionsClient", "Get", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForGet(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "privateendpointconnections.PrivateEndpointConnectionsClient", "Get", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForGet prepares the Get request. +func (c PrivateEndpointConnectionsClient) preparerForGet(ctx context.Context, id PrivateEndpointConnectionId) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsGet(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(id.ID()), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForGet handles the response to the Get request. The method always +// closes the http.Response Body. +func (c PrivateEndpointConnectionsClient) responderForGet(resp *http.Response) (result GetResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Model), + autorest.ByClosing()) + result.HttpResponse = resp + return +} diff --git a/internal/services/healthcare/sdk/2021-01-11/privateendpointconnections/method_listbyservice_autorest.go b/internal/services/healthcare/sdk/2021-01-11/privateendpointconnections/method_listbyservice_autorest.go new file mode 100644 index 000000000000..a908376bfddb --- /dev/null +++ b/internal/services/healthcare/sdk/2021-01-11/privateendpointconnections/method_listbyservice_autorest.go @@ -0,0 +1,65 @@ +package privateendpointconnections + +import ( + "context" + "fmt" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +type ListByServiceResponse struct { + HttpResponse *http.Response + Model *PrivateEndpointConnectionListResultDescription +} + +// ListByService ... +func (c PrivateEndpointConnectionsClient) ListByService(ctx context.Context, id ServiceId) (result ListByServiceResponse, err error) { + req, err := c.preparerForListByService(ctx, id) + if err != nil { + err = autorest.NewErrorWithError(err, "privateendpointconnections.PrivateEndpointConnectionsClient", "ListByService", 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", "ListByService", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForListByService(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "privateendpointconnections.PrivateEndpointConnectionsClient", "ListByService", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForListByService prepares the ListByService request. +func (c PrivateEndpointConnectionsClient) 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/privateEndpointConnections", 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 PrivateEndpointConnectionsClient) responderForListByService(resp *http.Response) (result ListByServiceResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Model), + autorest.ByClosing()) + result.HttpResponse = resp + return +} diff --git a/internal/services/healthcare/sdk/2021-01-11/privateendpointconnections/model_privateendpoint.go b/internal/services/healthcare/sdk/2021-01-11/privateendpointconnections/model_privateendpoint.go new file mode 100644 index 000000000000..33ffc888d58a --- /dev/null +++ b/internal/services/healthcare/sdk/2021-01-11/privateendpointconnections/model_privateendpoint.go @@ -0,0 +1,5 @@ +package privateendpointconnections + +type PrivateEndpoint struct { + Id *string `json:"id,omitempty"` +} diff --git a/internal/services/healthcare/sdk/2021-01-11/privateendpointconnections/model_privateendpointconnection.go b/internal/services/healthcare/sdk/2021-01-11/privateendpointconnections/model_privateendpointconnection.go new file mode 100644 index 000000000000..597d3e71746a --- /dev/null +++ b/internal/services/healthcare/sdk/2021-01-11/privateendpointconnections/model_privateendpointconnection.go @@ -0,0 +1,8 @@ +package privateendpointconnections + +type PrivateEndpointConnection struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateEndpointConnectionProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/internal/services/healthcare/sdk/2021-01-11/privateendpointconnections/model_privateendpointconnectiondescription.go b/internal/services/healthcare/sdk/2021-01-11/privateendpointconnections/model_privateendpointconnectiondescription.go new file mode 100644 index 000000000000..95543c352044 --- /dev/null +++ b/internal/services/healthcare/sdk/2021-01-11/privateendpointconnections/model_privateendpointconnectiondescription.go @@ -0,0 +1,9 @@ +package privateendpointconnections + +type PrivateEndpointConnectionDescription struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateEndpointConnectionProperties `json:"properties,omitempty"` + SystemData *SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/internal/services/healthcare/sdk/2021-01-11/privateendpointconnections/model_privateendpointconnectionlistresultdescription.go b/internal/services/healthcare/sdk/2021-01-11/privateendpointconnections/model_privateendpointconnectionlistresultdescription.go new file mode 100644 index 000000000000..579bed999b3d --- /dev/null +++ b/internal/services/healthcare/sdk/2021-01-11/privateendpointconnections/model_privateendpointconnectionlistresultdescription.go @@ -0,0 +1,5 @@ +package privateendpointconnections + +type PrivateEndpointConnectionListResultDescription struct { + Value *[]PrivateEndpointConnectionDescription `json:"value,omitempty"` +} diff --git a/internal/services/healthcare/sdk/2021-01-11/privateendpointconnections/model_privateendpointconnectionproperties.go b/internal/services/healthcare/sdk/2021-01-11/privateendpointconnections/model_privateendpointconnectionproperties.go new file mode 100644 index 000000000000..252bd91cbe86 --- /dev/null +++ b/internal/services/healthcare/sdk/2021-01-11/privateendpointconnections/model_privateendpointconnectionproperties.go @@ -0,0 +1,7 @@ +package privateendpointconnections + +type PrivateEndpointConnectionProperties struct { + PrivateEndpoint *PrivateEndpoint `json:"privateEndpoint,omitempty"` + PrivateLinkServiceConnectionState PrivateLinkServiceConnectionState `json:"privateLinkServiceConnectionState"` + ProvisioningState *PrivateEndpointConnectionProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/internal/services/healthcare/sdk/2021-01-11/privateendpointconnections/model_privatelinkserviceconnectionstate.go b/internal/services/healthcare/sdk/2021-01-11/privateendpointconnections/model_privatelinkserviceconnectionstate.go new file mode 100644 index 000000000000..def138656add --- /dev/null +++ b/internal/services/healthcare/sdk/2021-01-11/privateendpointconnections/model_privatelinkserviceconnectionstate.go @@ -0,0 +1,7 @@ +package privateendpointconnections + +type PrivateLinkServiceConnectionState struct { + ActionsRequired *string `json:"actionsRequired,omitempty"` + Description *string `json:"description,omitempty"` + Status *PrivateEndpointServiceConnectionStatus `json:"status,omitempty"` +} diff --git a/internal/services/healthcare/sdk/2021-01-11/privateendpointconnections/model_systemdata.go b/internal/services/healthcare/sdk/2021-01-11/privateendpointconnections/model_systemdata.go new file mode 100644 index 000000000000..3d46829edeb6 --- /dev/null +++ b/internal/services/healthcare/sdk/2021-01-11/privateendpointconnections/model_systemdata.go @@ -0,0 +1,40 @@ +package privateendpointconnections + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +type SystemData struct { + CreatedAt *string `json:"createdAt,omitempty"` + CreatedBy *string `json:"createdBy,omitempty"` + CreatedByType *CreatedByType `json:"createdByType,omitempty"` + LastModifiedAt *string `json:"lastModifiedAt,omitempty"` + LastModifiedBy *string `json:"lastModifiedBy,omitempty"` + LastModifiedByType *CreatedByType `json:"lastModifiedByType,omitempty"` +} + +func (o SystemData) GetCreatedAtAsTime() (*time.Time, error) { + if o.CreatedAt == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreatedAt, "2006-01-02T15:04:05Z07:00") +} + +func (o SystemData) SetCreatedAtAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreatedAt = &formatted +} + +func (o SystemData) GetLastModifiedAtAsTime() (*time.Time, error) { + if o.LastModifiedAt == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastModifiedAt, "2006-01-02T15:04:05Z07:00") +} + +func (o SystemData) SetLastModifiedAtAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastModifiedAt = &formatted +} diff --git a/internal/services/healthcare/sdk/2021-01-11/privateendpointconnections/version.go b/internal/services/healthcare/sdk/2021-01-11/privateendpointconnections/version.go new file mode 100644 index 000000000000..c19b0ce1a43e --- /dev/null +++ b/internal/services/healthcare/sdk/2021-01-11/privateendpointconnections/version.go @@ -0,0 +1,9 @@ +package privateendpointconnections + +import "fmt" + +const defaultApiVersion = "2021-01-11" + +func userAgent() string { + return fmt.Sprintf("pandora/privateendpointconnections/%s", defaultApiVersion) +} diff --git a/internal/services/healthcare/sdk/2021-01-11/privatelinkresources/client.go b/internal/services/healthcare/sdk/2021-01-11/privatelinkresources/client.go new file mode 100644 index 000000000000..3ccc015d4fe1 --- /dev/null +++ b/internal/services/healthcare/sdk/2021-01-11/privatelinkresources/client.go @@ -0,0 +1,15 @@ +package privatelinkresources + +import "github.com/Azure/go-autorest/autorest" + +type PrivateLinkResourcesClient struct { + Client autorest.Client + baseUri string +} + +func NewPrivateLinkResourcesClientWithBaseURI(endpoint string) PrivateLinkResourcesClient { + return PrivateLinkResourcesClient{ + Client: autorest.NewClientWithUserAgent(userAgent()), + baseUri: endpoint, + } +} diff --git a/internal/services/healthcare/sdk/2021-01-11/privatelinkresources/constants.go b/internal/services/healthcare/sdk/2021-01-11/privatelinkresources/constants.go new file mode 100644 index 000000000000..8b7848581899 --- /dev/null +++ b/internal/services/healthcare/sdk/2021-01-11/privatelinkresources/constants.go @@ -0,0 +1,37 @@ +package privatelinkresources + +import "strings" + +type CreatedByType string + +const ( + CreatedByTypeApplication CreatedByType = "Application" + CreatedByTypeKey CreatedByType = "Key" + CreatedByTypeManagedIdentity CreatedByType = "ManagedIdentity" + CreatedByTypeUser CreatedByType = "User" +) + +func PossibleValuesForCreatedByType() []string { + return []string{ + string(CreatedByTypeApplication), + string(CreatedByTypeKey), + string(CreatedByTypeManagedIdentity), + string(CreatedByTypeUser), + } +} + +func parseCreatedByType(input string) (*CreatedByType, error) { + vals := map[string]CreatedByType{ + "application": CreatedByTypeApplication, + "key": CreatedByTypeKey, + "managedidentity": CreatedByTypeManagedIdentity, + "user": CreatedByTypeUser, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := CreatedByType(input) + return &out, nil +} diff --git a/internal/services/healthcare/sdk/2021-01-11/privatelinkresources/id_privatelinkresource.go b/internal/services/healthcare/sdk/2021-01-11/privatelinkresources/id_privatelinkresource.go new file mode 100644 index 000000000000..4a716efea2d6 --- /dev/null +++ b/internal/services/healthcare/sdk/2021-01-11/privatelinkresources/id_privatelinkresource.go @@ -0,0 +1,137 @@ +package privatelinkresources + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +var _ resourceids.ResourceId = PrivateLinkResourceId{} + +// PrivateLinkResourceId is a struct representing the Resource ID for a Private Link Resource +type PrivateLinkResourceId struct { + SubscriptionId string + ResourceGroupName string + ResourceName string + GroupName string +} + +// NewPrivateLinkResourceID returns a new PrivateLinkResourceId struct +func NewPrivateLinkResourceID(subscriptionId string, resourceGroupName string, resourceName string, groupName string) PrivateLinkResourceId { + return PrivateLinkResourceId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ResourceName: resourceName, + GroupName: groupName, + } +} + +// ParsePrivateLinkResourceID parses 'input' into a PrivateLinkResourceId +func ParsePrivateLinkResourceID(input string) (*PrivateLinkResourceId, error) { + parser := resourceids.NewParserFromResourceIdType(PrivateLinkResourceId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := PrivateLinkResourceId{} + + if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { + return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) + } + + if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { + return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) + } + + if id.ResourceName, ok = parsed.Parsed["resourceName"]; !ok { + return nil, fmt.Errorf("the segment 'resourceName' was not found in the resource id %q", input) + } + + if id.GroupName, ok = parsed.Parsed["groupName"]; !ok { + return nil, fmt.Errorf("the segment 'groupName' was not found in the resource id %q", input) + } + + return &id, nil +} + +// ParsePrivateLinkResourceIDInsensitively parses 'input' case-insensitively into a PrivateLinkResourceId +// note: this method should only be used for API response data and not user input +func ParsePrivateLinkResourceIDInsensitively(input string) (*PrivateLinkResourceId, error) { + parser := resourceids.NewParserFromResourceIdType(PrivateLinkResourceId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := PrivateLinkResourceId{} + + if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { + return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) + } + + if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { + return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) + } + + if id.ResourceName, ok = parsed.Parsed["resourceName"]; !ok { + return nil, fmt.Errorf("the segment 'resourceName' was not found in the resource id %q", input) + } + + if id.GroupName, ok = parsed.Parsed["groupName"]; !ok { + return nil, fmt.Errorf("the segment 'groupName' was not found in the resource id %q", input) + } + + return &id, nil +} + +// ValidatePrivateLinkResourceID checks that 'input' can be parsed as a Private Link Resource ID +func ValidatePrivateLinkResourceID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParsePrivateLinkResourceID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Private Link Resource ID +func (id PrivateLinkResourceId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.HealthcareApis/services/%s/privateLinkResources/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ResourceName, id.GroupName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Private Link Resource ID +func (id PrivateLinkResourceId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftHealthcareApis", "Microsoft.HealthcareApis", "Microsoft.HealthcareApis"), + resourceids.StaticSegment("staticServices", "services", "services"), + resourceids.UserSpecifiedSegment("resourceName", "resourceValue"), + resourceids.StaticSegment("staticPrivateLinkResources", "privateLinkResources", "privateLinkResources"), + resourceids.UserSpecifiedSegment("groupName", "groupValue"), + } +} + +// String returns a human-readable description of this Private Link Resource ID +func (id PrivateLinkResourceId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Resource Name: %q", id.ResourceName), + fmt.Sprintf("Group Name: %q", id.GroupName), + } + return fmt.Sprintf("Private Link Resource (%s)", strings.Join(components, "\n")) +} diff --git a/internal/services/healthcare/sdk/2021-01-11/privatelinkresources/id_privatelinkresource_test.go b/internal/services/healthcare/sdk/2021-01-11/privatelinkresources/id_privatelinkresource_test.go new file mode 100644 index 000000000000..a7334abc33b5 --- /dev/null +++ b/internal/services/healthcare/sdk/2021-01-11/privatelinkresources/id_privatelinkresource_test.go @@ -0,0 +1,324 @@ +package privatelinkresources + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +var _ resourceids.ResourceId = PrivateLinkResourceId{} + +func TestNewPrivateLinkResourceID(t *testing.T) { + id := NewPrivateLinkResourceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "resourceValue", "groupValue") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.ResourceName != "resourceValue" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceName'", id.ResourceName, "resourceValue") + } + + if id.GroupName != "groupValue" { + t.Fatalf("Expected %q but got %q for Segment 'GroupName'", id.GroupName, "groupValue") + } +} + +func TestFormatPrivateLinkResourceID(t *testing.T) { + actual := NewPrivateLinkResourceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "resourceValue", "groupValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/services/resourceValue/privateLinkResources/groupValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParsePrivateLinkResourceID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *PrivateLinkResourceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/services", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/services/resourceValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/services/resourceValue/privateLinkResources", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/services/resourceValue/privateLinkResources/groupValue", + Expected: &PrivateLinkResourceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ResourceName: "resourceValue", + GroupName: "groupValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/services/resourceValue/privateLinkResources/groupValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParsePrivateLinkResourceID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ResourceName != v.Expected.ResourceName { + t.Fatalf("Expected %q but got %q for ResourceName", v.Expected.ResourceName, actual.ResourceName) + } + + if actual.GroupName != v.Expected.GroupName { + t.Fatalf("Expected %q but got %q for GroupName", v.Expected.GroupName, actual.GroupName) + } + + } +} + +func TestParsePrivateLinkResourceIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *PrivateLinkResourceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hEaLtHcArEaPiS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/services", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hEaLtHcArEaPiS/sErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/services/resourceValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hEaLtHcArEaPiS/sErViCeS/rEsOuRcEvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/services/resourceValue/privateLinkResources", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hEaLtHcArEaPiS/sErViCeS/rEsOuRcEvAlUe/pRiVaTeLiNkReSoUrCeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/services/resourceValue/privateLinkResources/groupValue", + Expected: &PrivateLinkResourceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ResourceName: "resourceValue", + GroupName: "groupValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/services/resourceValue/privateLinkResources/groupValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hEaLtHcArEaPiS/sErViCeS/rEsOuRcEvAlUe/pRiVaTeLiNkReSoUrCeS/gRoUpVaLuE", + Expected: &PrivateLinkResourceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ResourceName: "rEsOuRcEvAlUe", + GroupName: "gRoUpVaLuE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hEaLtHcArEaPiS/sErViCeS/rEsOuRcEvAlUe/pRiVaTeLiNkReSoUrCeS/gRoUpVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParsePrivateLinkResourceIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ResourceName != v.Expected.ResourceName { + t.Fatalf("Expected %q but got %q for ResourceName", v.Expected.ResourceName, actual.ResourceName) + } + + if actual.GroupName != v.Expected.GroupName { + t.Fatalf("Expected %q but got %q for GroupName", v.Expected.GroupName, actual.GroupName) + } + + } +} + +func TestSegmentsForPrivateLinkResourceId(t *testing.T) { + segments := PrivateLinkResourceId{}.Segments() + if len(segments) == 0 { + t.Fatalf("PrivateLinkResourceId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/internal/services/healthcare/sdk/2021-01-11/privatelinkresources/id_service.go b/internal/services/healthcare/sdk/2021-01-11/privatelinkresources/id_service.go new file mode 100644 index 000000000000..f87dd953cbc0 --- /dev/null +++ b/internal/services/healthcare/sdk/2021-01-11/privatelinkresources/id_service.go @@ -0,0 +1,124 @@ +package privatelinkresources + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +var _ resourceids.ResourceId = ServiceId{} + +// ServiceId is a struct representing the Resource ID for a Service +type ServiceId struct { + SubscriptionId string + ResourceGroupName string + ResourceName string +} + +// NewServiceID returns a new ServiceId struct +func NewServiceID(subscriptionId string, resourceGroupName string, resourceName string) ServiceId { + return ServiceId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ResourceName: resourceName, + } +} + +// ParseServiceID parses 'input' into a ServiceId +func ParseServiceID(input string) (*ServiceId, error) { + parser := resourceids.NewParserFromResourceIdType(ServiceId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := ServiceId{} + + if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { + return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) + } + + if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { + return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) + } + + if id.ResourceName, ok = parsed.Parsed["resourceName"]; !ok { + return nil, fmt.Errorf("the segment 'resourceName' was not found in the resource id %q", input) + } + + return &id, nil +} + +// ParseServiceIDInsensitively parses 'input' case-insensitively into a ServiceId +// note: this method should only be used for API response data and not user input +func ParseServiceIDInsensitively(input string) (*ServiceId, error) { + parser := resourceids.NewParserFromResourceIdType(ServiceId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := ServiceId{} + + if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { + return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) + } + + if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { + return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) + } + + if id.ResourceName, ok = parsed.Parsed["resourceName"]; !ok { + return nil, fmt.Errorf("the segment 'resourceName' was not found in the resource id %q", input) + } + + return &id, nil +} + +// ValidateServiceID checks that 'input' can be parsed as a Service ID +func ValidateServiceID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseServiceID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Service ID +func (id ServiceId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.HealthcareApis/services/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ResourceName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Service ID +func (id ServiceId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftHealthcareApis", "Microsoft.HealthcareApis", "Microsoft.HealthcareApis"), + resourceids.StaticSegment("staticServices", "services", "services"), + resourceids.UserSpecifiedSegment("resourceName", "resourceValue"), + } +} + +// String returns a human-readable description of this Service ID +func (id ServiceId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Resource Name: %q", id.ResourceName), + } + return fmt.Sprintf("Service (%s)", strings.Join(components, "\n")) +} diff --git a/internal/services/healthcare/sdk/2021-01-11/privatelinkresources/id_service_test.go b/internal/services/healthcare/sdk/2021-01-11/privatelinkresources/id_service_test.go new file mode 100644 index 000000000000..32a385125ba0 --- /dev/null +++ b/internal/services/healthcare/sdk/2021-01-11/privatelinkresources/id_service_test.go @@ -0,0 +1,279 @@ +package privatelinkresources + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +var _ resourceids.ResourceId = ServiceId{} + +func TestNewServiceID(t *testing.T) { + id := NewServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "resourceValue") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.ResourceName != "resourceValue" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceName'", id.ResourceName, "resourceValue") + } +} + +func TestFormatServiceID(t *testing.T) { + actual := NewServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "resourceValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/services/resourceValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseServiceID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ServiceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/services", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/services/resourceValue", + Expected: &ServiceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ResourceName: "resourceValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/services/resourceValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseServiceID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ResourceName != v.Expected.ResourceName { + t.Fatalf("Expected %q but got %q for ResourceName", v.Expected.ResourceName, actual.ResourceName) + } + + } +} + +func TestParseServiceIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ServiceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hEaLtHcArEaPiS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/services", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hEaLtHcArEaPiS/sErViCeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/services/resourceValue", + Expected: &ServiceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ResourceName: "resourceValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/services/resourceValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hEaLtHcArEaPiS/sErViCeS/rEsOuRcEvAlUe", + Expected: &ServiceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ResourceName: "rEsOuRcEvAlUe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hEaLtHcArEaPiS/sErViCeS/rEsOuRcEvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseServiceIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ResourceName != v.Expected.ResourceName { + t.Fatalf("Expected %q but got %q for ResourceName", v.Expected.ResourceName, actual.ResourceName) + } + + } +} + +func TestSegmentsForServiceId(t *testing.T) { + segments := ServiceId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ServiceId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/internal/services/healthcare/sdk/2021-01-11/privatelinkresources/method_get_autorest.go b/internal/services/healthcare/sdk/2021-01-11/privatelinkresources/method_get_autorest.go new file mode 100644 index 000000000000..097c32ab3809 --- /dev/null +++ b/internal/services/healthcare/sdk/2021-01-11/privatelinkresources/method_get_autorest.go @@ -0,0 +1,64 @@ +package privatelinkresources + +import ( + "context" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +type GetResponse struct { + HttpResponse *http.Response + Model *PrivateLinkResourceDescription +} + +// Get ... +func (c PrivateLinkResourcesClient) Get(ctx context.Context, id PrivateLinkResourceId) (result GetResponse, err error) { + req, err := c.preparerForGet(ctx, id) + if err != nil { + err = autorest.NewErrorWithError(err, "privatelinkresources.PrivateLinkResourcesClient", "Get", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "privatelinkresources.PrivateLinkResourcesClient", "Get", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForGet(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "privatelinkresources.PrivateLinkResourcesClient", "Get", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForGet prepares the Get request. +func (c PrivateLinkResourcesClient) preparerForGet(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)) +} + +// responderForGet handles the response to the Get request. The method always +// closes the http.Response Body. +func (c PrivateLinkResourcesClient) responderForGet(resp *http.Response) (result GetResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Model), + autorest.ByClosing()) + result.HttpResponse = resp + return +} diff --git a/internal/services/healthcare/sdk/2021-01-11/privatelinkresources/method_listbyservice_autorest.go b/internal/services/healthcare/sdk/2021-01-11/privatelinkresources/method_listbyservice_autorest.go new file mode 100644 index 000000000000..a13255a4d1bb --- /dev/null +++ b/internal/services/healthcare/sdk/2021-01-11/privatelinkresources/method_listbyservice_autorest.go @@ -0,0 +1,65 @@ +package privatelinkresources + +import ( + "context" + "fmt" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +type ListByServiceResponse struct { + HttpResponse *http.Response + Model *PrivateLinkResourceListResultDescription +} + +// ListByService ... +func (c PrivateLinkResourcesClient) ListByService(ctx context.Context, id ServiceId) (result ListByServiceResponse, err error) { + req, err := c.preparerForListByService(ctx, id) + if err != nil { + err = autorest.NewErrorWithError(err, "privatelinkresources.PrivateLinkResourcesClient", "ListByService", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "privatelinkresources.PrivateLinkResourcesClient", "ListByService", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForListByService(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "privatelinkresources.PrivateLinkResourcesClient", "ListByService", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForListByService prepares the ListByService request. +func (c PrivateLinkResourcesClient) 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/privateLinkResources", 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 PrivateLinkResourcesClient) responderForListByService(resp *http.Response) (result ListByServiceResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Model), + autorest.ByClosing()) + result.HttpResponse = resp + return +} diff --git a/internal/services/healthcare/sdk/2021-01-11/privatelinkresources/model_privatelinkresourcedescription.go b/internal/services/healthcare/sdk/2021-01-11/privatelinkresources/model_privatelinkresourcedescription.go new file mode 100644 index 000000000000..cd11d5179a60 --- /dev/null +++ b/internal/services/healthcare/sdk/2021-01-11/privatelinkresources/model_privatelinkresourcedescription.go @@ -0,0 +1,9 @@ +package privatelinkresources + +type PrivateLinkResourceDescription struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateLinkResourceProperties `json:"properties,omitempty"` + SystemData *SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/internal/services/healthcare/sdk/2021-01-11/privatelinkresources/model_privatelinkresourcelistresultdescription.go b/internal/services/healthcare/sdk/2021-01-11/privatelinkresources/model_privatelinkresourcelistresultdescription.go new file mode 100644 index 000000000000..9bf0baa227c8 --- /dev/null +++ b/internal/services/healthcare/sdk/2021-01-11/privatelinkresources/model_privatelinkresourcelistresultdescription.go @@ -0,0 +1,5 @@ +package privatelinkresources + +type PrivateLinkResourceListResultDescription struct { + Value *[]PrivateLinkResourceDescription `json:"value,omitempty"` +} diff --git a/internal/services/healthcare/sdk/2021-01-11/privatelinkresources/model_privatelinkresourceproperties.go b/internal/services/healthcare/sdk/2021-01-11/privatelinkresources/model_privatelinkresourceproperties.go new file mode 100644 index 000000000000..51bc838c1fbd --- /dev/null +++ b/internal/services/healthcare/sdk/2021-01-11/privatelinkresources/model_privatelinkresourceproperties.go @@ -0,0 +1,7 @@ +package privatelinkresources + +type PrivateLinkResourceProperties struct { + GroupId *string `json:"groupId,omitempty"` + RequiredMembers *[]string `json:"requiredMembers,omitempty"` + RequiredZoneNames *[]string `json:"requiredZoneNames,omitempty"` +} diff --git a/internal/services/healthcare/sdk/2021-01-11/privatelinkresources/model_systemdata.go b/internal/services/healthcare/sdk/2021-01-11/privatelinkresources/model_systemdata.go new file mode 100644 index 000000000000..f9327b762df1 --- /dev/null +++ b/internal/services/healthcare/sdk/2021-01-11/privatelinkresources/model_systemdata.go @@ -0,0 +1,40 @@ +package privatelinkresources + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +type SystemData struct { + CreatedAt *string `json:"createdAt,omitempty"` + CreatedBy *string `json:"createdBy,omitempty"` + CreatedByType *CreatedByType `json:"createdByType,omitempty"` + LastModifiedAt *string `json:"lastModifiedAt,omitempty"` + LastModifiedBy *string `json:"lastModifiedBy,omitempty"` + LastModifiedByType *CreatedByType `json:"lastModifiedByType,omitempty"` +} + +func (o SystemData) GetCreatedAtAsTime() (*time.Time, error) { + if o.CreatedAt == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreatedAt, "2006-01-02T15:04:05Z07:00") +} + +func (o SystemData) SetCreatedAtAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreatedAt = &formatted +} + +func (o SystemData) GetLastModifiedAtAsTime() (*time.Time, error) { + if o.LastModifiedAt == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastModifiedAt, "2006-01-02T15:04:05Z07:00") +} + +func (o SystemData) SetLastModifiedAtAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastModifiedAt = &formatted +} diff --git a/internal/services/healthcare/sdk/2021-01-11/privatelinkresources/version.go b/internal/services/healthcare/sdk/2021-01-11/privatelinkresources/version.go new file mode 100644 index 000000000000..7a2bb306bb9a --- /dev/null +++ b/internal/services/healthcare/sdk/2021-01-11/privatelinkresources/version.go @@ -0,0 +1,9 @@ +package privatelinkresources + +import "fmt" + +const defaultApiVersion = "2021-01-11" + +func userAgent() string { + return fmt.Sprintf("pandora/privatelinkresources/%s", defaultApiVersion) +} diff --git a/internal/services/healthcare/sdk/2021-01-11/proxy/client.go b/internal/services/healthcare/sdk/2021-01-11/proxy/client.go new file mode 100644 index 000000000000..6acefce56ad5 --- /dev/null +++ b/internal/services/healthcare/sdk/2021-01-11/proxy/client.go @@ -0,0 +1,15 @@ +package proxy + +import "github.com/Azure/go-autorest/autorest" + +type ProxyClient struct { + Client autorest.Client + baseUri string +} + +func NewProxyClientWithBaseURI(endpoint string) ProxyClient { + return ProxyClient{ + Client: autorest.NewClientWithUserAgent(userAgent()), + baseUri: endpoint, + } +} diff --git a/internal/services/healthcare/sdk/2021-01-11/proxy/constants.go b/internal/services/healthcare/sdk/2021-01-11/proxy/constants.go new file mode 100644 index 000000000000..6e0c4744ebfc --- /dev/null +++ b/internal/services/healthcare/sdk/2021-01-11/proxy/constants.go @@ -0,0 +1,31 @@ +package proxy + +import "strings" + +type ServiceNameUnavailabilityReason string + +const ( + ServiceNameUnavailabilityReasonAlreadyExists ServiceNameUnavailabilityReason = "AlreadyExists" + ServiceNameUnavailabilityReasonInvalid ServiceNameUnavailabilityReason = "Invalid" +) + +func PossibleValuesForServiceNameUnavailabilityReason() []string { + return []string{ + string(ServiceNameUnavailabilityReasonAlreadyExists), + string(ServiceNameUnavailabilityReasonInvalid), + } +} + +func parseServiceNameUnavailabilityReason(input string) (*ServiceNameUnavailabilityReason, error) { + vals := map[string]ServiceNameUnavailabilityReason{ + "alreadyexists": ServiceNameUnavailabilityReasonAlreadyExists, + "invalid": ServiceNameUnavailabilityReasonInvalid, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ServiceNameUnavailabilityReason(input) + return &out, nil +} diff --git a/internal/services/healthcare/sdk/2021-01-11/proxy/method_serviceschecknameavailability_autorest.go b/internal/services/healthcare/sdk/2021-01-11/proxy/method_serviceschecknameavailability_autorest.go new file mode 100644 index 000000000000..b44d479fa8e6 --- /dev/null +++ b/internal/services/healthcare/sdk/2021-01-11/proxy/method_serviceschecknameavailability_autorest.go @@ -0,0 +1,67 @@ +package proxy + +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" +) + +type ServicesCheckNameAvailabilityResponse struct { + HttpResponse *http.Response + Model *ServicesNameAvailabilityInfo +} + +// ServicesCheckNameAvailability ... +func (c ProxyClient) ServicesCheckNameAvailability(ctx context.Context, id commonids.SubscriptionId, input CheckNameAvailabilityParameters) (result ServicesCheckNameAvailabilityResponse, err error) { + req, err := c.preparerForServicesCheckNameAvailability(ctx, id, input) + if err != nil { + err = autorest.NewErrorWithError(err, "proxy.ProxyClient", "ServicesCheckNameAvailability", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "proxy.ProxyClient", "ServicesCheckNameAvailability", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForServicesCheckNameAvailability(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "proxy.ProxyClient", "ServicesCheckNameAvailability", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForServicesCheckNameAvailability prepares the ServicesCheckNameAvailability request. +func (c ProxyClient) preparerForServicesCheckNameAvailability(ctx context.Context, id commonids.SubscriptionId, input CheckNameAvailabilityParameters) (*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.HealthcareApis/checkNameAvailability", id.ID())), + autorest.WithJSON(input), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForServicesCheckNameAvailability handles the response to the ServicesCheckNameAvailability request. The method always +// closes the http.Response Body. +func (c ProxyClient) responderForServicesCheckNameAvailability(resp *http.Response) (result ServicesCheckNameAvailabilityResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Model), + autorest.ByClosing()) + result.HttpResponse = resp + return +} diff --git a/internal/services/healthcare/sdk/2021-01-11/proxy/model_checknameavailabilityparameters.go b/internal/services/healthcare/sdk/2021-01-11/proxy/model_checknameavailabilityparameters.go new file mode 100644 index 000000000000..0759b12e6f95 --- /dev/null +++ b/internal/services/healthcare/sdk/2021-01-11/proxy/model_checknameavailabilityparameters.go @@ -0,0 +1,6 @@ +package proxy + +type CheckNameAvailabilityParameters struct { + Name string `json:"name"` + Type string `json:"type"` +} diff --git a/internal/services/healthcare/sdk/2021-01-11/proxy/model_servicesnameavailabilityinfo.go b/internal/services/healthcare/sdk/2021-01-11/proxy/model_servicesnameavailabilityinfo.go new file mode 100644 index 000000000000..1a5e4c9f2cfa --- /dev/null +++ b/internal/services/healthcare/sdk/2021-01-11/proxy/model_servicesnameavailabilityinfo.go @@ -0,0 +1,7 @@ +package proxy + +type ServicesNameAvailabilityInfo struct { + Message *string `json:"message,omitempty"` + NameAvailable *bool `json:"nameAvailable,omitempty"` + Reason *ServiceNameUnavailabilityReason `json:"reason,omitempty"` +} diff --git a/internal/services/healthcare/sdk/2021-01-11/proxy/version.go b/internal/services/healthcare/sdk/2021-01-11/proxy/version.go new file mode 100644 index 000000000000..4f789019480e --- /dev/null +++ b/internal/services/healthcare/sdk/2021-01-11/proxy/version.go @@ -0,0 +1,9 @@ +package proxy + +import "fmt" + +const defaultApiVersion = "2021-01-11" + +func userAgent() string { + return fmt.Sprintf("pandora/proxy/%s", defaultApiVersion) +} diff --git a/internal/services/healthcare/sdk/2021-01-11/resource/client.go b/internal/services/healthcare/sdk/2021-01-11/resource/client.go new file mode 100644 index 000000000000..d9f8bbb20ce1 --- /dev/null +++ b/internal/services/healthcare/sdk/2021-01-11/resource/client.go @@ -0,0 +1,15 @@ +package resource + +import "github.com/Azure/go-autorest/autorest" + +type ResourceClient struct { + Client autorest.Client + baseUri string +} + +func NewResourceClientWithBaseURI(endpoint string) ResourceClient { + return ResourceClient{ + Client: autorest.NewClientWithUserAgent(userAgent()), + baseUri: endpoint, + } +} diff --git a/internal/services/healthcare/sdk/2021-01-11/resource/constants.go b/internal/services/healthcare/sdk/2021-01-11/resource/constants.go new file mode 100644 index 000000000000..cf424b1eea1a --- /dev/null +++ b/internal/services/healthcare/sdk/2021-01-11/resource/constants.go @@ -0,0 +1,210 @@ +package resource + +import "strings" + +type CreatedByType string + +const ( + CreatedByTypeApplication CreatedByType = "Application" + CreatedByTypeKey CreatedByType = "Key" + CreatedByTypeManagedIdentity CreatedByType = "ManagedIdentity" + CreatedByTypeUser CreatedByType = "User" +) + +func PossibleValuesForCreatedByType() []string { + return []string{ + string(CreatedByTypeApplication), + string(CreatedByTypeKey), + string(CreatedByTypeManagedIdentity), + string(CreatedByTypeUser), + } +} + +func parseCreatedByType(input string) (*CreatedByType, error) { + vals := map[string]CreatedByType{ + "application": CreatedByTypeApplication, + "key": CreatedByTypeKey, + "managedidentity": CreatedByTypeManagedIdentity, + "user": CreatedByTypeUser, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := CreatedByType(input) + return &out, nil +} + +type Kind string + +const ( + KindFhir Kind = "fhir" + KindFhirNegativeRFour Kind = "fhir-R4" + KindFhirNegativeStuThree Kind = "fhir-Stu3" +) + +func PossibleValuesForKind() []string { + return []string{ + string(KindFhir), + string(KindFhirNegativeRFour), + string(KindFhirNegativeStuThree), + } +} + +func parseKind(input string) (*Kind, error) { + vals := map[string]Kind{ + "fhir": KindFhir, + "fhir-r4": KindFhirNegativeRFour, + "fhir-stu3": KindFhirNegativeStuThree, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := Kind(input) + return &out, nil +} + +type PrivateEndpointConnectionProvisioningState string + +const ( + PrivateEndpointConnectionProvisioningStateCreating PrivateEndpointConnectionProvisioningState = "Creating" + PrivateEndpointConnectionProvisioningStateDeleting PrivateEndpointConnectionProvisioningState = "Deleting" + PrivateEndpointConnectionProvisioningStateFailed PrivateEndpointConnectionProvisioningState = "Failed" + PrivateEndpointConnectionProvisioningStateSucceeded PrivateEndpointConnectionProvisioningState = "Succeeded" +) + +func PossibleValuesForPrivateEndpointConnectionProvisioningState() []string { + return []string{ + string(PrivateEndpointConnectionProvisioningStateCreating), + string(PrivateEndpointConnectionProvisioningStateDeleting), + string(PrivateEndpointConnectionProvisioningStateFailed), + string(PrivateEndpointConnectionProvisioningStateSucceeded), + } +} + +func parsePrivateEndpointConnectionProvisioningState(input string) (*PrivateEndpointConnectionProvisioningState, error) { + vals := map[string]PrivateEndpointConnectionProvisioningState{ + "creating": PrivateEndpointConnectionProvisioningStateCreating, + "deleting": PrivateEndpointConnectionProvisioningStateDeleting, + "failed": PrivateEndpointConnectionProvisioningStateFailed, + "succeeded": PrivateEndpointConnectionProvisioningStateSucceeded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PrivateEndpointConnectionProvisioningState(input) + return &out, nil +} + +type PrivateEndpointServiceConnectionStatus string + +const ( + PrivateEndpointServiceConnectionStatusApproved PrivateEndpointServiceConnectionStatus = "Approved" + PrivateEndpointServiceConnectionStatusPending PrivateEndpointServiceConnectionStatus = "Pending" + PrivateEndpointServiceConnectionStatusRejected PrivateEndpointServiceConnectionStatus = "Rejected" +) + +func PossibleValuesForPrivateEndpointServiceConnectionStatus() []string { + return []string{ + string(PrivateEndpointServiceConnectionStatusApproved), + string(PrivateEndpointServiceConnectionStatusPending), + string(PrivateEndpointServiceConnectionStatusRejected), + } +} + +func parsePrivateEndpointServiceConnectionStatus(input string) (*PrivateEndpointServiceConnectionStatus, error) { + vals := map[string]PrivateEndpointServiceConnectionStatus{ + "approved": PrivateEndpointServiceConnectionStatusApproved, + "pending": PrivateEndpointServiceConnectionStatusPending, + "rejected": PrivateEndpointServiceConnectionStatusRejected, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PrivateEndpointServiceConnectionStatus(input) + return &out, nil +} + +type ProvisioningState string + +const ( + ProvisioningStateAccepted ProvisioningState = "Accepted" + ProvisioningStateCanceled ProvisioningState = "Canceled" + ProvisioningStateCreating ProvisioningState = "Creating" + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateDeprovisioned ProvisioningState = "Deprovisioned" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + ProvisioningStateUpdating ProvisioningState = "Updating" + ProvisioningStateVerifying ProvisioningState = "Verifying" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateAccepted), + string(ProvisioningStateCanceled), + string(ProvisioningStateCreating), + string(ProvisioningStateDeleting), + string(ProvisioningStateDeprovisioned), + string(ProvisioningStateFailed), + string(ProvisioningStateSucceeded), + string(ProvisioningStateUpdating), + string(ProvisioningStateVerifying), + } +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "accepted": ProvisioningStateAccepted, + "canceled": ProvisioningStateCanceled, + "creating": ProvisioningStateCreating, + "deleting": ProvisioningStateDeleting, + "deprovisioned": ProvisioningStateDeprovisioned, + "failed": ProvisioningStateFailed, + "succeeded": ProvisioningStateSucceeded, + "updating": ProvisioningStateUpdating, + "verifying": ProvisioningStateVerifying, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} + +type PublicNetworkAccess string + +const ( + PublicNetworkAccessDisabled PublicNetworkAccess = "Disabled" + PublicNetworkAccessEnabled PublicNetworkAccess = "Enabled" +) + +func PossibleValuesForPublicNetworkAccess() []string { + return []string{ + string(PublicNetworkAccessDisabled), + string(PublicNetworkAccessEnabled), + } +} + +func parsePublicNetworkAccess(input string) (*PublicNetworkAccess, error) { + vals := map[string]PublicNetworkAccess{ + "disabled": PublicNetworkAccessDisabled, + "enabled": PublicNetworkAccessEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PublicNetworkAccess(input) + return &out, nil +} diff --git a/internal/services/healthcare/sdk/2021-01-11/resource/id_service.go b/internal/services/healthcare/sdk/2021-01-11/resource/id_service.go new file mode 100644 index 000000000000..89356f6a5a16 --- /dev/null +++ b/internal/services/healthcare/sdk/2021-01-11/resource/id_service.go @@ -0,0 +1,124 @@ +package resource + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +var _ resourceids.ResourceId = ServiceId{} + +// ServiceId is a struct representing the Resource ID for a Service +type ServiceId struct { + SubscriptionId string + ResourceGroupName string + ResourceName string +} + +// NewServiceID returns a new ServiceId struct +func NewServiceID(subscriptionId string, resourceGroupName string, resourceName string) ServiceId { + return ServiceId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ResourceName: resourceName, + } +} + +// ParseServiceID parses 'input' into a ServiceId +func ParseServiceID(input string) (*ServiceId, error) { + parser := resourceids.NewParserFromResourceIdType(ServiceId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := ServiceId{} + + if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { + return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) + } + + if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { + return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) + } + + if id.ResourceName, ok = parsed.Parsed["resourceName"]; !ok { + return nil, fmt.Errorf("the segment 'resourceName' was not found in the resource id %q", input) + } + + return &id, nil +} + +// ParseServiceIDInsensitively parses 'input' case-insensitively into a ServiceId +// note: this method should only be used for API response data and not user input +func ParseServiceIDInsensitively(input string) (*ServiceId, error) { + parser := resourceids.NewParserFromResourceIdType(ServiceId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := ServiceId{} + + if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { + return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) + } + + if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { + return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) + } + + if id.ResourceName, ok = parsed.Parsed["resourceName"]; !ok { + return nil, fmt.Errorf("the segment 'resourceName' was not found in the resource id %q", input) + } + + return &id, nil +} + +// ValidateServiceID checks that 'input' can be parsed as a Service ID +func ValidateServiceID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseServiceID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Service ID +func (id ServiceId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.HealthcareApis/services/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ResourceName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Service ID +func (id ServiceId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftHealthcareApis", "Microsoft.HealthcareApis", "Microsoft.HealthcareApis"), + resourceids.StaticSegment("staticServices", "services", "services"), + resourceids.UserSpecifiedSegment("resourceName", "resourceValue"), + } +} + +// String returns a human-readable description of this Service ID +func (id ServiceId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Resource Name: %q", id.ResourceName), + } + return fmt.Sprintf("Service (%s)", strings.Join(components, "\n")) +} diff --git a/internal/services/healthcare/sdk/2021-01-11/resource/id_service_test.go b/internal/services/healthcare/sdk/2021-01-11/resource/id_service_test.go new file mode 100644 index 000000000000..d10df20a6de0 --- /dev/null +++ b/internal/services/healthcare/sdk/2021-01-11/resource/id_service_test.go @@ -0,0 +1,279 @@ +package resource + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +var _ resourceids.ResourceId = ServiceId{} + +func TestNewServiceID(t *testing.T) { + id := NewServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "resourceValue") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.ResourceName != "resourceValue" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceName'", id.ResourceName, "resourceValue") + } +} + +func TestFormatServiceID(t *testing.T) { + actual := NewServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "resourceValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/services/resourceValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseServiceID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ServiceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/services", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/services/resourceValue", + Expected: &ServiceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ResourceName: "resourceValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/services/resourceValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseServiceID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ResourceName != v.Expected.ResourceName { + t.Fatalf("Expected %q but got %q for ResourceName", v.Expected.ResourceName, actual.ResourceName) + } + + } +} + +func TestParseServiceIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ServiceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hEaLtHcArEaPiS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/services", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hEaLtHcArEaPiS/sErViCeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/services/resourceValue", + Expected: &ServiceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ResourceName: "resourceValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/services/resourceValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hEaLtHcArEaPiS/sErViCeS/rEsOuRcEvAlUe", + Expected: &ServiceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ResourceName: "rEsOuRcEvAlUe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hEaLtHcArEaPiS/sErViCeS/rEsOuRcEvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseServiceIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ResourceName != v.Expected.ResourceName { + t.Fatalf("Expected %q but got %q for ResourceName", v.Expected.ResourceName, actual.ResourceName) + } + + } +} + +func TestSegmentsForServiceId(t *testing.T) { + segments := ServiceId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ServiceId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/internal/services/healthcare/sdk/2021-01-11/resource/method_servicescreateorupdate_autorest.go b/internal/services/healthcare/sdk/2021-01-11/resource/method_servicescreateorupdate_autorest.go new file mode 100644 index 000000000000..2f038ae8eecf --- /dev/null +++ b/internal/services/healthcare/sdk/2021-01-11/resource/method_servicescreateorupdate_autorest.go @@ -0,0 +1,75 @@ +package resource + +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" +) + +type ServicesCreateOrUpdateResponse struct { + Poller polling.LongRunningPoller + HttpResponse *http.Response +} + +// ServicesCreateOrUpdate ... +func (c ResourceClient) ServicesCreateOrUpdate(ctx context.Context, id ServiceId, input ServicesDescription) (result ServicesCreateOrUpdateResponse, err error) { + req, err := c.preparerForServicesCreateOrUpdate(ctx, id, input) + if err != nil { + err = autorest.NewErrorWithError(err, "resource.ResourceClient", "ServicesCreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = c.senderForServicesCreateOrUpdate(ctx, req) + if err != nil { + err = autorest.NewErrorWithError(err, "resource.ResourceClient", "ServicesCreateOrUpdate", result.HttpResponse, "Failure sending request") + return + } + + return +} + +// ServicesCreateOrUpdateThenPoll performs ServicesCreateOrUpdate then polls until it's completed +func (c ResourceClient) ServicesCreateOrUpdateThenPoll(ctx context.Context, id ServiceId, input ServicesDescription) error { + result, err := c.ServicesCreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing ServicesCreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(); err != nil { + return fmt.Errorf("polling after ServicesCreateOrUpdate: %+v", err) + } + + return nil +} + +// preparerForServicesCreateOrUpdate prepares the ServicesCreateOrUpdate request. +func (c ResourceClient) preparerForServicesCreateOrUpdate(ctx context.Context, id ServiceId, input ServicesDescription) (*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)) +} + +// senderForServicesCreateOrUpdate sends the ServicesCreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (c ResourceClient) senderForServicesCreateOrUpdate(ctx context.Context, req *http.Request) (future ServicesCreateOrUpdateResponse, err error) { + var resp *http.Response + resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + return + } + future.Poller, err = polling.NewLongRunningPollerFromResponse(ctx, resp, c.Client) + return +} diff --git a/internal/services/healthcare/sdk/2021-01-11/resource/method_servicesdelete_autorest.go b/internal/services/healthcare/sdk/2021-01-11/resource/method_servicesdelete_autorest.go new file mode 100644 index 000000000000..dbe35e0b6207 --- /dev/null +++ b/internal/services/healthcare/sdk/2021-01-11/resource/method_servicesdelete_autorest.go @@ -0,0 +1,74 @@ +package resource + +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" +) + +type ServicesDeleteResponse struct { + Poller polling.LongRunningPoller + HttpResponse *http.Response +} + +// ServicesDelete ... +func (c ResourceClient) ServicesDelete(ctx context.Context, id ServiceId) (result ServicesDeleteResponse, err error) { + req, err := c.preparerForServicesDelete(ctx, id) + if err != nil { + err = autorest.NewErrorWithError(err, "resource.ResourceClient", "ServicesDelete", nil, "Failure preparing request") + return + } + + result, err = c.senderForServicesDelete(ctx, req) + if err != nil { + err = autorest.NewErrorWithError(err, "resource.ResourceClient", "ServicesDelete", result.HttpResponse, "Failure sending request") + return + } + + return +} + +// ServicesDeleteThenPoll performs ServicesDelete then polls until it's completed +func (c ResourceClient) ServicesDeleteThenPoll(ctx context.Context, id ServiceId) error { + result, err := c.ServicesDelete(ctx, id) + if err != nil { + return fmt.Errorf("performing ServicesDelete: %+v", err) + } + + if err := result.Poller.PollUntilDone(); err != nil { + return fmt.Errorf("polling after ServicesDelete: %+v", err) + } + + return nil +} + +// preparerForServicesDelete prepares the ServicesDelete request. +func (c ResourceClient) preparerForServicesDelete(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)) +} + +// senderForServicesDelete sends the ServicesDelete request. The method will close the +// http.Response Body if it receives an error. +func (c ResourceClient) senderForServicesDelete(ctx context.Context, req *http.Request) (future ServicesDeleteResponse, err error) { + var resp *http.Response + resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + return + } + future.Poller, err = polling.NewLongRunningPollerFromResponse(ctx, resp, c.Client) + return +} diff --git a/internal/services/healthcare/sdk/2021-01-11/resource/method_servicesget_autorest.go b/internal/services/healthcare/sdk/2021-01-11/resource/method_servicesget_autorest.go new file mode 100644 index 000000000000..6bf9442cb8a1 --- /dev/null +++ b/internal/services/healthcare/sdk/2021-01-11/resource/method_servicesget_autorest.go @@ -0,0 +1,64 @@ +package resource + +import ( + "context" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +type ServicesGetResponse struct { + HttpResponse *http.Response + Model *ServicesDescription +} + +// ServicesGet ... +func (c ResourceClient) ServicesGet(ctx context.Context, id ServiceId) (result ServicesGetResponse, err error) { + req, err := c.preparerForServicesGet(ctx, id) + if err != nil { + err = autorest.NewErrorWithError(err, "resource.ResourceClient", "ServicesGet", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "resource.ResourceClient", "ServicesGet", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForServicesGet(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "resource.ResourceClient", "ServicesGet", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForServicesGet prepares the ServicesGet request. +func (c ResourceClient) preparerForServicesGet(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)) +} + +// responderForServicesGet handles the response to the ServicesGet request. The method always +// closes the http.Response Body. +func (c ResourceClient) responderForServicesGet(resp *http.Response) (result ServicesGetResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Model), + autorest.ByClosing()) + result.HttpResponse = resp + return +} diff --git a/internal/services/healthcare/sdk/2021-01-11/resource/method_servicesupdate_autorest.go b/internal/services/healthcare/sdk/2021-01-11/resource/method_servicesupdate_autorest.go new file mode 100644 index 000000000000..9f8acc63f12a --- /dev/null +++ b/internal/services/healthcare/sdk/2021-01-11/resource/method_servicesupdate_autorest.go @@ -0,0 +1,75 @@ +package resource + +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" +) + +type ServicesUpdateResponse struct { + Poller polling.LongRunningPoller + HttpResponse *http.Response +} + +// ServicesUpdate ... +func (c ResourceClient) ServicesUpdate(ctx context.Context, id ServiceId, input ServicesPatchDescription) (result ServicesUpdateResponse, err error) { + req, err := c.preparerForServicesUpdate(ctx, id, input) + if err != nil { + err = autorest.NewErrorWithError(err, "resource.ResourceClient", "ServicesUpdate", nil, "Failure preparing request") + return + } + + result, err = c.senderForServicesUpdate(ctx, req) + if err != nil { + err = autorest.NewErrorWithError(err, "resource.ResourceClient", "ServicesUpdate", result.HttpResponse, "Failure sending request") + return + } + + return +} + +// ServicesUpdateThenPoll performs ServicesUpdate then polls until it's completed +func (c ResourceClient) ServicesUpdateThenPoll(ctx context.Context, id ServiceId, input ServicesPatchDescription) error { + result, err := c.ServicesUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing ServicesUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(); err != nil { + return fmt.Errorf("polling after ServicesUpdate: %+v", err) + } + + return nil +} + +// preparerForServicesUpdate prepares the ServicesUpdate request. +func (c ResourceClient) preparerForServicesUpdate(ctx context.Context, id ServiceId, input ServicesPatchDescription) (*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)) +} + +// senderForServicesUpdate sends the ServicesUpdate request. The method will close the +// http.Response Body if it receives an error. +func (c ResourceClient) senderForServicesUpdate(ctx context.Context, req *http.Request) (future ServicesUpdateResponse, err error) { + var resp *http.Response + resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + return + } + future.Poller, err = polling.NewLongRunningPollerFromResponse(ctx, resp, c.Client) + return +} diff --git a/internal/services/healthcare/sdk/2021-01-11/resource/model_privateendpoint.go b/internal/services/healthcare/sdk/2021-01-11/resource/model_privateendpoint.go new file mode 100644 index 000000000000..91d2298ebef4 --- /dev/null +++ b/internal/services/healthcare/sdk/2021-01-11/resource/model_privateendpoint.go @@ -0,0 +1,5 @@ +package resource + +type PrivateEndpoint struct { + Id *string `json:"id,omitempty"` +} diff --git a/internal/services/healthcare/sdk/2021-01-11/resource/model_privateendpointconnection.go b/internal/services/healthcare/sdk/2021-01-11/resource/model_privateendpointconnection.go new file mode 100644 index 000000000000..8a588e9071b9 --- /dev/null +++ b/internal/services/healthcare/sdk/2021-01-11/resource/model_privateendpointconnection.go @@ -0,0 +1,8 @@ +package resource + +type PrivateEndpointConnection struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateEndpointConnectionProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/internal/services/healthcare/sdk/2021-01-11/resource/model_privateendpointconnectionproperties.go b/internal/services/healthcare/sdk/2021-01-11/resource/model_privateendpointconnectionproperties.go new file mode 100644 index 000000000000..f2b79dce8bc5 --- /dev/null +++ b/internal/services/healthcare/sdk/2021-01-11/resource/model_privateendpointconnectionproperties.go @@ -0,0 +1,7 @@ +package resource + +type PrivateEndpointConnectionProperties struct { + PrivateEndpoint *PrivateEndpoint `json:"privateEndpoint,omitempty"` + PrivateLinkServiceConnectionState PrivateLinkServiceConnectionState `json:"privateLinkServiceConnectionState"` + ProvisioningState *PrivateEndpointConnectionProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/internal/services/healthcare/sdk/2021-01-11/resource/model_privatelinkserviceconnectionstate.go b/internal/services/healthcare/sdk/2021-01-11/resource/model_privatelinkserviceconnectionstate.go new file mode 100644 index 000000000000..3617e3db806b --- /dev/null +++ b/internal/services/healthcare/sdk/2021-01-11/resource/model_privatelinkserviceconnectionstate.go @@ -0,0 +1,7 @@ +package resource + +type PrivateLinkServiceConnectionState struct { + ActionsRequired *string `json:"actionsRequired,omitempty"` + Description *string `json:"description,omitempty"` + Status *PrivateEndpointServiceConnectionStatus `json:"status,omitempty"` +} diff --git a/internal/services/healthcare/sdk/2021-01-11/resource/model_serviceaccesspolicyentry.go b/internal/services/healthcare/sdk/2021-01-11/resource/model_serviceaccesspolicyentry.go new file mode 100644 index 000000000000..bb7d73d7f581 --- /dev/null +++ b/internal/services/healthcare/sdk/2021-01-11/resource/model_serviceaccesspolicyentry.go @@ -0,0 +1,5 @@ +package resource + +type ServiceAccessPolicyEntry struct { + ObjectId string `json:"objectId"` +} diff --git a/internal/services/healthcare/sdk/2021-01-11/resource/model_serviceacrconfigurationinfo.go b/internal/services/healthcare/sdk/2021-01-11/resource/model_serviceacrconfigurationinfo.go new file mode 100644 index 000000000000..45d58c3f22c2 --- /dev/null +++ b/internal/services/healthcare/sdk/2021-01-11/resource/model_serviceacrconfigurationinfo.go @@ -0,0 +1,5 @@ +package resource + +type ServiceAcrConfigurationInfo struct { + LoginServers *[]string `json:"loginServers,omitempty"` +} diff --git a/internal/services/healthcare/sdk/2021-01-11/resource/model_serviceauthenticationconfigurationinfo.go b/internal/services/healthcare/sdk/2021-01-11/resource/model_serviceauthenticationconfigurationinfo.go new file mode 100644 index 000000000000..b15aeecb91eb --- /dev/null +++ b/internal/services/healthcare/sdk/2021-01-11/resource/model_serviceauthenticationconfigurationinfo.go @@ -0,0 +1,7 @@ +package resource + +type ServiceAuthenticationConfigurationInfo struct { + Audience *string `json:"audience,omitempty"` + Authority *string `json:"authority,omitempty"` + SmartProxyEnabled *bool `json:"smartProxyEnabled,omitempty"` +} diff --git a/internal/services/healthcare/sdk/2021-01-11/resource/model_servicecorsconfigurationinfo.go b/internal/services/healthcare/sdk/2021-01-11/resource/model_servicecorsconfigurationinfo.go new file mode 100644 index 000000000000..3222eb38f35f --- /dev/null +++ b/internal/services/healthcare/sdk/2021-01-11/resource/model_servicecorsconfigurationinfo.go @@ -0,0 +1,9 @@ +package resource + +type ServiceCorsConfigurationInfo struct { + AllowCredentials *bool `json:"allowCredentials,omitempty"` + Headers *[]string `json:"headers,omitempty"` + MaxAge *int64 `json:"maxAge,omitempty"` + Methods *[]string `json:"methods,omitempty"` + Origins *[]string `json:"origins,omitempty"` +} diff --git a/internal/services/healthcare/sdk/2021-01-11/resource/model_servicecosmosdbconfigurationinfo.go b/internal/services/healthcare/sdk/2021-01-11/resource/model_servicecosmosdbconfigurationinfo.go new file mode 100644 index 000000000000..bbdfe7992e43 --- /dev/null +++ b/internal/services/healthcare/sdk/2021-01-11/resource/model_servicecosmosdbconfigurationinfo.go @@ -0,0 +1,6 @@ +package resource + +type ServiceCosmosDbConfigurationInfo struct { + KeyVaultKeyUri *string `json:"keyVaultKeyUri,omitempty"` + OfferThroughput *int64 `json:"offerThroughput,omitempty"` +} diff --git a/internal/services/healthcare/sdk/2021-01-11/resource/model_serviceexportconfigurationinfo.go b/internal/services/healthcare/sdk/2021-01-11/resource/model_serviceexportconfigurationinfo.go new file mode 100644 index 000000000000..35ea1dbe59c1 --- /dev/null +++ b/internal/services/healthcare/sdk/2021-01-11/resource/model_serviceexportconfigurationinfo.go @@ -0,0 +1,5 @@ +package resource + +type ServiceExportConfigurationInfo struct { + StorageAccountName *string `json:"storageAccountName,omitempty"` +} diff --git a/internal/services/healthcare/sdk/2021-01-11/resource/model_servicesdescription.go b/internal/services/healthcare/sdk/2021-01-11/resource/model_servicesdescription.go new file mode 100644 index 000000000000..94364d8f618b --- /dev/null +++ b/internal/services/healthcare/sdk/2021-01-11/resource/model_servicesdescription.go @@ -0,0 +1,18 @@ +package resource + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/identity" +) + +type ServicesDescription struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Identity *identity.SystemAssigned `json:"identity,omitempty"` + Kind Kind `json:"kind"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties *ServicesProperties `json:"properties,omitempty"` + SystemData *SystemData `json:"systemData,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/internal/services/healthcare/sdk/2021-01-11/resource/model_servicespatchdescription.go b/internal/services/healthcare/sdk/2021-01-11/resource/model_servicespatchdescription.go new file mode 100644 index 000000000000..d1bcdfe6c558 --- /dev/null +++ b/internal/services/healthcare/sdk/2021-01-11/resource/model_servicespatchdescription.go @@ -0,0 +1,6 @@ +package resource + +type ServicesPatchDescription struct { + Properties *ServicesPropertiesUpdateParameters `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/internal/services/healthcare/sdk/2021-01-11/resource/model_servicesproperties.go b/internal/services/healthcare/sdk/2021-01-11/resource/model_servicesproperties.go new file mode 100644 index 000000000000..83dd58e7f604 --- /dev/null +++ b/internal/services/healthcare/sdk/2021-01-11/resource/model_servicesproperties.go @@ -0,0 +1,13 @@ +package resource + +type ServicesProperties struct { + AccessPolicies *[]ServiceAccessPolicyEntry `json:"accessPolicies,omitempty"` + AcrConfiguration *ServiceAcrConfigurationInfo `json:"acrConfiguration,omitempty"` + AuthenticationConfiguration *ServiceAuthenticationConfigurationInfo `json:"authenticationConfiguration,omitempty"` + CorsConfiguration *ServiceCorsConfigurationInfo `json:"corsConfiguration,omitempty"` + CosmosDbConfiguration *ServiceCosmosDbConfigurationInfo `json:"cosmosDbConfiguration,omitempty"` + ExportConfiguration *ServiceExportConfigurationInfo `json:"exportConfiguration,omitempty"` + PrivateEndpointConnections *[]PrivateEndpointConnection `json:"privateEndpointConnections,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + PublicNetworkAccess *PublicNetworkAccess `json:"publicNetworkAccess,omitempty"` +} diff --git a/internal/services/healthcare/sdk/2021-01-11/resource/model_servicespropertiesupdateparameters.go b/internal/services/healthcare/sdk/2021-01-11/resource/model_servicespropertiesupdateparameters.go new file mode 100644 index 000000000000..bdee5e5622b7 --- /dev/null +++ b/internal/services/healthcare/sdk/2021-01-11/resource/model_servicespropertiesupdateparameters.go @@ -0,0 +1,5 @@ +package resource + +type ServicesPropertiesUpdateParameters struct { + PublicNetworkAccess *PublicNetworkAccess `json:"publicNetworkAccess,omitempty"` +} diff --git a/internal/services/healthcare/sdk/2021-01-11/resource/model_systemdata.go b/internal/services/healthcare/sdk/2021-01-11/resource/model_systemdata.go new file mode 100644 index 000000000000..8d282622850b --- /dev/null +++ b/internal/services/healthcare/sdk/2021-01-11/resource/model_systemdata.go @@ -0,0 +1,40 @@ +package resource + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +type SystemData struct { + CreatedAt *string `json:"createdAt,omitempty"` + CreatedBy *string `json:"createdBy,omitempty"` + CreatedByType *CreatedByType `json:"createdByType,omitempty"` + LastModifiedAt *string `json:"lastModifiedAt,omitempty"` + LastModifiedBy *string `json:"lastModifiedBy,omitempty"` + LastModifiedByType *CreatedByType `json:"lastModifiedByType,omitempty"` +} + +func (o SystemData) GetCreatedAtAsTime() (*time.Time, error) { + if o.CreatedAt == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreatedAt, "2006-01-02T15:04:05Z07:00") +} + +func (o SystemData) SetCreatedAtAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreatedAt = &formatted +} + +func (o SystemData) GetLastModifiedAtAsTime() (*time.Time, error) { + if o.LastModifiedAt == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastModifiedAt, "2006-01-02T15:04:05Z07:00") +} + +func (o SystemData) SetLastModifiedAtAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastModifiedAt = &formatted +} diff --git a/internal/services/healthcare/sdk/2021-01-11/resource/version.go b/internal/services/healthcare/sdk/2021-01-11/resource/version.go new file mode 100644 index 000000000000..368219e151ef --- /dev/null +++ b/internal/services/healthcare/sdk/2021-01-11/resource/version.go @@ -0,0 +1,9 @@ +package resource + +import "fmt" + +const defaultApiVersion = "2021-01-11" + +func userAgent() string { + return fmt.Sprintf("pandora/resource/%s", defaultApiVersion) +} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/collection/client.go b/internal/services/healthcare/sdk/2021-06-01-preview/collection/client.go new file mode 100644 index 000000000000..9c73b5b57183 --- /dev/null +++ b/internal/services/healthcare/sdk/2021-06-01-preview/collection/client.go @@ -0,0 +1,15 @@ +package collection + +import "github.com/Azure/go-autorest/autorest" + +type CollectionClient struct { + Client autorest.Client + baseUri string +} + +func NewCollectionClientWithBaseURI(endpoint string) CollectionClient { + return CollectionClient{ + Client: autorest.NewClientWithUserAgent(userAgent()), + baseUri: endpoint, + } +} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/collection/constants.go b/internal/services/healthcare/sdk/2021-06-01-preview/collection/constants.go new file mode 100644 index 000000000000..b26711c9a119 --- /dev/null +++ b/internal/services/healthcare/sdk/2021-06-01-preview/collection/constants.go @@ -0,0 +1,210 @@ +package collection + +import "strings" + +type CreatedByType string + +const ( + CreatedByTypeApplication CreatedByType = "Application" + CreatedByTypeKey CreatedByType = "Key" + CreatedByTypeManagedIdentity CreatedByType = "ManagedIdentity" + CreatedByTypeUser CreatedByType = "User" +) + +func PossibleValuesForCreatedByType() []string { + return []string{ + string(CreatedByTypeApplication), + string(CreatedByTypeKey), + string(CreatedByTypeManagedIdentity), + string(CreatedByTypeUser), + } +} + +func parseCreatedByType(input string) (*CreatedByType, error) { + vals := map[string]CreatedByType{ + "application": CreatedByTypeApplication, + "key": CreatedByTypeKey, + "managedidentity": CreatedByTypeManagedIdentity, + "user": CreatedByTypeUser, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := CreatedByType(input) + return &out, nil +} + +type Kind string + +const ( + KindFhir Kind = "fhir" + KindFhirNegativeRFour Kind = "fhir-R4" + KindFhirNegativeStuThree Kind = "fhir-Stu3" +) + +func PossibleValuesForKind() []string { + return []string{ + string(KindFhir), + string(KindFhirNegativeRFour), + string(KindFhirNegativeStuThree), + } +} + +func parseKind(input string) (*Kind, error) { + vals := map[string]Kind{ + "fhir": KindFhir, + "fhir-r4": KindFhirNegativeRFour, + "fhir-stu3": KindFhirNegativeStuThree, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := Kind(input) + return &out, nil +} + +type PrivateEndpointConnectionProvisioningState string + +const ( + PrivateEndpointConnectionProvisioningStateCreating PrivateEndpointConnectionProvisioningState = "Creating" + PrivateEndpointConnectionProvisioningStateDeleting PrivateEndpointConnectionProvisioningState = "Deleting" + PrivateEndpointConnectionProvisioningStateFailed PrivateEndpointConnectionProvisioningState = "Failed" + PrivateEndpointConnectionProvisioningStateSucceeded PrivateEndpointConnectionProvisioningState = "Succeeded" +) + +func PossibleValuesForPrivateEndpointConnectionProvisioningState() []string { + return []string{ + string(PrivateEndpointConnectionProvisioningStateCreating), + string(PrivateEndpointConnectionProvisioningStateDeleting), + string(PrivateEndpointConnectionProvisioningStateFailed), + string(PrivateEndpointConnectionProvisioningStateSucceeded), + } +} + +func parsePrivateEndpointConnectionProvisioningState(input string) (*PrivateEndpointConnectionProvisioningState, error) { + vals := map[string]PrivateEndpointConnectionProvisioningState{ + "creating": PrivateEndpointConnectionProvisioningStateCreating, + "deleting": PrivateEndpointConnectionProvisioningStateDeleting, + "failed": PrivateEndpointConnectionProvisioningStateFailed, + "succeeded": PrivateEndpointConnectionProvisioningStateSucceeded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PrivateEndpointConnectionProvisioningState(input) + return &out, nil +} + +type PrivateEndpointServiceConnectionStatus string + +const ( + PrivateEndpointServiceConnectionStatusApproved PrivateEndpointServiceConnectionStatus = "Approved" + PrivateEndpointServiceConnectionStatusPending PrivateEndpointServiceConnectionStatus = "Pending" + PrivateEndpointServiceConnectionStatusRejected PrivateEndpointServiceConnectionStatus = "Rejected" +) + +func PossibleValuesForPrivateEndpointServiceConnectionStatus() []string { + return []string{ + string(PrivateEndpointServiceConnectionStatusApproved), + string(PrivateEndpointServiceConnectionStatusPending), + string(PrivateEndpointServiceConnectionStatusRejected), + } +} + +func parsePrivateEndpointServiceConnectionStatus(input string) (*PrivateEndpointServiceConnectionStatus, error) { + vals := map[string]PrivateEndpointServiceConnectionStatus{ + "approved": PrivateEndpointServiceConnectionStatusApproved, + "pending": PrivateEndpointServiceConnectionStatusPending, + "rejected": PrivateEndpointServiceConnectionStatusRejected, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PrivateEndpointServiceConnectionStatus(input) + return &out, nil +} + +type ProvisioningState string + +const ( + ProvisioningStateAccepted ProvisioningState = "Accepted" + ProvisioningStateCanceled ProvisioningState = "Canceled" + ProvisioningStateCreating ProvisioningState = "Creating" + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateDeprovisioned ProvisioningState = "Deprovisioned" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + ProvisioningStateUpdating ProvisioningState = "Updating" + ProvisioningStateVerifying ProvisioningState = "Verifying" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateAccepted), + string(ProvisioningStateCanceled), + string(ProvisioningStateCreating), + string(ProvisioningStateDeleting), + string(ProvisioningStateDeprovisioned), + string(ProvisioningStateFailed), + string(ProvisioningStateSucceeded), + string(ProvisioningStateUpdating), + string(ProvisioningStateVerifying), + } +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "accepted": ProvisioningStateAccepted, + "canceled": ProvisioningStateCanceled, + "creating": ProvisioningStateCreating, + "deleting": ProvisioningStateDeleting, + "deprovisioned": ProvisioningStateDeprovisioned, + "failed": ProvisioningStateFailed, + "succeeded": ProvisioningStateSucceeded, + "updating": ProvisioningStateUpdating, + "verifying": ProvisioningStateVerifying, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} + +type PublicNetworkAccess string + +const ( + PublicNetworkAccessDisabled PublicNetworkAccess = "Disabled" + PublicNetworkAccessEnabled PublicNetworkAccess = "Enabled" +) + +func PossibleValuesForPublicNetworkAccess() []string { + return []string{ + string(PublicNetworkAccessDisabled), + string(PublicNetworkAccessEnabled), + } +} + +func parsePublicNetworkAccess(input string) (*PublicNetworkAccess, error) { + vals := map[string]PublicNetworkAccess{ + "disabled": PublicNetworkAccessDisabled, + "enabled": PublicNetworkAccessEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PublicNetworkAccess(input) + return &out, nil +} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/collection/method_serviceslist_autorest.go b/internal/services/healthcare/sdk/2021-06-01-preview/collection/method_serviceslist_autorest.go new file mode 100644 index 000000000000..43106463a451 --- /dev/null +++ b/internal/services/healthcare/sdk/2021-06-01-preview/collection/method_serviceslist_autorest.go @@ -0,0 +1,184 @@ +package collection + +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" +) + +type ServicesListResponse struct { + HttpResponse *http.Response + Model *[]ServicesDescription + + nextLink *string + nextPageFunc func(ctx context.Context, nextLink string) (ServicesListResponse, error) +} + +type ServicesListCompleteResult struct { + Items []ServicesDescription +} + +func (r ServicesListResponse) HasMore() bool { + return r.nextLink != nil +} + +func (r ServicesListResponse) LoadMore(ctx context.Context) (resp ServicesListResponse, err error) { + if !r.HasMore() { + err = fmt.Errorf("no more pages returned") + return + } + return r.nextPageFunc(ctx, *r.nextLink) +} + +// ServicesList ... +func (c CollectionClient) ServicesList(ctx context.Context, id commonids.SubscriptionId) (resp ServicesListResponse, err error) { + req, err := c.preparerForServicesList(ctx, id) + if err != nil { + err = autorest.NewErrorWithError(err, "collection.CollectionClient", "ServicesList", nil, "Failure preparing request") + return + } + + resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "collection.CollectionClient", "ServicesList", resp.HttpResponse, "Failure sending request") + return + } + + resp, err = c.responderForServicesList(resp.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "collection.CollectionClient", "ServicesList", resp.HttpResponse, "Failure responding to request") + return + } + return +} + +// ServicesListComplete retrieves all of the results into a single object +func (c CollectionClient) ServicesListComplete(ctx context.Context, id commonids.SubscriptionId) (ServicesListCompleteResult, error) { + return c.ServicesListCompleteMatchingPredicate(ctx, id, ServicesDescriptionPredicate{}) +} + +// ServicesListCompleteMatchingPredicate retrieves all of the results and then applied the predicate +func (c CollectionClient) ServicesListCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate ServicesDescriptionPredicate) (resp ServicesListCompleteResult, err error) { + items := make([]ServicesDescription, 0) + + page, err := c.ServicesList(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 := ServicesListCompleteResult{ + Items: items, + } + return out, nil +} + +// preparerForServicesList prepares the ServicesList request. +func (c CollectionClient) preparerForServicesList(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.HealthcareApis/services", id.ID())), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// preparerForServicesListWithNextLink prepares the ServicesList request with the given nextLink token. +func (c CollectionClient) preparerForServicesListWithNextLink(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)) +} + +// responderForServicesList handles the response to the ServicesList request. The method always +// closes the http.Response Body. +func (c CollectionClient) responderForServicesList(resp *http.Response) (result ServicesListResponse, err error) { + type page struct { + Values []ServicesDescription `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 ServicesListResponse, err error) { + req, err := c.preparerForServicesListWithNextLink(ctx, nextLink) + if err != nil { + err = autorest.NewErrorWithError(err, "collection.CollectionClient", "ServicesList", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "collection.CollectionClient", "ServicesList", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForServicesList(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "collection.CollectionClient", "ServicesList", result.HttpResponse, "Failure responding to request") + return + } + + return + } + } + return +} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/collection/method_serviceslistbyresourcegroup_autorest.go b/internal/services/healthcare/sdk/2021-06-01-preview/collection/method_serviceslistbyresourcegroup_autorest.go new file mode 100644 index 000000000000..b57331bf1292 --- /dev/null +++ b/internal/services/healthcare/sdk/2021-06-01-preview/collection/method_serviceslistbyresourcegroup_autorest.go @@ -0,0 +1,184 @@ +package collection + +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" +) + +type ServicesListByResourceGroupResponse struct { + HttpResponse *http.Response + Model *[]ServicesDescription + + nextLink *string + nextPageFunc func(ctx context.Context, nextLink string) (ServicesListByResourceGroupResponse, error) +} + +type ServicesListByResourceGroupCompleteResult struct { + Items []ServicesDescription +} + +func (r ServicesListByResourceGroupResponse) HasMore() bool { + return r.nextLink != nil +} + +func (r ServicesListByResourceGroupResponse) LoadMore(ctx context.Context) (resp ServicesListByResourceGroupResponse, err error) { + if !r.HasMore() { + err = fmt.Errorf("no more pages returned") + return + } + return r.nextPageFunc(ctx, *r.nextLink) +} + +// ServicesListByResourceGroup ... +func (c CollectionClient) ServicesListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (resp ServicesListByResourceGroupResponse, err error) { + req, err := c.preparerForServicesListByResourceGroup(ctx, id) + if err != nil { + err = autorest.NewErrorWithError(err, "collection.CollectionClient", "ServicesListByResourceGroup", nil, "Failure preparing request") + return + } + + resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "collection.CollectionClient", "ServicesListByResourceGroup", resp.HttpResponse, "Failure sending request") + return + } + + resp, err = c.responderForServicesListByResourceGroup(resp.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "collection.CollectionClient", "ServicesListByResourceGroup", resp.HttpResponse, "Failure responding to request") + return + } + return +} + +// ServicesListByResourceGroupComplete retrieves all of the results into a single object +func (c CollectionClient) ServicesListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (ServicesListByResourceGroupCompleteResult, error) { + return c.ServicesListByResourceGroupCompleteMatchingPredicate(ctx, id, ServicesDescriptionPredicate{}) +} + +// ServicesListByResourceGroupCompleteMatchingPredicate retrieves all of the results and then applied the predicate +func (c CollectionClient) ServicesListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate ServicesDescriptionPredicate) (resp ServicesListByResourceGroupCompleteResult, err error) { + items := make([]ServicesDescription, 0) + + page, err := c.ServicesListByResourceGroup(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 := ServicesListByResourceGroupCompleteResult{ + Items: items, + } + return out, nil +} + +// preparerForServicesListByResourceGroup prepares the ServicesListByResourceGroup request. +func (c CollectionClient) preparerForServicesListByResourceGroup(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.HealthcareApis/services", id.ID())), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// preparerForServicesListByResourceGroupWithNextLink prepares the ServicesListByResourceGroup request with the given nextLink token. +func (c CollectionClient) preparerForServicesListByResourceGroupWithNextLink(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)) +} + +// responderForServicesListByResourceGroup handles the response to the ServicesListByResourceGroup request. The method always +// closes the http.Response Body. +func (c CollectionClient) responderForServicesListByResourceGroup(resp *http.Response) (result ServicesListByResourceGroupResponse, err error) { + type page struct { + Values []ServicesDescription `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 ServicesListByResourceGroupResponse, err error) { + req, err := c.preparerForServicesListByResourceGroupWithNextLink(ctx, nextLink) + if err != nil { + err = autorest.NewErrorWithError(err, "collection.CollectionClient", "ServicesListByResourceGroup", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "collection.CollectionClient", "ServicesListByResourceGroup", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForServicesListByResourceGroup(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "collection.CollectionClient", "ServicesListByResourceGroup", result.HttpResponse, "Failure responding to request") + return + } + + return + } + } + return +} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/collection/model_privateendpoint.go b/internal/services/healthcare/sdk/2021-06-01-preview/collection/model_privateendpoint.go new file mode 100644 index 000000000000..4fbaafd6baef --- /dev/null +++ b/internal/services/healthcare/sdk/2021-06-01-preview/collection/model_privateendpoint.go @@ -0,0 +1,5 @@ +package collection + +type PrivateEndpoint struct { + Id *string `json:"id,omitempty"` +} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/collection/model_privateendpointconnection.go b/internal/services/healthcare/sdk/2021-06-01-preview/collection/model_privateendpointconnection.go new file mode 100644 index 000000000000..bb27ca23f744 --- /dev/null +++ b/internal/services/healthcare/sdk/2021-06-01-preview/collection/model_privateendpointconnection.go @@ -0,0 +1,8 @@ +package collection + +type PrivateEndpointConnection struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateEndpointConnectionProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/collection/model_privateendpointconnectionproperties.go b/internal/services/healthcare/sdk/2021-06-01-preview/collection/model_privateendpointconnectionproperties.go new file mode 100644 index 000000000000..4610ed7818db --- /dev/null +++ b/internal/services/healthcare/sdk/2021-06-01-preview/collection/model_privateendpointconnectionproperties.go @@ -0,0 +1,7 @@ +package collection + +type PrivateEndpointConnectionProperties struct { + PrivateEndpoint *PrivateEndpoint `json:"privateEndpoint,omitempty"` + PrivateLinkServiceConnectionState PrivateLinkServiceConnectionState `json:"privateLinkServiceConnectionState"` + ProvisioningState *PrivateEndpointConnectionProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/collection/model_privatelinkserviceconnectionstate.go b/internal/services/healthcare/sdk/2021-06-01-preview/collection/model_privatelinkserviceconnectionstate.go new file mode 100644 index 000000000000..fe6619d2e5b3 --- /dev/null +++ b/internal/services/healthcare/sdk/2021-06-01-preview/collection/model_privatelinkserviceconnectionstate.go @@ -0,0 +1,7 @@ +package collection + +type PrivateLinkServiceConnectionState struct { + ActionsRequired *string `json:"actionsRequired,omitempty"` + Description *string `json:"description,omitempty"` + Status *PrivateEndpointServiceConnectionStatus `json:"status,omitempty"` +} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/collection/model_serviceaccesspolicyentry.go b/internal/services/healthcare/sdk/2021-06-01-preview/collection/model_serviceaccesspolicyentry.go new file mode 100644 index 000000000000..788b9abe36c4 --- /dev/null +++ b/internal/services/healthcare/sdk/2021-06-01-preview/collection/model_serviceaccesspolicyentry.go @@ -0,0 +1,5 @@ +package collection + +type ServiceAccessPolicyEntry struct { + ObjectId string `json:"objectId"` +} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/collection/model_serviceacrconfigurationinfo.go b/internal/services/healthcare/sdk/2021-06-01-preview/collection/model_serviceacrconfigurationinfo.go new file mode 100644 index 000000000000..e6aba5385d12 --- /dev/null +++ b/internal/services/healthcare/sdk/2021-06-01-preview/collection/model_serviceacrconfigurationinfo.go @@ -0,0 +1,5 @@ +package collection + +type ServiceAcrConfigurationInfo struct { + LoginServers *[]string `json:"loginServers,omitempty"` +} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/collection/model_serviceauthenticationconfigurationinfo.go b/internal/services/healthcare/sdk/2021-06-01-preview/collection/model_serviceauthenticationconfigurationinfo.go new file mode 100644 index 000000000000..817440eddd27 --- /dev/null +++ b/internal/services/healthcare/sdk/2021-06-01-preview/collection/model_serviceauthenticationconfigurationinfo.go @@ -0,0 +1,7 @@ +package collection + +type ServiceAuthenticationConfigurationInfo struct { + Audience *string `json:"audience,omitempty"` + Authority *string `json:"authority,omitempty"` + SmartProxyEnabled *bool `json:"smartProxyEnabled,omitempty"` +} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/collection/model_servicecorsconfigurationinfo.go b/internal/services/healthcare/sdk/2021-06-01-preview/collection/model_servicecorsconfigurationinfo.go new file mode 100644 index 000000000000..c8c1e73b44ad --- /dev/null +++ b/internal/services/healthcare/sdk/2021-06-01-preview/collection/model_servicecorsconfigurationinfo.go @@ -0,0 +1,9 @@ +package collection + +type ServiceCorsConfigurationInfo struct { + AllowCredentials *bool `json:"allowCredentials,omitempty"` + Headers *[]string `json:"headers,omitempty"` + MaxAge *int64 `json:"maxAge,omitempty"` + Methods *[]string `json:"methods,omitempty"` + Origins *[]string `json:"origins,omitempty"` +} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/collection/model_servicecosmosdbconfigurationinfo.go b/internal/services/healthcare/sdk/2021-06-01-preview/collection/model_servicecosmosdbconfigurationinfo.go new file mode 100644 index 000000000000..eec76c56a531 --- /dev/null +++ b/internal/services/healthcare/sdk/2021-06-01-preview/collection/model_servicecosmosdbconfigurationinfo.go @@ -0,0 +1,6 @@ +package collection + +type ServiceCosmosDbConfigurationInfo struct { + KeyVaultKeyUri *string `json:"keyVaultKeyUri,omitempty"` + OfferThroughput *int64 `json:"offerThroughput,omitempty"` +} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/collection/model_serviceexportconfigurationinfo.go b/internal/services/healthcare/sdk/2021-06-01-preview/collection/model_serviceexportconfigurationinfo.go new file mode 100644 index 000000000000..eee5a8843e2b --- /dev/null +++ b/internal/services/healthcare/sdk/2021-06-01-preview/collection/model_serviceexportconfigurationinfo.go @@ -0,0 +1,5 @@ +package collection + +type ServiceExportConfigurationInfo struct { + StorageAccountName *string `json:"storageAccountName,omitempty"` +} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/collection/model_servicesdescription.go b/internal/services/healthcare/sdk/2021-06-01-preview/collection/model_servicesdescription.go new file mode 100644 index 000000000000..0571a820794e --- /dev/null +++ b/internal/services/healthcare/sdk/2021-06-01-preview/collection/model_servicesdescription.go @@ -0,0 +1,18 @@ +package collection + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/identity" +) + +type ServicesDescription struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Identity *identity.SystemAssigned `json:"identity,omitempty"` + Kind Kind `json:"kind"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties *ServicesProperties `json:"properties,omitempty"` + SystemData *SystemData `json:"systemData,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/collection/model_servicesproperties.go b/internal/services/healthcare/sdk/2021-06-01-preview/collection/model_servicesproperties.go new file mode 100644 index 000000000000..aa60431aa653 --- /dev/null +++ b/internal/services/healthcare/sdk/2021-06-01-preview/collection/model_servicesproperties.go @@ -0,0 +1,13 @@ +package collection + +type ServicesProperties struct { + AccessPolicies *[]ServiceAccessPolicyEntry `json:"accessPolicies,omitempty"` + AcrConfiguration *ServiceAcrConfigurationInfo `json:"acrConfiguration,omitempty"` + AuthenticationConfiguration *ServiceAuthenticationConfigurationInfo `json:"authenticationConfiguration,omitempty"` + CorsConfiguration *ServiceCorsConfigurationInfo `json:"corsConfiguration,omitempty"` + CosmosDbConfiguration *ServiceCosmosDbConfigurationInfo `json:"cosmosDbConfiguration,omitempty"` + ExportConfiguration *ServiceExportConfigurationInfo `json:"exportConfiguration,omitempty"` + PrivateEndpointConnections *[]PrivateEndpointConnection `json:"privateEndpointConnections,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + PublicNetworkAccess *PublicNetworkAccess `json:"publicNetworkAccess,omitempty"` +} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/collection/model_systemdata.go b/internal/services/healthcare/sdk/2021-06-01-preview/collection/model_systemdata.go new file mode 100644 index 000000000000..a8361db52cda --- /dev/null +++ b/internal/services/healthcare/sdk/2021-06-01-preview/collection/model_systemdata.go @@ -0,0 +1,40 @@ +package collection + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +type SystemData struct { + CreatedAt *string `json:"createdAt,omitempty"` + CreatedBy *string `json:"createdBy,omitempty"` + CreatedByType *CreatedByType `json:"createdByType,omitempty"` + LastModifiedAt *string `json:"lastModifiedAt,omitempty"` + LastModifiedBy *string `json:"lastModifiedBy,omitempty"` + LastModifiedByType *CreatedByType `json:"lastModifiedByType,omitempty"` +} + +func (o SystemData) GetCreatedAtAsTime() (*time.Time, error) { + if o.CreatedAt == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreatedAt, "2006-01-02T15:04:05Z07:00") +} + +func (o SystemData) SetCreatedAtAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreatedAt = &formatted +} + +func (o SystemData) GetLastModifiedAtAsTime() (*time.Time, error) { + if o.LastModifiedAt == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastModifiedAt, "2006-01-02T15:04:05Z07:00") +} + +func (o SystemData) SetLastModifiedAtAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastModifiedAt = &formatted +} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/collection/predicates.go b/internal/services/healthcare/sdk/2021-06-01-preview/collection/predicates.go new file mode 100644 index 000000000000..b62be96254a8 --- /dev/null +++ b/internal/services/healthcare/sdk/2021-06-01-preview/collection/predicates.go @@ -0,0 +1,34 @@ +package collection + +type ServicesDescriptionPredicate struct { + Etag *string + Id *string + Location *string + Name *string + Type *string +} + +func (p ServicesDescriptionPredicate) Matches(input ServicesDescription) bool { + + if p.Etag != nil && (input.Etag == nil && *p.Etag != *input.Etag) { + return false + } + + if p.Id != nil && (input.Id == nil && *p.Id != *input.Id) { + return false + } + + if p.Location != nil && *p.Location != input.Location { + return false + } + + if p.Name != nil && (input.Name == nil && *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil && *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/collection/version.go b/internal/services/healthcare/sdk/2021-06-01-preview/collection/version.go new file mode 100644 index 000000000000..239a2aed75d6 --- /dev/null +++ b/internal/services/healthcare/sdk/2021-06-01-preview/collection/version.go @@ -0,0 +1,9 @@ +package collection + +import "fmt" + +const defaultApiVersion = "2021-06-01-preview" + +func userAgent() string { + return fmt.Sprintf("pandora/collection/%s", defaultApiVersion) +} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/dicomservices/client.go b/internal/services/healthcare/sdk/2021-06-01-preview/dicomservices/client.go new file mode 100644 index 000000000000..f28417b70643 --- /dev/null +++ b/internal/services/healthcare/sdk/2021-06-01-preview/dicomservices/client.go @@ -0,0 +1,15 @@ +package dicomservices + +import "github.com/Azure/go-autorest/autorest" + +type DicomServicesClient struct { + Client autorest.Client + baseUri string +} + +func NewDicomServicesClientWithBaseURI(endpoint string) DicomServicesClient { + return DicomServicesClient{ + Client: autorest.NewClientWithUserAgent(userAgent()), + baseUri: endpoint, + } +} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/dicomservices/constants.go b/internal/services/healthcare/sdk/2021-06-01-preview/dicomservices/constants.go new file mode 100644 index 000000000000..d717e5afcf42 --- /dev/null +++ b/internal/services/healthcare/sdk/2021-06-01-preview/dicomservices/constants.go @@ -0,0 +1,98 @@ +package dicomservices + +import "strings" + +type CreatedByType string + +const ( + CreatedByTypeApplication CreatedByType = "Application" + CreatedByTypeKey CreatedByType = "Key" + CreatedByTypeManagedIdentity CreatedByType = "ManagedIdentity" + CreatedByTypeUser CreatedByType = "User" +) + +func PossibleValuesForCreatedByType() []string { + return []string{ + string(CreatedByTypeApplication), + string(CreatedByTypeKey), + string(CreatedByTypeManagedIdentity), + string(CreatedByTypeUser), + } +} + +func parseCreatedByType(input string) (*CreatedByType, error) { + vals := map[string]CreatedByType{ + "application": CreatedByTypeApplication, + "key": CreatedByTypeKey, + "managedidentity": CreatedByTypeManagedIdentity, + "user": CreatedByTypeUser, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := CreatedByType(input) + return &out, nil +} + +type ProvisioningState string + +const ( + ProvisioningStateAccepted ProvisioningState = "Accepted" + ProvisioningStateCanceled ProvisioningState = "Canceled" + ProvisioningStateCreating ProvisioningState = "Creating" + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateDeprovisioned ProvisioningState = "Deprovisioned" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateMoving ProvisioningState = "Moving" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + ProvisioningStateSuspended ProvisioningState = "Suspended" + ProvisioningStateSystemMaintenance ProvisioningState = "SystemMaintenance" + ProvisioningStateUpdating ProvisioningState = "Updating" + ProvisioningStateVerifying ProvisioningState = "Verifying" + ProvisioningStateWarned ProvisioningState = "Warned" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateAccepted), + string(ProvisioningStateCanceled), + string(ProvisioningStateCreating), + string(ProvisioningStateDeleting), + string(ProvisioningStateDeprovisioned), + string(ProvisioningStateFailed), + string(ProvisioningStateMoving), + string(ProvisioningStateSucceeded), + string(ProvisioningStateSuspended), + string(ProvisioningStateSystemMaintenance), + string(ProvisioningStateUpdating), + string(ProvisioningStateVerifying), + string(ProvisioningStateWarned), + } +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "accepted": ProvisioningStateAccepted, + "canceled": ProvisioningStateCanceled, + "creating": ProvisioningStateCreating, + "deleting": ProvisioningStateDeleting, + "deprovisioned": ProvisioningStateDeprovisioned, + "failed": ProvisioningStateFailed, + "moving": ProvisioningStateMoving, + "succeeded": ProvisioningStateSucceeded, + "suspended": ProvisioningStateSuspended, + "systemmaintenance": ProvisioningStateSystemMaintenance, + "updating": ProvisioningStateUpdating, + "verifying": ProvisioningStateVerifying, + "warned": ProvisioningStateWarned, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/dicomservices/id_dicomservice.go b/internal/services/healthcare/sdk/2021-06-01-preview/dicomservices/id_dicomservice.go new file mode 100644 index 000000000000..02bbcd1b3322 --- /dev/null +++ b/internal/services/healthcare/sdk/2021-06-01-preview/dicomservices/id_dicomservice.go @@ -0,0 +1,137 @@ +package dicomservices + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +var _ resourceids.ResourceId = DicomServiceId{} + +// DicomServiceId is a struct representing the Resource ID for a Dicom Service +type DicomServiceId struct { + SubscriptionId string + ResourceGroupName string + WorkspaceName string + DicomServiceName string +} + +// NewDicomServiceID returns a new DicomServiceId struct +func NewDicomServiceID(subscriptionId string, resourceGroupName string, workspaceName string, dicomServiceName string) DicomServiceId { + return DicomServiceId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + WorkspaceName: workspaceName, + DicomServiceName: dicomServiceName, + } +} + +// ParseDicomServiceID parses 'input' into a DicomServiceId +func ParseDicomServiceID(input string) (*DicomServiceId, error) { + parser := resourceids.NewParserFromResourceIdType(DicomServiceId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := DicomServiceId{} + + if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { + return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) + } + + if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { + return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) + } + + if id.WorkspaceName, ok = parsed.Parsed["workspaceName"]; !ok { + return nil, fmt.Errorf("the segment 'workspaceName' was not found in the resource id %q", input) + } + + if id.DicomServiceName, ok = parsed.Parsed["dicomServiceName"]; !ok { + return nil, fmt.Errorf("the segment 'dicomServiceName' was not found in the resource id %q", input) + } + + return &id, nil +} + +// ParseDicomServiceIDInsensitively parses 'input' case-insensitively into a DicomServiceId +// note: this method should only be used for API response data and not user input +func ParseDicomServiceIDInsensitively(input string) (*DicomServiceId, error) { + parser := resourceids.NewParserFromResourceIdType(DicomServiceId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := DicomServiceId{} + + if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { + return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) + } + + if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { + return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) + } + + if id.WorkspaceName, ok = parsed.Parsed["workspaceName"]; !ok { + return nil, fmt.Errorf("the segment 'workspaceName' was not found in the resource id %q", input) + } + + if id.DicomServiceName, ok = parsed.Parsed["dicomServiceName"]; !ok { + return nil, fmt.Errorf("the segment 'dicomServiceName' was not found in the resource id %q", input) + } + + return &id, nil +} + +// ValidateDicomServiceID checks that 'input' can be parsed as a Dicom Service ID +func ValidateDicomServiceID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseDicomServiceID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Dicom Service ID +func (id DicomServiceId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.HealthcareApis/workspaces/%s/dicomServices/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.WorkspaceName, id.DicomServiceName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Dicom Service ID +func (id DicomServiceId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftHealthcareApis", "Microsoft.HealthcareApis", "Microsoft.HealthcareApis"), + resourceids.StaticSegment("staticWorkspaces", "workspaces", "workspaces"), + resourceids.UserSpecifiedSegment("workspaceName", "workspaceValue"), + resourceids.StaticSegment("staticDicomServices", "dicomServices", "dicomServices"), + resourceids.UserSpecifiedSegment("dicomServiceName", "dicomServiceValue"), + } +} + +// String returns a human-readable description of this Dicom Service ID +func (id DicomServiceId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Workspace Name: %q", id.WorkspaceName), + fmt.Sprintf("Dicom Service Name: %q", id.DicomServiceName), + } + return fmt.Sprintf("Dicom Service (%s)", strings.Join(components, "\n")) +} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/dicomservices/id_dicomservice_test.go b/internal/services/healthcare/sdk/2021-06-01-preview/dicomservices/id_dicomservice_test.go new file mode 100644 index 000000000000..2ea7f0c98c99 --- /dev/null +++ b/internal/services/healthcare/sdk/2021-06-01-preview/dicomservices/id_dicomservice_test.go @@ -0,0 +1,324 @@ +package dicomservices + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +var _ resourceids.ResourceId = DicomServiceId{} + +func TestNewDicomServiceID(t *testing.T) { + id := NewDicomServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceValue", "dicomServiceValue") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.WorkspaceName != "workspaceValue" { + t.Fatalf("Expected %q but got %q for Segment 'WorkspaceName'", id.WorkspaceName, "workspaceValue") + } + + if id.DicomServiceName != "dicomServiceValue" { + t.Fatalf("Expected %q but got %q for Segment 'DicomServiceName'", id.DicomServiceName, "dicomServiceValue") + } +} + +func TestFormatDicomServiceID(t *testing.T) { + actual := NewDicomServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceValue", "dicomServiceValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/workspaces/workspaceValue/dicomServices/dicomServiceValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseDicomServiceID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DicomServiceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/workspaces", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/workspaces/workspaceValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/workspaces/workspaceValue/dicomServices", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/workspaces/workspaceValue/dicomServices/dicomServiceValue", + Expected: &DicomServiceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceValue", + DicomServiceName: "dicomServiceValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/workspaces/workspaceValue/dicomServices/dicomServiceValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDicomServiceID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + if actual.DicomServiceName != v.Expected.DicomServiceName { + t.Fatalf("Expected %q but got %q for DicomServiceName", v.Expected.DicomServiceName, actual.DicomServiceName) + } + + } +} + +func TestParseDicomServiceIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DicomServiceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hEaLtHcArEaPiS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/workspaces", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hEaLtHcArEaPiS/wOrKsPaCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/workspaces/workspaceValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hEaLtHcArEaPiS/wOrKsPaCeS/wOrKsPaCeVaLuE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/workspaces/workspaceValue/dicomServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hEaLtHcArEaPiS/wOrKsPaCeS/wOrKsPaCeVaLuE/dIcOmSeRvIcEs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/workspaces/workspaceValue/dicomServices/dicomServiceValue", + Expected: &DicomServiceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceValue", + DicomServiceName: "dicomServiceValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/workspaces/workspaceValue/dicomServices/dicomServiceValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hEaLtHcArEaPiS/wOrKsPaCeS/wOrKsPaCeVaLuE/dIcOmSeRvIcEs/dIcOmSeRvIcEvAlUe", + Expected: &DicomServiceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + WorkspaceName: "wOrKsPaCeVaLuE", + DicomServiceName: "dIcOmSeRvIcEvAlUe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hEaLtHcArEaPiS/wOrKsPaCeS/wOrKsPaCeVaLuE/dIcOmSeRvIcEs/dIcOmSeRvIcEvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDicomServiceIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + if actual.DicomServiceName != v.Expected.DicomServiceName { + t.Fatalf("Expected %q but got %q for DicomServiceName", v.Expected.DicomServiceName, actual.DicomServiceName) + } + + } +} + +func TestSegmentsForDicomServiceId(t *testing.T) { + segments := DicomServiceId{}.Segments() + if len(segments) == 0 { + t.Fatalf("DicomServiceId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/dicomservices/id_workspace.go b/internal/services/healthcare/sdk/2021-06-01-preview/dicomservices/id_workspace.go new file mode 100644 index 000000000000..cce75d91dddb --- /dev/null +++ b/internal/services/healthcare/sdk/2021-06-01-preview/dicomservices/id_workspace.go @@ -0,0 +1,124 @@ +package dicomservices + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +var _ resourceids.ResourceId = WorkspaceId{} + +// WorkspaceId is a struct representing the Resource ID for a Workspace +type WorkspaceId struct { + SubscriptionId string + ResourceGroupName string + WorkspaceName string +} + +// NewWorkspaceID returns a new WorkspaceId struct +func NewWorkspaceID(subscriptionId string, resourceGroupName string, workspaceName string) WorkspaceId { + return WorkspaceId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + WorkspaceName: workspaceName, + } +} + +// ParseWorkspaceID parses 'input' into a WorkspaceId +func ParseWorkspaceID(input string) (*WorkspaceId, error) { + parser := resourceids.NewParserFromResourceIdType(WorkspaceId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := WorkspaceId{} + + if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { + return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) + } + + if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { + return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) + } + + if id.WorkspaceName, ok = parsed.Parsed["workspaceName"]; !ok { + return nil, fmt.Errorf("the segment 'workspaceName' was not found in the resource id %q", input) + } + + return &id, nil +} + +// ParseWorkspaceIDInsensitively parses 'input' case-insensitively into a WorkspaceId +// note: this method should only be used for API response data and not user input +func ParseWorkspaceIDInsensitively(input string) (*WorkspaceId, error) { + parser := resourceids.NewParserFromResourceIdType(WorkspaceId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := WorkspaceId{} + + if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { + return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) + } + + if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { + return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) + } + + if id.WorkspaceName, ok = parsed.Parsed["workspaceName"]; !ok { + return nil, fmt.Errorf("the segment 'workspaceName' was not found in the resource id %q", input) + } + + return &id, nil +} + +// ValidateWorkspaceID checks that 'input' can be parsed as a Workspace ID +func ValidateWorkspaceID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseWorkspaceID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Workspace ID +func (id WorkspaceId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.HealthcareApis/workspaces/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.WorkspaceName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Workspace ID +func (id WorkspaceId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftHealthcareApis", "Microsoft.HealthcareApis", "Microsoft.HealthcareApis"), + resourceids.StaticSegment("staticWorkspaces", "workspaces", "workspaces"), + resourceids.UserSpecifiedSegment("workspaceName", "workspaceValue"), + } +} + +// String returns a human-readable description of this Workspace ID +func (id WorkspaceId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Workspace Name: %q", id.WorkspaceName), + } + return fmt.Sprintf("Workspace (%s)", strings.Join(components, "\n")) +} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/dicomservices/id_workspace_test.go b/internal/services/healthcare/sdk/2021-06-01-preview/dicomservices/id_workspace_test.go new file mode 100644 index 000000000000..1d85dcbe025f --- /dev/null +++ b/internal/services/healthcare/sdk/2021-06-01-preview/dicomservices/id_workspace_test.go @@ -0,0 +1,279 @@ +package dicomservices + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +var _ resourceids.ResourceId = WorkspaceId{} + +func TestNewWorkspaceID(t *testing.T) { + id := NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceValue") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.WorkspaceName != "workspaceValue" { + t.Fatalf("Expected %q but got %q for Segment 'WorkspaceName'", id.WorkspaceName, "workspaceValue") + } +} + +func TestFormatWorkspaceID(t *testing.T) { + actual := NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/workspaces/workspaceValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseWorkspaceID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *WorkspaceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/workspaces", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/workspaces/workspaceValue", + Expected: &WorkspaceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/workspaces/workspaceValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseWorkspaceID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + } +} + +func TestParseWorkspaceIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *WorkspaceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hEaLtHcArEaPiS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/workspaces", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hEaLtHcArEaPiS/wOrKsPaCeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/workspaces/workspaceValue", + Expected: &WorkspaceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/workspaces/workspaceValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hEaLtHcArEaPiS/wOrKsPaCeS/wOrKsPaCeVaLuE", + Expected: &WorkspaceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + WorkspaceName: "wOrKsPaCeVaLuE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hEaLtHcArEaPiS/wOrKsPaCeS/wOrKsPaCeVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseWorkspaceIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + } +} + +func TestSegmentsForWorkspaceId(t *testing.T) { + segments := WorkspaceId{}.Segments() + if len(segments) == 0 { + t.Fatalf("WorkspaceId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/dicomservices/method_createorupdate_autorest.go b/internal/services/healthcare/sdk/2021-06-01-preview/dicomservices/method_createorupdate_autorest.go new file mode 100644 index 000000000000..3e5b6eeda9cc --- /dev/null +++ b/internal/services/healthcare/sdk/2021-06-01-preview/dicomservices/method_createorupdate_autorest.go @@ -0,0 +1,75 @@ +package dicomservices + +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" +) + +type CreateOrUpdateResponse struct { + Poller polling.LongRunningPoller + HttpResponse *http.Response +} + +// CreateOrUpdate ... +func (c DicomServicesClient) CreateOrUpdate(ctx context.Context, id DicomServiceId, input DicomService) (result CreateOrUpdateResponse, err error) { + req, err := c.preparerForCreateOrUpdate(ctx, id, input) + if err != nil { + err = autorest.NewErrorWithError(err, "dicomservices.DicomServicesClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = c.senderForCreateOrUpdate(ctx, req) + if err != nil { + err = autorest.NewErrorWithError(err, "dicomservices.DicomServicesClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") + return + } + + return +} + +// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed +func (c DicomServicesClient) CreateOrUpdateThenPoll(ctx context.Context, id DicomServiceId, input DicomService) 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 DicomServicesClient) preparerForCreateOrUpdate(ctx context.Context, id DicomServiceId, input DicomService) (*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 DicomServicesClient) senderForCreateOrUpdate(ctx context.Context, req *http.Request) (future CreateOrUpdateResponse, err error) { + var resp *http.Response + resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + return + } + future.Poller, err = polling.NewLongRunningPollerFromResponse(ctx, resp, c.Client) + return +} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/dicomservices/method_delete_autorest.go b/internal/services/healthcare/sdk/2021-06-01-preview/dicomservices/method_delete_autorest.go new file mode 100644 index 000000000000..f68d272b8339 --- /dev/null +++ b/internal/services/healthcare/sdk/2021-06-01-preview/dicomservices/method_delete_autorest.go @@ -0,0 +1,74 @@ +package dicomservices + +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" +) + +type DeleteResponse struct { + Poller polling.LongRunningPoller + HttpResponse *http.Response +} + +// Delete ... +func (c DicomServicesClient) Delete(ctx context.Context, id DicomServiceId) (result DeleteResponse, err error) { + req, err := c.preparerForDelete(ctx, id) + if err != nil { + err = autorest.NewErrorWithError(err, "dicomservices.DicomServicesClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = c.senderForDelete(ctx, req) + if err != nil { + err = autorest.NewErrorWithError(err, "dicomservices.DicomServicesClient", "Delete", result.HttpResponse, "Failure sending request") + return + } + + return +} + +// DeleteThenPoll performs Delete then polls until it's completed +func (c DicomServicesClient) DeleteThenPoll(ctx context.Context, id DicomServiceId) 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 DicomServicesClient) preparerForDelete(ctx context.Context, id DicomServiceId) (*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 DicomServicesClient) senderForDelete(ctx context.Context, req *http.Request) (future DeleteResponse, err error) { + var resp *http.Response + resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + return + } + future.Poller, err = polling.NewLongRunningPollerFromResponse(ctx, resp, c.Client) + return +} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/dicomservices/method_get_autorest.go b/internal/services/healthcare/sdk/2021-06-01-preview/dicomservices/method_get_autorest.go new file mode 100644 index 000000000000..9d7252dedec2 --- /dev/null +++ b/internal/services/healthcare/sdk/2021-06-01-preview/dicomservices/method_get_autorest.go @@ -0,0 +1,64 @@ +package dicomservices + +import ( + "context" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +type GetResponse struct { + HttpResponse *http.Response + Model *DicomService +} + +// Get ... +func (c DicomServicesClient) Get(ctx context.Context, id DicomServiceId) (result GetResponse, err error) { + req, err := c.preparerForGet(ctx, id) + if err != nil { + err = autorest.NewErrorWithError(err, "dicomservices.DicomServicesClient", "Get", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "dicomservices.DicomServicesClient", "Get", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForGet(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "dicomservices.DicomServicesClient", "Get", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForGet prepares the Get request. +func (c DicomServicesClient) preparerForGet(ctx context.Context, id DicomServiceId) (*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 DicomServicesClient) responderForGet(resp *http.Response) (result GetResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Model), + autorest.ByClosing()) + result.HttpResponse = resp + return +} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/dicomservices/method_listbyworkspace_autorest.go b/internal/services/healthcare/sdk/2021-06-01-preview/dicomservices/method_listbyworkspace_autorest.go new file mode 100644 index 000000000000..978262b2923c --- /dev/null +++ b/internal/services/healthcare/sdk/2021-06-01-preview/dicomservices/method_listbyworkspace_autorest.go @@ -0,0 +1,183 @@ +package dicomservices + +import ( + "context" + "fmt" + "net/http" + "net/url" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +type ListByWorkspaceResponse struct { + HttpResponse *http.Response + Model *[]DicomService + + nextLink *string + nextPageFunc func(ctx context.Context, nextLink string) (ListByWorkspaceResponse, error) +} + +type ListByWorkspaceCompleteResult struct { + Items []DicomService +} + +func (r ListByWorkspaceResponse) HasMore() bool { + return r.nextLink != nil +} + +func (r ListByWorkspaceResponse) LoadMore(ctx context.Context) (resp ListByWorkspaceResponse, err error) { + if !r.HasMore() { + err = fmt.Errorf("no more pages returned") + return + } + return r.nextPageFunc(ctx, *r.nextLink) +} + +// ListByWorkspace ... +func (c DicomServicesClient) ListByWorkspace(ctx context.Context, id WorkspaceId) (resp ListByWorkspaceResponse, err error) { + req, err := c.preparerForListByWorkspace(ctx, id) + if err != nil { + err = autorest.NewErrorWithError(err, "dicomservices.DicomServicesClient", "ListByWorkspace", nil, "Failure preparing request") + return + } + + resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "dicomservices.DicomServicesClient", "ListByWorkspace", resp.HttpResponse, "Failure sending request") + return + } + + resp, err = c.responderForListByWorkspace(resp.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "dicomservices.DicomServicesClient", "ListByWorkspace", resp.HttpResponse, "Failure responding to request") + return + } + return +} + +// ListByWorkspaceComplete retrieves all of the results into a single object +func (c DicomServicesClient) ListByWorkspaceComplete(ctx context.Context, id WorkspaceId) (ListByWorkspaceCompleteResult, error) { + return c.ListByWorkspaceCompleteMatchingPredicate(ctx, id, DicomServicePredicate{}) +} + +// ListByWorkspaceCompleteMatchingPredicate retrieves all of the results and then applied the predicate +func (c DicomServicesClient) ListByWorkspaceCompleteMatchingPredicate(ctx context.Context, id WorkspaceId, predicate DicomServicePredicate) (resp ListByWorkspaceCompleteResult, err error) { + items := make([]DicomService, 0) + + page, err := c.ListByWorkspace(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 := ListByWorkspaceCompleteResult{ + Items: items, + } + return out, nil +} + +// preparerForListByWorkspace prepares the ListByWorkspace request. +func (c DicomServicesClient) preparerForListByWorkspace(ctx context.Context, id WorkspaceId) (*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/dicomServices", id.ID())), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// preparerForListByWorkspaceWithNextLink prepares the ListByWorkspace request with the given nextLink token. +func (c DicomServicesClient) preparerForListByWorkspaceWithNextLink(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)) +} + +// responderForListByWorkspace handles the response to the ListByWorkspace request. The method always +// closes the http.Response Body. +func (c DicomServicesClient) responderForListByWorkspace(resp *http.Response) (result ListByWorkspaceResponse, err error) { + type page struct { + Values []DicomService `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 ListByWorkspaceResponse, err error) { + req, err := c.preparerForListByWorkspaceWithNextLink(ctx, nextLink) + if err != nil { + err = autorest.NewErrorWithError(err, "dicomservices.DicomServicesClient", "ListByWorkspace", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "dicomservices.DicomServicesClient", "ListByWorkspace", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForListByWorkspace(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "dicomservices.DicomServicesClient", "ListByWorkspace", result.HttpResponse, "Failure responding to request") + return + } + + return + } + } + return +} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/dicomservices/method_update_autorest.go b/internal/services/healthcare/sdk/2021-06-01-preview/dicomservices/method_update_autorest.go new file mode 100644 index 000000000000..c62715bcf985 --- /dev/null +++ b/internal/services/healthcare/sdk/2021-06-01-preview/dicomservices/method_update_autorest.go @@ -0,0 +1,75 @@ +package dicomservices + +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" +) + +type UpdateResponse struct { + Poller polling.LongRunningPoller + HttpResponse *http.Response +} + +// Update ... +func (c DicomServicesClient) Update(ctx context.Context, id DicomServiceId, input ResourceTags) (result UpdateResponse, err error) { + req, err := c.preparerForUpdate(ctx, id, input) + if err != nil { + err = autorest.NewErrorWithError(err, "dicomservices.DicomServicesClient", "Update", nil, "Failure preparing request") + return + } + + result, err = c.senderForUpdate(ctx, req) + if err != nil { + err = autorest.NewErrorWithError(err, "dicomservices.DicomServicesClient", "Update", result.HttpResponse, "Failure sending request") + return + } + + return +} + +// UpdateThenPoll performs Update then polls until it's completed +func (c DicomServicesClient) UpdateThenPoll(ctx context.Context, id DicomServiceId, input ResourceTags) 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 DicomServicesClient) preparerForUpdate(ctx context.Context, id DicomServiceId, input ResourceTags) (*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 DicomServicesClient) senderForUpdate(ctx context.Context, req *http.Request) (future UpdateResponse, err error) { + var resp *http.Response + resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + return + } + future.Poller, err = polling.NewLongRunningPollerFromResponse(ctx, resp, c.Client) + return +} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/dicomservices/model_dicomservice.go b/internal/services/healthcare/sdk/2021-06-01-preview/dicomservices/model_dicomservice.go new file mode 100644 index 000000000000..d48dc717ca59 --- /dev/null +++ b/internal/services/healthcare/sdk/2021-06-01-preview/dicomservices/model_dicomservice.go @@ -0,0 +1,12 @@ +package dicomservices + +type DicomService struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *DicomServiceProperties `json:"properties,omitempty"` + SystemData *SystemData `json:"systemData,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/dicomservices/model_dicomserviceauthenticationconfiguration.go b/internal/services/healthcare/sdk/2021-06-01-preview/dicomservices/model_dicomserviceauthenticationconfiguration.go new file mode 100644 index 000000000000..e1c559253e2a --- /dev/null +++ b/internal/services/healthcare/sdk/2021-06-01-preview/dicomservices/model_dicomserviceauthenticationconfiguration.go @@ -0,0 +1,6 @@ +package dicomservices + +type DicomServiceAuthenticationConfiguration struct { + Audiences *[]string `json:"audiences,omitempty"` + Authority *string `json:"authority,omitempty"` +} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/dicomservices/model_dicomserviceproperties.go b/internal/services/healthcare/sdk/2021-06-01-preview/dicomservices/model_dicomserviceproperties.go new file mode 100644 index 000000000000..b55a89d50d5c --- /dev/null +++ b/internal/services/healthcare/sdk/2021-06-01-preview/dicomservices/model_dicomserviceproperties.go @@ -0,0 +1,7 @@ +package dicomservices + +type DicomServiceProperties struct { + AuthenticationConfiguration *DicomServiceAuthenticationConfiguration `json:"authenticationConfiguration,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ServiceUrl *string `json:"serviceUrl,omitempty"` +} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/dicomservices/model_resourcetags.go b/internal/services/healthcare/sdk/2021-06-01-preview/dicomservices/model_resourcetags.go new file mode 100644 index 000000000000..0b836f1bcd4d --- /dev/null +++ b/internal/services/healthcare/sdk/2021-06-01-preview/dicomservices/model_resourcetags.go @@ -0,0 +1,5 @@ +package dicomservices + +type ResourceTags struct { + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/dicomservices/model_systemdata.go b/internal/services/healthcare/sdk/2021-06-01-preview/dicomservices/model_systemdata.go new file mode 100644 index 000000000000..cfe11a5037b6 --- /dev/null +++ b/internal/services/healthcare/sdk/2021-06-01-preview/dicomservices/model_systemdata.go @@ -0,0 +1,40 @@ +package dicomservices + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +type SystemData struct { + CreatedAt *string `json:"createdAt,omitempty"` + CreatedBy *string `json:"createdBy,omitempty"` + CreatedByType *CreatedByType `json:"createdByType,omitempty"` + LastModifiedAt *string `json:"lastModifiedAt,omitempty"` + LastModifiedBy *string `json:"lastModifiedBy,omitempty"` + LastModifiedByType *CreatedByType `json:"lastModifiedByType,omitempty"` +} + +func (o SystemData) GetCreatedAtAsTime() (*time.Time, error) { + if o.CreatedAt == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreatedAt, "2006-01-02T15:04:05Z07:00") +} + +func (o SystemData) SetCreatedAtAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreatedAt = &formatted +} + +func (o SystemData) GetLastModifiedAtAsTime() (*time.Time, error) { + if o.LastModifiedAt == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastModifiedAt, "2006-01-02T15:04:05Z07:00") +} + +func (o SystemData) SetLastModifiedAtAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastModifiedAt = &formatted +} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/dicomservices/predicates.go b/internal/services/healthcare/sdk/2021-06-01-preview/dicomservices/predicates.go new file mode 100644 index 000000000000..c331a042d4bb --- /dev/null +++ b/internal/services/healthcare/sdk/2021-06-01-preview/dicomservices/predicates.go @@ -0,0 +1,34 @@ +package dicomservices + +type DicomServicePredicate struct { + Etag *string + Id *string + Location *string + Name *string + Type *string +} + +func (p DicomServicePredicate) Matches(input DicomService) bool { + + if p.Etag != nil && (input.Etag == nil && *p.Etag != *input.Etag) { + return false + } + + if p.Id != nil && (input.Id == nil && *p.Id != *input.Id) { + return false + } + + if p.Location != nil && (input.Location == nil && *p.Location != *input.Location) { + return false + } + + if p.Name != nil && (input.Name == nil && *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil && *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/dicomservices/version.go b/internal/services/healthcare/sdk/2021-06-01-preview/dicomservices/version.go new file mode 100644 index 000000000000..193ab1a9e9b2 --- /dev/null +++ b/internal/services/healthcare/sdk/2021-06-01-preview/dicomservices/version.go @@ -0,0 +1,9 @@ +package dicomservices + +import "fmt" + +const defaultApiVersion = "2021-06-01-preview" + +func userAgent() string { + return fmt.Sprintf("pandora/dicomservices/%s", defaultApiVersion) +} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/client.go b/internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/client.go new file mode 100644 index 000000000000..da61d03b51b7 --- /dev/null +++ b/internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/client.go @@ -0,0 +1,15 @@ +package fhirservices + +import "github.com/Azure/go-autorest/autorest" + +type FhirServicesClient struct { + Client autorest.Client + baseUri string +} + +func NewFhirServicesClientWithBaseURI(endpoint string) FhirServicesClient { + return FhirServicesClient{ + Client: autorest.NewClientWithUserAgent(userAgent()), + baseUri: endpoint, + } +} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/constants.go b/internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/constants.go new file mode 100644 index 000000000000..21039bcfe1c1 --- /dev/null +++ b/internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/constants.go @@ -0,0 +1,154 @@ +package fhirservices + +import "strings" + +type CreatedByType string + +const ( + CreatedByTypeApplication CreatedByType = "Application" + CreatedByTypeKey CreatedByType = "Key" + CreatedByTypeManagedIdentity CreatedByType = "ManagedIdentity" + CreatedByTypeUser CreatedByType = "User" +) + +func PossibleValuesForCreatedByType() []string { + return []string{ + string(CreatedByTypeApplication), + string(CreatedByTypeKey), + string(CreatedByTypeManagedIdentity), + string(CreatedByTypeUser), + } +} + +func parseCreatedByType(input string) (*CreatedByType, error) { + vals := map[string]CreatedByType{ + "application": CreatedByTypeApplication, + "key": CreatedByTypeKey, + "managedidentity": CreatedByTypeManagedIdentity, + "user": CreatedByTypeUser, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := CreatedByType(input) + return &out, nil +} + +type FhirServiceKind string + +const ( + FhirServiceKindFhirNegativeRFour FhirServiceKind = "fhir-R4" + FhirServiceKindFhirNegativeStuThree FhirServiceKind = "fhir-Stu3" +) + +func PossibleValuesForFhirServiceKind() []string { + return []string{ + string(FhirServiceKindFhirNegativeRFour), + string(FhirServiceKindFhirNegativeStuThree), + } +} + +func parseFhirServiceKind(input string) (*FhirServiceKind, error) { + vals := map[string]FhirServiceKind{ + "fhir-r4": FhirServiceKindFhirNegativeRFour, + "fhir-stu3": FhirServiceKindFhirNegativeStuThree, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := FhirServiceKind(input) + return &out, nil +} + +type ManagedServiceIdentityType string + +const ( + ManagedServiceIdentityTypeNone ManagedServiceIdentityType = "None" + ManagedServiceIdentityTypeSystemAssigned ManagedServiceIdentityType = "SystemAssigned" +) + +func PossibleValuesForManagedServiceIdentityType() []string { + return []string{ + string(ManagedServiceIdentityTypeNone), + string(ManagedServiceIdentityTypeSystemAssigned), + } +} + +func parseManagedServiceIdentityType(input string) (*ManagedServiceIdentityType, error) { + vals := map[string]ManagedServiceIdentityType{ + "none": ManagedServiceIdentityTypeNone, + "systemassigned": ManagedServiceIdentityTypeSystemAssigned, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ManagedServiceIdentityType(input) + return &out, nil +} + +type ProvisioningState string + +const ( + ProvisioningStateAccepted ProvisioningState = "Accepted" + ProvisioningStateCanceled ProvisioningState = "Canceled" + ProvisioningStateCreating ProvisioningState = "Creating" + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateDeprovisioned ProvisioningState = "Deprovisioned" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateMoving ProvisioningState = "Moving" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + ProvisioningStateSuspended ProvisioningState = "Suspended" + ProvisioningStateSystemMaintenance ProvisioningState = "SystemMaintenance" + ProvisioningStateUpdating ProvisioningState = "Updating" + ProvisioningStateVerifying ProvisioningState = "Verifying" + ProvisioningStateWarned ProvisioningState = "Warned" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateAccepted), + string(ProvisioningStateCanceled), + string(ProvisioningStateCreating), + string(ProvisioningStateDeleting), + string(ProvisioningStateDeprovisioned), + string(ProvisioningStateFailed), + string(ProvisioningStateMoving), + string(ProvisioningStateSucceeded), + string(ProvisioningStateSuspended), + string(ProvisioningStateSystemMaintenance), + string(ProvisioningStateUpdating), + string(ProvisioningStateVerifying), + string(ProvisioningStateWarned), + } +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "accepted": ProvisioningStateAccepted, + "canceled": ProvisioningStateCanceled, + "creating": ProvisioningStateCreating, + "deleting": ProvisioningStateDeleting, + "deprovisioned": ProvisioningStateDeprovisioned, + "failed": ProvisioningStateFailed, + "moving": ProvisioningStateMoving, + "succeeded": ProvisioningStateSucceeded, + "suspended": ProvisioningStateSuspended, + "systemmaintenance": ProvisioningStateSystemMaintenance, + "updating": ProvisioningStateUpdating, + "verifying": ProvisioningStateVerifying, + "warned": ProvisioningStateWarned, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/id_fhirservice.go b/internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/id_fhirservice.go new file mode 100644 index 000000000000..e7cb11987bac --- /dev/null +++ b/internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/id_fhirservice.go @@ -0,0 +1,137 @@ +package fhirservices + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +var _ resourceids.ResourceId = FhirServiceId{} + +// FhirServiceId is a struct representing the Resource ID for a Fhir Service +type FhirServiceId struct { + SubscriptionId string + ResourceGroupName string + WorkspaceName string + FhirServiceName string +} + +// NewFhirServiceID returns a new FhirServiceId struct +func NewFhirServiceID(subscriptionId string, resourceGroupName string, workspaceName string, fhirServiceName string) FhirServiceId { + return FhirServiceId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + WorkspaceName: workspaceName, + FhirServiceName: fhirServiceName, + } +} + +// ParseFhirServiceID parses 'input' into a FhirServiceId +func ParseFhirServiceID(input string) (*FhirServiceId, error) { + parser := resourceids.NewParserFromResourceIdType(FhirServiceId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := FhirServiceId{} + + if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { + return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) + } + + if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { + return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) + } + + if id.WorkspaceName, ok = parsed.Parsed["workspaceName"]; !ok { + return nil, fmt.Errorf("the segment 'workspaceName' was not found in the resource id %q", input) + } + + if id.FhirServiceName, ok = parsed.Parsed["fhirServiceName"]; !ok { + return nil, fmt.Errorf("the segment 'fhirServiceName' was not found in the resource id %q", input) + } + + return &id, nil +} + +// ParseFhirServiceIDInsensitively parses 'input' case-insensitively into a FhirServiceId +// note: this method should only be used for API response data and not user input +func ParseFhirServiceIDInsensitively(input string) (*FhirServiceId, error) { + parser := resourceids.NewParserFromResourceIdType(FhirServiceId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := FhirServiceId{} + + if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { + return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) + } + + if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { + return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) + } + + if id.WorkspaceName, ok = parsed.Parsed["workspaceName"]; !ok { + return nil, fmt.Errorf("the segment 'workspaceName' was not found in the resource id %q", input) + } + + if id.FhirServiceName, ok = parsed.Parsed["fhirServiceName"]; !ok { + return nil, fmt.Errorf("the segment 'fhirServiceName' was not found in the resource id %q", input) + } + + return &id, nil +} + +// ValidateFhirServiceID checks that 'input' can be parsed as a Fhir Service ID +func ValidateFhirServiceID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseFhirServiceID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Fhir Service ID +func (id FhirServiceId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.HealthcareApis/workspaces/%s/fhirServices/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.WorkspaceName, id.FhirServiceName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Fhir Service ID +func (id FhirServiceId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftHealthcareApis", "Microsoft.HealthcareApis", "Microsoft.HealthcareApis"), + resourceids.StaticSegment("staticWorkspaces", "workspaces", "workspaces"), + resourceids.UserSpecifiedSegment("workspaceName", "workspaceValue"), + resourceids.StaticSegment("staticFhirServices", "fhirServices", "fhirServices"), + resourceids.UserSpecifiedSegment("fhirServiceName", "fhirServiceValue"), + } +} + +// String returns a human-readable description of this Fhir Service ID +func (id FhirServiceId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Workspace Name: %q", id.WorkspaceName), + fmt.Sprintf("Fhir Service Name: %q", id.FhirServiceName), + } + return fmt.Sprintf("Fhir Service (%s)", strings.Join(components, "\n")) +} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/id_fhirservice_test.go b/internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/id_fhirservice_test.go new file mode 100644 index 000000000000..26537436e30b --- /dev/null +++ b/internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/id_fhirservice_test.go @@ -0,0 +1,324 @@ +package fhirservices + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +var _ resourceids.ResourceId = FhirServiceId{} + +func TestNewFhirServiceID(t *testing.T) { + id := NewFhirServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceValue", "fhirServiceValue") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.WorkspaceName != "workspaceValue" { + t.Fatalf("Expected %q but got %q for Segment 'WorkspaceName'", id.WorkspaceName, "workspaceValue") + } + + if id.FhirServiceName != "fhirServiceValue" { + t.Fatalf("Expected %q but got %q for Segment 'FhirServiceName'", id.FhirServiceName, "fhirServiceValue") + } +} + +func TestFormatFhirServiceID(t *testing.T) { + actual := NewFhirServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceValue", "fhirServiceValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/workspaces/workspaceValue/fhirServices/fhirServiceValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseFhirServiceID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *FhirServiceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/workspaces", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/workspaces/workspaceValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/workspaces/workspaceValue/fhirServices", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/workspaces/workspaceValue/fhirServices/fhirServiceValue", + Expected: &FhirServiceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceValue", + FhirServiceName: "fhirServiceValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/workspaces/workspaceValue/fhirServices/fhirServiceValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseFhirServiceID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + if actual.FhirServiceName != v.Expected.FhirServiceName { + t.Fatalf("Expected %q but got %q for FhirServiceName", v.Expected.FhirServiceName, actual.FhirServiceName) + } + + } +} + +func TestParseFhirServiceIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *FhirServiceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hEaLtHcArEaPiS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/workspaces", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hEaLtHcArEaPiS/wOrKsPaCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/workspaces/workspaceValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hEaLtHcArEaPiS/wOrKsPaCeS/wOrKsPaCeVaLuE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/workspaces/workspaceValue/fhirServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hEaLtHcArEaPiS/wOrKsPaCeS/wOrKsPaCeVaLuE/fHiRsErViCeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/workspaces/workspaceValue/fhirServices/fhirServiceValue", + Expected: &FhirServiceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceValue", + FhirServiceName: "fhirServiceValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/workspaces/workspaceValue/fhirServices/fhirServiceValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hEaLtHcArEaPiS/wOrKsPaCeS/wOrKsPaCeVaLuE/fHiRsErViCeS/fHiRsErViCeVaLuE", + Expected: &FhirServiceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + WorkspaceName: "wOrKsPaCeVaLuE", + FhirServiceName: "fHiRsErViCeVaLuE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hEaLtHcArEaPiS/wOrKsPaCeS/wOrKsPaCeVaLuE/fHiRsErViCeS/fHiRsErViCeVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseFhirServiceIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + if actual.FhirServiceName != v.Expected.FhirServiceName { + t.Fatalf("Expected %q but got %q for FhirServiceName", v.Expected.FhirServiceName, actual.FhirServiceName) + } + + } +} + +func TestSegmentsForFhirServiceId(t *testing.T) { + segments := FhirServiceId{}.Segments() + if len(segments) == 0 { + t.Fatalf("FhirServiceId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/id_workspace.go b/internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/id_workspace.go new file mode 100644 index 000000000000..8abd7a760f49 --- /dev/null +++ b/internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/id_workspace.go @@ -0,0 +1,124 @@ +package fhirservices + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +var _ resourceids.ResourceId = WorkspaceId{} + +// WorkspaceId is a struct representing the Resource ID for a Workspace +type WorkspaceId struct { + SubscriptionId string + ResourceGroupName string + WorkspaceName string +} + +// NewWorkspaceID returns a new WorkspaceId struct +func NewWorkspaceID(subscriptionId string, resourceGroupName string, workspaceName string) WorkspaceId { + return WorkspaceId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + WorkspaceName: workspaceName, + } +} + +// ParseWorkspaceID parses 'input' into a WorkspaceId +func ParseWorkspaceID(input string) (*WorkspaceId, error) { + parser := resourceids.NewParserFromResourceIdType(WorkspaceId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := WorkspaceId{} + + if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { + return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) + } + + if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { + return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) + } + + if id.WorkspaceName, ok = parsed.Parsed["workspaceName"]; !ok { + return nil, fmt.Errorf("the segment 'workspaceName' was not found in the resource id %q", input) + } + + return &id, nil +} + +// ParseWorkspaceIDInsensitively parses 'input' case-insensitively into a WorkspaceId +// note: this method should only be used for API response data and not user input +func ParseWorkspaceIDInsensitively(input string) (*WorkspaceId, error) { + parser := resourceids.NewParserFromResourceIdType(WorkspaceId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := WorkspaceId{} + + if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { + return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) + } + + if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { + return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) + } + + if id.WorkspaceName, ok = parsed.Parsed["workspaceName"]; !ok { + return nil, fmt.Errorf("the segment 'workspaceName' was not found in the resource id %q", input) + } + + return &id, nil +} + +// ValidateWorkspaceID checks that 'input' can be parsed as a Workspace ID +func ValidateWorkspaceID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseWorkspaceID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Workspace ID +func (id WorkspaceId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.HealthcareApis/workspaces/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.WorkspaceName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Workspace ID +func (id WorkspaceId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftHealthcareApis", "Microsoft.HealthcareApis", "Microsoft.HealthcareApis"), + resourceids.StaticSegment("staticWorkspaces", "workspaces", "workspaces"), + resourceids.UserSpecifiedSegment("workspaceName", "workspaceValue"), + } +} + +// String returns a human-readable description of this Workspace ID +func (id WorkspaceId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Workspace Name: %q", id.WorkspaceName), + } + return fmt.Sprintf("Workspace (%s)", strings.Join(components, "\n")) +} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/id_workspace_test.go b/internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/id_workspace_test.go new file mode 100644 index 000000000000..5aa31df8f9e6 --- /dev/null +++ b/internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/id_workspace_test.go @@ -0,0 +1,279 @@ +package fhirservices + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +var _ resourceids.ResourceId = WorkspaceId{} + +func TestNewWorkspaceID(t *testing.T) { + id := NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceValue") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.WorkspaceName != "workspaceValue" { + t.Fatalf("Expected %q but got %q for Segment 'WorkspaceName'", id.WorkspaceName, "workspaceValue") + } +} + +func TestFormatWorkspaceID(t *testing.T) { + actual := NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/workspaces/workspaceValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseWorkspaceID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *WorkspaceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/workspaces", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/workspaces/workspaceValue", + Expected: &WorkspaceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/workspaces/workspaceValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseWorkspaceID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + } +} + +func TestParseWorkspaceIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *WorkspaceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hEaLtHcArEaPiS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/workspaces", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hEaLtHcArEaPiS/wOrKsPaCeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/workspaces/workspaceValue", + Expected: &WorkspaceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/workspaces/workspaceValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hEaLtHcArEaPiS/wOrKsPaCeS/wOrKsPaCeVaLuE", + Expected: &WorkspaceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + WorkspaceName: "wOrKsPaCeVaLuE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hEaLtHcArEaPiS/wOrKsPaCeS/wOrKsPaCeVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseWorkspaceIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + } +} + +func TestSegmentsForWorkspaceId(t *testing.T) { + segments := WorkspaceId{}.Segments() + if len(segments) == 0 { + t.Fatalf("WorkspaceId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/method_createorupdate_autorest.go b/internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/method_createorupdate_autorest.go new file mode 100644 index 000000000000..b2535d43d8a7 --- /dev/null +++ b/internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/method_createorupdate_autorest.go @@ -0,0 +1,75 @@ +package fhirservices + +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" +) + +type CreateOrUpdateResponse struct { + Poller polling.LongRunningPoller + HttpResponse *http.Response +} + +// CreateOrUpdate ... +func (c FhirServicesClient) CreateOrUpdate(ctx context.Context, id FhirServiceId, input FhirService) (result CreateOrUpdateResponse, err error) { + req, err := c.preparerForCreateOrUpdate(ctx, id, input) + if err != nil { + err = autorest.NewErrorWithError(err, "fhirservices.FhirServicesClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = c.senderForCreateOrUpdate(ctx, req) + if err != nil { + err = autorest.NewErrorWithError(err, "fhirservices.FhirServicesClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") + return + } + + return +} + +// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed +func (c FhirServicesClient) CreateOrUpdateThenPoll(ctx context.Context, id FhirServiceId, input FhirService) 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 FhirServicesClient) preparerForCreateOrUpdate(ctx context.Context, id FhirServiceId, input FhirService) (*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 FhirServicesClient) senderForCreateOrUpdate(ctx context.Context, req *http.Request) (future CreateOrUpdateResponse, err error) { + var resp *http.Response + resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + return + } + future.Poller, err = polling.NewLongRunningPollerFromResponse(ctx, resp, c.Client) + return +} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/method_delete_autorest.go b/internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/method_delete_autorest.go new file mode 100644 index 000000000000..f8361563ff15 --- /dev/null +++ b/internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/method_delete_autorest.go @@ -0,0 +1,74 @@ +package fhirservices + +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" +) + +type DeleteResponse struct { + Poller polling.LongRunningPoller + HttpResponse *http.Response +} + +// Delete ... +func (c FhirServicesClient) Delete(ctx context.Context, id FhirServiceId) (result DeleteResponse, err error) { + req, err := c.preparerForDelete(ctx, id) + if err != nil { + err = autorest.NewErrorWithError(err, "fhirservices.FhirServicesClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = c.senderForDelete(ctx, req) + if err != nil { + err = autorest.NewErrorWithError(err, "fhirservices.FhirServicesClient", "Delete", result.HttpResponse, "Failure sending request") + return + } + + return +} + +// DeleteThenPoll performs Delete then polls until it's completed +func (c FhirServicesClient) DeleteThenPoll(ctx context.Context, id FhirServiceId) 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 FhirServicesClient) preparerForDelete(ctx context.Context, id FhirServiceId) (*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 FhirServicesClient) senderForDelete(ctx context.Context, req *http.Request) (future DeleteResponse, err error) { + var resp *http.Response + resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + return + } + future.Poller, err = polling.NewLongRunningPollerFromResponse(ctx, resp, c.Client) + return +} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/method_get_autorest.go b/internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/method_get_autorest.go new file mode 100644 index 000000000000..3c89a465f94f --- /dev/null +++ b/internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/method_get_autorest.go @@ -0,0 +1,64 @@ +package fhirservices + +import ( + "context" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +type GetResponse struct { + HttpResponse *http.Response + Model *FhirService +} + +// Get ... +func (c FhirServicesClient) Get(ctx context.Context, id FhirServiceId) (result GetResponse, err error) { + req, err := c.preparerForGet(ctx, id) + if err != nil { + err = autorest.NewErrorWithError(err, "fhirservices.FhirServicesClient", "Get", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "fhirservices.FhirServicesClient", "Get", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForGet(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "fhirservices.FhirServicesClient", "Get", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForGet prepares the Get request. +func (c FhirServicesClient) preparerForGet(ctx context.Context, id FhirServiceId) (*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 FhirServicesClient) responderForGet(resp *http.Response) (result GetResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Model), + autorest.ByClosing()) + result.HttpResponse = resp + return +} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/method_listbyworkspace_autorest.go b/internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/method_listbyworkspace_autorest.go new file mode 100644 index 000000000000..a30fb5ef5129 --- /dev/null +++ b/internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/method_listbyworkspace_autorest.go @@ -0,0 +1,183 @@ +package fhirservices + +import ( + "context" + "fmt" + "net/http" + "net/url" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +type ListByWorkspaceResponse struct { + HttpResponse *http.Response + Model *[]FhirService + + nextLink *string + nextPageFunc func(ctx context.Context, nextLink string) (ListByWorkspaceResponse, error) +} + +type ListByWorkspaceCompleteResult struct { + Items []FhirService +} + +func (r ListByWorkspaceResponse) HasMore() bool { + return r.nextLink != nil +} + +func (r ListByWorkspaceResponse) LoadMore(ctx context.Context) (resp ListByWorkspaceResponse, err error) { + if !r.HasMore() { + err = fmt.Errorf("no more pages returned") + return + } + return r.nextPageFunc(ctx, *r.nextLink) +} + +// ListByWorkspace ... +func (c FhirServicesClient) ListByWorkspace(ctx context.Context, id WorkspaceId) (resp ListByWorkspaceResponse, err error) { + req, err := c.preparerForListByWorkspace(ctx, id) + if err != nil { + err = autorest.NewErrorWithError(err, "fhirservices.FhirServicesClient", "ListByWorkspace", nil, "Failure preparing request") + return + } + + resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "fhirservices.FhirServicesClient", "ListByWorkspace", resp.HttpResponse, "Failure sending request") + return + } + + resp, err = c.responderForListByWorkspace(resp.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "fhirservices.FhirServicesClient", "ListByWorkspace", resp.HttpResponse, "Failure responding to request") + return + } + return +} + +// ListByWorkspaceComplete retrieves all of the results into a single object +func (c FhirServicesClient) ListByWorkspaceComplete(ctx context.Context, id WorkspaceId) (ListByWorkspaceCompleteResult, error) { + return c.ListByWorkspaceCompleteMatchingPredicate(ctx, id, FhirServicePredicate{}) +} + +// ListByWorkspaceCompleteMatchingPredicate retrieves all of the results and then applied the predicate +func (c FhirServicesClient) ListByWorkspaceCompleteMatchingPredicate(ctx context.Context, id WorkspaceId, predicate FhirServicePredicate) (resp ListByWorkspaceCompleteResult, err error) { + items := make([]FhirService, 0) + + page, err := c.ListByWorkspace(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 := ListByWorkspaceCompleteResult{ + Items: items, + } + return out, nil +} + +// preparerForListByWorkspace prepares the ListByWorkspace request. +func (c FhirServicesClient) preparerForListByWorkspace(ctx context.Context, id WorkspaceId) (*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/fhirServices", id.ID())), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// preparerForListByWorkspaceWithNextLink prepares the ListByWorkspace request with the given nextLink token. +func (c FhirServicesClient) preparerForListByWorkspaceWithNextLink(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)) +} + +// responderForListByWorkspace handles the response to the ListByWorkspace request. The method always +// closes the http.Response Body. +func (c FhirServicesClient) responderForListByWorkspace(resp *http.Response) (result ListByWorkspaceResponse, err error) { + type page struct { + Values []FhirService `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 ListByWorkspaceResponse, err error) { + req, err := c.preparerForListByWorkspaceWithNextLink(ctx, nextLink) + if err != nil { + err = autorest.NewErrorWithError(err, "fhirservices.FhirServicesClient", "ListByWorkspace", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "fhirservices.FhirServicesClient", "ListByWorkspace", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForListByWorkspace(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "fhirservices.FhirServicesClient", "ListByWorkspace", result.HttpResponse, "Failure responding to request") + return + } + + return + } + } + return +} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/method_update_autorest.go b/internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/method_update_autorest.go new file mode 100644 index 000000000000..3a286b326764 --- /dev/null +++ b/internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/method_update_autorest.go @@ -0,0 +1,75 @@ +package fhirservices + +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" +) + +type UpdateResponse struct { + Poller polling.LongRunningPoller + HttpResponse *http.Response +} + +// Update ... +func (c FhirServicesClient) Update(ctx context.Context, id FhirServiceId, input FhirServicePatchResource) (result UpdateResponse, err error) { + req, err := c.preparerForUpdate(ctx, id, input) + if err != nil { + err = autorest.NewErrorWithError(err, "fhirservices.FhirServicesClient", "Update", nil, "Failure preparing request") + return + } + + result, err = c.senderForUpdate(ctx, req) + if err != nil { + err = autorest.NewErrorWithError(err, "fhirservices.FhirServicesClient", "Update", result.HttpResponse, "Failure sending request") + return + } + + return +} + +// UpdateThenPoll performs Update then polls until it's completed +func (c FhirServicesClient) UpdateThenPoll(ctx context.Context, id FhirServiceId, input FhirServicePatchResource) 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 FhirServicesClient) preparerForUpdate(ctx context.Context, id FhirServiceId, input FhirServicePatchResource) (*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 FhirServicesClient) senderForUpdate(ctx context.Context, req *http.Request) (future UpdateResponse, err error) { + var resp *http.Response + resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + return + } + future.Poller, err = polling.NewLongRunningPollerFromResponse(ctx, resp, c.Client) + return +} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/model_fhirservice.go b/internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/model_fhirservice.go new file mode 100644 index 000000000000..a1e36a7b64f9 --- /dev/null +++ b/internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/model_fhirservice.go @@ -0,0 +1,14 @@ +package fhirservices + +type FhirService struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Identity *ServiceManagedIdentityIdentity `json:"identity,omitempty"` + Kind *FhirServiceKind `json:"kind,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *FhirServiceProperties `json:"properties,omitempty"` + SystemData *SystemData `json:"systemData,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/model_fhirserviceaccesspolicyentry.go b/internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/model_fhirserviceaccesspolicyentry.go new file mode 100644 index 000000000000..31a9e85ea171 --- /dev/null +++ b/internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/model_fhirserviceaccesspolicyentry.go @@ -0,0 +1,5 @@ +package fhirservices + +type FhirServiceAccessPolicyEntry struct { + ObjectId string `json:"objectId"` +} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/model_fhirserviceacrconfiguration.go b/internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/model_fhirserviceacrconfiguration.go new file mode 100644 index 000000000000..f733e51101d1 --- /dev/null +++ b/internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/model_fhirserviceacrconfiguration.go @@ -0,0 +1,5 @@ +package fhirservices + +type FhirServiceAcrConfiguration struct { + LoginServers *[]string `json:"loginServers,omitempty"` +} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/model_fhirserviceauthenticationconfiguration.go b/internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/model_fhirserviceauthenticationconfiguration.go new file mode 100644 index 000000000000..6d25b36de86f --- /dev/null +++ b/internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/model_fhirserviceauthenticationconfiguration.go @@ -0,0 +1,7 @@ +package fhirservices + +type FhirServiceAuthenticationConfiguration struct { + Audience *string `json:"audience,omitempty"` + Authority *string `json:"authority,omitempty"` + SmartProxyEnabled *bool `json:"smartProxyEnabled,omitempty"` +} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/model_fhirservicecorsconfiguration.go b/internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/model_fhirservicecorsconfiguration.go new file mode 100644 index 000000000000..9ec0330a3947 --- /dev/null +++ b/internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/model_fhirservicecorsconfiguration.go @@ -0,0 +1,9 @@ +package fhirservices + +type FhirServiceCorsConfiguration struct { + AllowCredentials *bool `json:"allowCredentials,omitempty"` + Headers *[]string `json:"headers,omitempty"` + MaxAge *int64 `json:"maxAge,omitempty"` + Methods *[]string `json:"methods,omitempty"` + Origins *[]string `json:"origins,omitempty"` +} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/model_fhirserviceexportconfiguration.go b/internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/model_fhirserviceexportconfiguration.go new file mode 100644 index 000000000000..0eaf3c1e2007 --- /dev/null +++ b/internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/model_fhirserviceexportconfiguration.go @@ -0,0 +1,5 @@ +package fhirservices + +type FhirServiceExportConfiguration struct { + StorageAccountName *string `json:"storageAccountName,omitempty"` +} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/model_fhirservicepatchresource.go b/internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/model_fhirservicepatchresource.go new file mode 100644 index 000000000000..652c5a21ce35 --- /dev/null +++ b/internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/model_fhirservicepatchresource.go @@ -0,0 +1,6 @@ +package fhirservices + +type FhirServicePatchResource struct { + Identity *ServiceManagedIdentityIdentity `json:"identity,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/model_fhirserviceproperties.go b/internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/model_fhirserviceproperties.go new file mode 100644 index 000000000000..6d773381b0af --- /dev/null +++ b/internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/model_fhirserviceproperties.go @@ -0,0 +1,10 @@ +package fhirservices + +type FhirServiceProperties struct { + AccessPolicies *[]FhirServiceAccessPolicyEntry `json:"accessPolicies,omitempty"` + AcrConfiguration *FhirServiceAcrConfiguration `json:"acrConfiguration,omitempty"` + AuthenticationConfiguration *FhirServiceAuthenticationConfiguration `json:"authenticationConfiguration,omitempty"` + CorsConfiguration *FhirServiceCorsConfiguration `json:"corsConfiguration,omitempty"` + ExportConfiguration *FhirServiceExportConfiguration `json:"exportConfiguration,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/model_servicemanagedidentityidentity.go b/internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/model_servicemanagedidentityidentity.go new file mode 100644 index 000000000000..b15f4aff7956 --- /dev/null +++ b/internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/model_servicemanagedidentityidentity.go @@ -0,0 +1,5 @@ +package fhirservices + +type ServiceManagedIdentityIdentity struct { + Type *ManagedServiceIdentityType `json:"type,omitempty"` +} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/model_systemdata.go b/internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/model_systemdata.go new file mode 100644 index 000000000000..2454158fc621 --- /dev/null +++ b/internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/model_systemdata.go @@ -0,0 +1,40 @@ +package fhirservices + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +type SystemData struct { + CreatedAt *string `json:"createdAt,omitempty"` + CreatedBy *string `json:"createdBy,omitempty"` + CreatedByType *CreatedByType `json:"createdByType,omitempty"` + LastModifiedAt *string `json:"lastModifiedAt,omitempty"` + LastModifiedBy *string `json:"lastModifiedBy,omitempty"` + LastModifiedByType *CreatedByType `json:"lastModifiedByType,omitempty"` +} + +func (o SystemData) GetCreatedAtAsTime() (*time.Time, error) { + if o.CreatedAt == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreatedAt, "2006-01-02T15:04:05Z07:00") +} + +func (o SystemData) SetCreatedAtAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreatedAt = &formatted +} + +func (o SystemData) GetLastModifiedAtAsTime() (*time.Time, error) { + if o.LastModifiedAt == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastModifiedAt, "2006-01-02T15:04:05Z07:00") +} + +func (o SystemData) SetLastModifiedAtAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastModifiedAt = &formatted +} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/predicates.go b/internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/predicates.go new file mode 100644 index 000000000000..c64d1a5adfa0 --- /dev/null +++ b/internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/predicates.go @@ -0,0 +1,34 @@ +package fhirservices + +type FhirServicePredicate struct { + Etag *string + Id *string + Location *string + Name *string + Type *string +} + +func (p FhirServicePredicate) Matches(input FhirService) bool { + + if p.Etag != nil && (input.Etag == nil && *p.Etag != *input.Etag) { + return false + } + + if p.Id != nil && (input.Id == nil && *p.Id != *input.Id) { + return false + } + + if p.Location != nil && (input.Location == nil && *p.Location != *input.Location) { + return false + } + + if p.Name != nil && (input.Name == nil && *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil && *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/version.go b/internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/version.go new file mode 100644 index 000000000000..f2ca1c55d66e --- /dev/null +++ b/internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/version.go @@ -0,0 +1,9 @@ +package fhirservices + +import "fmt" + +const defaultApiVersion = "2021-06-01-preview" + +func userAgent() string { + return fmt.Sprintf("pandora/fhirservices/%s", defaultApiVersion) +} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/client.go b/internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/client.go new file mode 100644 index 000000000000..e47505b51f6b --- /dev/null +++ b/internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/client.go @@ -0,0 +1,15 @@ +package iotconnectors + +import "github.com/Azure/go-autorest/autorest" + +type IotConnectorsClient struct { + Client autorest.Client + baseUri string +} + +func NewIotConnectorsClientWithBaseURI(endpoint string) IotConnectorsClient { + return IotConnectorsClient{ + Client: autorest.NewClientWithUserAgent(userAgent()), + baseUri: endpoint, + } +} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/constants.go b/internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/constants.go new file mode 100644 index 000000000000..2c82c5ad9189 --- /dev/null +++ b/internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/constants.go @@ -0,0 +1,154 @@ +package iotconnectors + +import "strings" + +type CreatedByType string + +const ( + CreatedByTypeApplication CreatedByType = "Application" + CreatedByTypeKey CreatedByType = "Key" + CreatedByTypeManagedIdentity CreatedByType = "ManagedIdentity" + CreatedByTypeUser CreatedByType = "User" +) + +func PossibleValuesForCreatedByType() []string { + return []string{ + string(CreatedByTypeApplication), + string(CreatedByTypeKey), + string(CreatedByTypeManagedIdentity), + string(CreatedByTypeUser), + } +} + +func parseCreatedByType(input string) (*CreatedByType, error) { + vals := map[string]CreatedByType{ + "application": CreatedByTypeApplication, + "key": CreatedByTypeKey, + "managedidentity": CreatedByTypeManagedIdentity, + "user": CreatedByTypeUser, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := CreatedByType(input) + return &out, nil +} + +type IotIdentityResolutionType string + +const ( + IotIdentityResolutionTypeCreate IotIdentityResolutionType = "Create" + IotIdentityResolutionTypeLookup IotIdentityResolutionType = "Lookup" +) + +func PossibleValuesForIotIdentityResolutionType() []string { + return []string{ + string(IotIdentityResolutionTypeCreate), + string(IotIdentityResolutionTypeLookup), + } +} + +func parseIotIdentityResolutionType(input string) (*IotIdentityResolutionType, error) { + vals := map[string]IotIdentityResolutionType{ + "create": IotIdentityResolutionTypeCreate, + "lookup": IotIdentityResolutionTypeLookup, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := IotIdentityResolutionType(input) + return &out, nil +} + +type ManagedServiceIdentityType string + +const ( + ManagedServiceIdentityTypeNone ManagedServiceIdentityType = "None" + ManagedServiceIdentityTypeSystemAssigned ManagedServiceIdentityType = "SystemAssigned" +) + +func PossibleValuesForManagedServiceIdentityType() []string { + return []string{ + string(ManagedServiceIdentityTypeNone), + string(ManagedServiceIdentityTypeSystemAssigned), + } +} + +func parseManagedServiceIdentityType(input string) (*ManagedServiceIdentityType, error) { + vals := map[string]ManagedServiceIdentityType{ + "none": ManagedServiceIdentityTypeNone, + "systemassigned": ManagedServiceIdentityTypeSystemAssigned, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ManagedServiceIdentityType(input) + return &out, nil +} + +type ProvisioningState string + +const ( + ProvisioningStateAccepted ProvisioningState = "Accepted" + ProvisioningStateCanceled ProvisioningState = "Canceled" + ProvisioningStateCreating ProvisioningState = "Creating" + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateDeprovisioned ProvisioningState = "Deprovisioned" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateMoving ProvisioningState = "Moving" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + ProvisioningStateSuspended ProvisioningState = "Suspended" + ProvisioningStateSystemMaintenance ProvisioningState = "SystemMaintenance" + ProvisioningStateUpdating ProvisioningState = "Updating" + ProvisioningStateVerifying ProvisioningState = "Verifying" + ProvisioningStateWarned ProvisioningState = "Warned" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateAccepted), + string(ProvisioningStateCanceled), + string(ProvisioningStateCreating), + string(ProvisioningStateDeleting), + string(ProvisioningStateDeprovisioned), + string(ProvisioningStateFailed), + string(ProvisioningStateMoving), + string(ProvisioningStateSucceeded), + string(ProvisioningStateSuspended), + string(ProvisioningStateSystemMaintenance), + string(ProvisioningStateUpdating), + string(ProvisioningStateVerifying), + string(ProvisioningStateWarned), + } +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "accepted": ProvisioningStateAccepted, + "canceled": ProvisioningStateCanceled, + "creating": ProvisioningStateCreating, + "deleting": ProvisioningStateDeleting, + "deprovisioned": ProvisioningStateDeprovisioned, + "failed": ProvisioningStateFailed, + "moving": ProvisioningStateMoving, + "succeeded": ProvisioningStateSucceeded, + "suspended": ProvisioningStateSuspended, + "systemmaintenance": ProvisioningStateSystemMaintenance, + "updating": ProvisioningStateUpdating, + "verifying": ProvisioningStateVerifying, + "warned": ProvisioningStateWarned, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/id_fhirdestination.go b/internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/id_fhirdestination.go new file mode 100644 index 000000000000..1c50fbf55c10 --- /dev/null +++ b/internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/id_fhirdestination.go @@ -0,0 +1,150 @@ +package iotconnectors + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +var _ resourceids.ResourceId = FhirDestinationId{} + +// FhirDestinationId is a struct representing the Resource ID for a Fhir Destination +type FhirDestinationId struct { + SubscriptionId string + ResourceGroupName string + WorkspaceName string + IotConnectorName string + FhirDestinationName string +} + +// NewFhirDestinationID returns a new FhirDestinationId struct +func NewFhirDestinationID(subscriptionId string, resourceGroupName string, workspaceName string, iotConnectorName string, fhirDestinationName string) FhirDestinationId { + return FhirDestinationId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + WorkspaceName: workspaceName, + IotConnectorName: iotConnectorName, + FhirDestinationName: fhirDestinationName, + } +} + +// ParseFhirDestinationID parses 'input' into a FhirDestinationId +func ParseFhirDestinationID(input string) (*FhirDestinationId, error) { + parser := resourceids.NewParserFromResourceIdType(FhirDestinationId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := FhirDestinationId{} + + if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { + return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) + } + + if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { + return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) + } + + if id.WorkspaceName, ok = parsed.Parsed["workspaceName"]; !ok { + return nil, fmt.Errorf("the segment 'workspaceName' was not found in the resource id %q", input) + } + + if id.IotConnectorName, ok = parsed.Parsed["iotConnectorName"]; !ok { + return nil, fmt.Errorf("the segment 'iotConnectorName' was not found in the resource id %q", input) + } + + if id.FhirDestinationName, ok = parsed.Parsed["fhirDestinationName"]; !ok { + return nil, fmt.Errorf("the segment 'fhirDestinationName' was not found in the resource id %q", input) + } + + return &id, nil +} + +// ParseFhirDestinationIDInsensitively parses 'input' case-insensitively into a FhirDestinationId +// note: this method should only be used for API response data and not user input +func ParseFhirDestinationIDInsensitively(input string) (*FhirDestinationId, error) { + parser := resourceids.NewParserFromResourceIdType(FhirDestinationId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := FhirDestinationId{} + + if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { + return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) + } + + if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { + return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) + } + + if id.WorkspaceName, ok = parsed.Parsed["workspaceName"]; !ok { + return nil, fmt.Errorf("the segment 'workspaceName' was not found in the resource id %q", input) + } + + if id.IotConnectorName, ok = parsed.Parsed["iotConnectorName"]; !ok { + return nil, fmt.Errorf("the segment 'iotConnectorName' was not found in the resource id %q", input) + } + + if id.FhirDestinationName, ok = parsed.Parsed["fhirDestinationName"]; !ok { + return nil, fmt.Errorf("the segment 'fhirDestinationName' was not found in the resource id %q", input) + } + + return &id, nil +} + +// ValidateFhirDestinationID checks that 'input' can be parsed as a Fhir Destination ID +func ValidateFhirDestinationID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseFhirDestinationID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Fhir Destination ID +func (id FhirDestinationId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.HealthcareApis/workspaces/%s/iotConnectors/%s/fhirDestinations/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.WorkspaceName, id.IotConnectorName, id.FhirDestinationName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Fhir Destination ID +func (id FhirDestinationId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftHealthcareApis", "Microsoft.HealthcareApis", "Microsoft.HealthcareApis"), + resourceids.StaticSegment("staticWorkspaces", "workspaces", "workspaces"), + resourceids.UserSpecifiedSegment("workspaceName", "workspaceValue"), + resourceids.StaticSegment("staticIotConnectors", "iotConnectors", "iotConnectors"), + resourceids.UserSpecifiedSegment("iotConnectorName", "iotConnectorValue"), + resourceids.StaticSegment("staticFhirDestinations", "fhirDestinations", "fhirDestinations"), + resourceids.UserSpecifiedSegment("fhirDestinationName", "fhirDestinationValue"), + } +} + +// String returns a human-readable description of this Fhir Destination ID +func (id FhirDestinationId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Workspace Name: %q", id.WorkspaceName), + fmt.Sprintf("Iot Connector Name: %q", id.IotConnectorName), + fmt.Sprintf("Fhir Destination Name: %q", id.FhirDestinationName), + } + return fmt.Sprintf("Fhir Destination (%s)", strings.Join(components, "\n")) +} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/id_fhirdestination_test.go b/internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/id_fhirdestination_test.go new file mode 100644 index 000000000000..04999190d678 --- /dev/null +++ b/internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/id_fhirdestination_test.go @@ -0,0 +1,369 @@ +package iotconnectors + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +var _ resourceids.ResourceId = FhirDestinationId{} + +func TestNewFhirDestinationID(t *testing.T) { + id := NewFhirDestinationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceValue", "iotConnectorValue", "fhirDestinationValue") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.WorkspaceName != "workspaceValue" { + t.Fatalf("Expected %q but got %q for Segment 'WorkspaceName'", id.WorkspaceName, "workspaceValue") + } + + if id.IotConnectorName != "iotConnectorValue" { + t.Fatalf("Expected %q but got %q for Segment 'IotConnectorName'", id.IotConnectorName, "iotConnectorValue") + } + + if id.FhirDestinationName != "fhirDestinationValue" { + t.Fatalf("Expected %q but got %q for Segment 'FhirDestinationName'", id.FhirDestinationName, "fhirDestinationValue") + } +} + +func TestFormatFhirDestinationID(t *testing.T) { + actual := NewFhirDestinationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceValue", "iotConnectorValue", "fhirDestinationValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/workspaces/workspaceValue/iotConnectors/iotConnectorValue/fhirDestinations/fhirDestinationValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseFhirDestinationID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *FhirDestinationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/workspaces", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/workspaces/workspaceValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/workspaces/workspaceValue/iotConnectors", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/workspaces/workspaceValue/iotConnectors/iotConnectorValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/workspaces/workspaceValue/iotConnectors/iotConnectorValue/fhirDestinations", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/workspaces/workspaceValue/iotConnectors/iotConnectorValue/fhirDestinations/fhirDestinationValue", + Expected: &FhirDestinationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceValue", + IotConnectorName: "iotConnectorValue", + FhirDestinationName: "fhirDestinationValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/workspaces/workspaceValue/iotConnectors/iotConnectorValue/fhirDestinations/fhirDestinationValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseFhirDestinationID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + if actual.IotConnectorName != v.Expected.IotConnectorName { + t.Fatalf("Expected %q but got %q for IotConnectorName", v.Expected.IotConnectorName, actual.IotConnectorName) + } + + if actual.FhirDestinationName != v.Expected.FhirDestinationName { + t.Fatalf("Expected %q but got %q for FhirDestinationName", v.Expected.FhirDestinationName, actual.FhirDestinationName) + } + + } +} + +func TestParseFhirDestinationIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *FhirDestinationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hEaLtHcArEaPiS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/workspaces", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hEaLtHcArEaPiS/wOrKsPaCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/workspaces/workspaceValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hEaLtHcArEaPiS/wOrKsPaCeS/wOrKsPaCeVaLuE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/workspaces/workspaceValue/iotConnectors", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hEaLtHcArEaPiS/wOrKsPaCeS/wOrKsPaCeVaLuE/iOtCoNnEcToRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/workspaces/workspaceValue/iotConnectors/iotConnectorValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hEaLtHcArEaPiS/wOrKsPaCeS/wOrKsPaCeVaLuE/iOtCoNnEcToRs/iOtCoNnEcToRvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/workspaces/workspaceValue/iotConnectors/iotConnectorValue/fhirDestinations", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hEaLtHcArEaPiS/wOrKsPaCeS/wOrKsPaCeVaLuE/iOtCoNnEcToRs/iOtCoNnEcToRvAlUe/fHiRdEsTiNaTiOnS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/workspaces/workspaceValue/iotConnectors/iotConnectorValue/fhirDestinations/fhirDestinationValue", + Expected: &FhirDestinationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceValue", + IotConnectorName: "iotConnectorValue", + FhirDestinationName: "fhirDestinationValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/workspaces/workspaceValue/iotConnectors/iotConnectorValue/fhirDestinations/fhirDestinationValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hEaLtHcArEaPiS/wOrKsPaCeS/wOrKsPaCeVaLuE/iOtCoNnEcToRs/iOtCoNnEcToRvAlUe/fHiRdEsTiNaTiOnS/fHiRdEsTiNaTiOnVaLuE", + Expected: &FhirDestinationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + WorkspaceName: "wOrKsPaCeVaLuE", + IotConnectorName: "iOtCoNnEcToRvAlUe", + FhirDestinationName: "fHiRdEsTiNaTiOnVaLuE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hEaLtHcArEaPiS/wOrKsPaCeS/wOrKsPaCeVaLuE/iOtCoNnEcToRs/iOtCoNnEcToRvAlUe/fHiRdEsTiNaTiOnS/fHiRdEsTiNaTiOnVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseFhirDestinationIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + if actual.IotConnectorName != v.Expected.IotConnectorName { + t.Fatalf("Expected %q but got %q for IotConnectorName", v.Expected.IotConnectorName, actual.IotConnectorName) + } + + if actual.FhirDestinationName != v.Expected.FhirDestinationName { + t.Fatalf("Expected %q but got %q for FhirDestinationName", v.Expected.FhirDestinationName, actual.FhirDestinationName) + } + + } +} + +func TestSegmentsForFhirDestinationId(t *testing.T) { + segments := FhirDestinationId{}.Segments() + if len(segments) == 0 { + t.Fatalf("FhirDestinationId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/id_iotconnector.go b/internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/id_iotconnector.go new file mode 100644 index 000000000000..7188ae3eac54 --- /dev/null +++ b/internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/id_iotconnector.go @@ -0,0 +1,137 @@ +package iotconnectors + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +var _ resourceids.ResourceId = IotConnectorId{} + +// IotConnectorId is a struct representing the Resource ID for a Iot Connector +type IotConnectorId struct { + SubscriptionId string + ResourceGroupName string + WorkspaceName string + IotConnectorName string +} + +// NewIotConnectorID returns a new IotConnectorId struct +func NewIotConnectorID(subscriptionId string, resourceGroupName string, workspaceName string, iotConnectorName string) IotConnectorId { + return IotConnectorId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + WorkspaceName: workspaceName, + IotConnectorName: iotConnectorName, + } +} + +// ParseIotConnectorID parses 'input' into a IotConnectorId +func ParseIotConnectorID(input string) (*IotConnectorId, error) { + parser := resourceids.NewParserFromResourceIdType(IotConnectorId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := IotConnectorId{} + + if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { + return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) + } + + if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { + return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) + } + + if id.WorkspaceName, ok = parsed.Parsed["workspaceName"]; !ok { + return nil, fmt.Errorf("the segment 'workspaceName' was not found in the resource id %q", input) + } + + if id.IotConnectorName, ok = parsed.Parsed["iotConnectorName"]; !ok { + return nil, fmt.Errorf("the segment 'iotConnectorName' was not found in the resource id %q", input) + } + + return &id, nil +} + +// ParseIotConnectorIDInsensitively parses 'input' case-insensitively into a IotConnectorId +// note: this method should only be used for API response data and not user input +func ParseIotConnectorIDInsensitively(input string) (*IotConnectorId, error) { + parser := resourceids.NewParserFromResourceIdType(IotConnectorId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := IotConnectorId{} + + if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { + return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) + } + + if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { + return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) + } + + if id.WorkspaceName, ok = parsed.Parsed["workspaceName"]; !ok { + return nil, fmt.Errorf("the segment 'workspaceName' was not found in the resource id %q", input) + } + + if id.IotConnectorName, ok = parsed.Parsed["iotConnectorName"]; !ok { + return nil, fmt.Errorf("the segment 'iotConnectorName' was not found in the resource id %q", input) + } + + return &id, nil +} + +// ValidateIotConnectorID checks that 'input' can be parsed as a Iot Connector ID +func ValidateIotConnectorID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseIotConnectorID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Iot Connector ID +func (id IotConnectorId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.HealthcareApis/workspaces/%s/iotConnectors/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.WorkspaceName, id.IotConnectorName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Iot Connector ID +func (id IotConnectorId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftHealthcareApis", "Microsoft.HealthcareApis", "Microsoft.HealthcareApis"), + resourceids.StaticSegment("staticWorkspaces", "workspaces", "workspaces"), + resourceids.UserSpecifiedSegment("workspaceName", "workspaceValue"), + resourceids.StaticSegment("staticIotConnectors", "iotConnectors", "iotConnectors"), + resourceids.UserSpecifiedSegment("iotConnectorName", "iotConnectorValue"), + } +} + +// String returns a human-readable description of this Iot Connector ID +func (id IotConnectorId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Workspace Name: %q", id.WorkspaceName), + fmt.Sprintf("Iot Connector Name: %q", id.IotConnectorName), + } + return fmt.Sprintf("Iot Connector (%s)", strings.Join(components, "\n")) +} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/id_iotconnector_test.go b/internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/id_iotconnector_test.go new file mode 100644 index 000000000000..c05aa57833bc --- /dev/null +++ b/internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/id_iotconnector_test.go @@ -0,0 +1,324 @@ +package iotconnectors + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +var _ resourceids.ResourceId = IotConnectorId{} + +func TestNewIotConnectorID(t *testing.T) { + id := NewIotConnectorID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceValue", "iotConnectorValue") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.WorkspaceName != "workspaceValue" { + t.Fatalf("Expected %q but got %q for Segment 'WorkspaceName'", id.WorkspaceName, "workspaceValue") + } + + if id.IotConnectorName != "iotConnectorValue" { + t.Fatalf("Expected %q but got %q for Segment 'IotConnectorName'", id.IotConnectorName, "iotConnectorValue") + } +} + +func TestFormatIotConnectorID(t *testing.T) { + actual := NewIotConnectorID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceValue", "iotConnectorValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/workspaces/workspaceValue/iotConnectors/iotConnectorValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseIotConnectorID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *IotConnectorId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/workspaces", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/workspaces/workspaceValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/workspaces/workspaceValue/iotConnectors", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/workspaces/workspaceValue/iotConnectors/iotConnectorValue", + Expected: &IotConnectorId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceValue", + IotConnectorName: "iotConnectorValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/workspaces/workspaceValue/iotConnectors/iotConnectorValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseIotConnectorID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + if actual.IotConnectorName != v.Expected.IotConnectorName { + t.Fatalf("Expected %q but got %q for IotConnectorName", v.Expected.IotConnectorName, actual.IotConnectorName) + } + + } +} + +func TestParseIotConnectorIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *IotConnectorId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hEaLtHcArEaPiS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/workspaces", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hEaLtHcArEaPiS/wOrKsPaCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/workspaces/workspaceValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hEaLtHcArEaPiS/wOrKsPaCeS/wOrKsPaCeVaLuE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/workspaces/workspaceValue/iotConnectors", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hEaLtHcArEaPiS/wOrKsPaCeS/wOrKsPaCeVaLuE/iOtCoNnEcToRs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/workspaces/workspaceValue/iotConnectors/iotConnectorValue", + Expected: &IotConnectorId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceValue", + IotConnectorName: "iotConnectorValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/workspaces/workspaceValue/iotConnectors/iotConnectorValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hEaLtHcArEaPiS/wOrKsPaCeS/wOrKsPaCeVaLuE/iOtCoNnEcToRs/iOtCoNnEcToRvAlUe", + Expected: &IotConnectorId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + WorkspaceName: "wOrKsPaCeVaLuE", + IotConnectorName: "iOtCoNnEcToRvAlUe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hEaLtHcArEaPiS/wOrKsPaCeS/wOrKsPaCeVaLuE/iOtCoNnEcToRs/iOtCoNnEcToRvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseIotConnectorIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + if actual.IotConnectorName != v.Expected.IotConnectorName { + t.Fatalf("Expected %q but got %q for IotConnectorName", v.Expected.IotConnectorName, actual.IotConnectorName) + } + + } +} + +func TestSegmentsForIotConnectorId(t *testing.T) { + segments := IotConnectorId{}.Segments() + if len(segments) == 0 { + t.Fatalf("IotConnectorId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/id_workspace.go b/internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/id_workspace.go new file mode 100644 index 000000000000..dc5ca4d7ed70 --- /dev/null +++ b/internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/id_workspace.go @@ -0,0 +1,124 @@ +package iotconnectors + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +var _ resourceids.ResourceId = WorkspaceId{} + +// WorkspaceId is a struct representing the Resource ID for a Workspace +type WorkspaceId struct { + SubscriptionId string + ResourceGroupName string + WorkspaceName string +} + +// NewWorkspaceID returns a new WorkspaceId struct +func NewWorkspaceID(subscriptionId string, resourceGroupName string, workspaceName string) WorkspaceId { + return WorkspaceId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + WorkspaceName: workspaceName, + } +} + +// ParseWorkspaceID parses 'input' into a WorkspaceId +func ParseWorkspaceID(input string) (*WorkspaceId, error) { + parser := resourceids.NewParserFromResourceIdType(WorkspaceId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := WorkspaceId{} + + if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { + return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) + } + + if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { + return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) + } + + if id.WorkspaceName, ok = parsed.Parsed["workspaceName"]; !ok { + return nil, fmt.Errorf("the segment 'workspaceName' was not found in the resource id %q", input) + } + + return &id, nil +} + +// ParseWorkspaceIDInsensitively parses 'input' case-insensitively into a WorkspaceId +// note: this method should only be used for API response data and not user input +func ParseWorkspaceIDInsensitively(input string) (*WorkspaceId, error) { + parser := resourceids.NewParserFromResourceIdType(WorkspaceId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := WorkspaceId{} + + if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { + return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) + } + + if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { + return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) + } + + if id.WorkspaceName, ok = parsed.Parsed["workspaceName"]; !ok { + return nil, fmt.Errorf("the segment 'workspaceName' was not found in the resource id %q", input) + } + + return &id, nil +} + +// ValidateWorkspaceID checks that 'input' can be parsed as a Workspace ID +func ValidateWorkspaceID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseWorkspaceID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Workspace ID +func (id WorkspaceId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.HealthcareApis/workspaces/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.WorkspaceName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Workspace ID +func (id WorkspaceId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftHealthcareApis", "Microsoft.HealthcareApis", "Microsoft.HealthcareApis"), + resourceids.StaticSegment("staticWorkspaces", "workspaces", "workspaces"), + resourceids.UserSpecifiedSegment("workspaceName", "workspaceValue"), + } +} + +// String returns a human-readable description of this Workspace ID +func (id WorkspaceId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Workspace Name: %q", id.WorkspaceName), + } + return fmt.Sprintf("Workspace (%s)", strings.Join(components, "\n")) +} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/id_workspace_test.go b/internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/id_workspace_test.go new file mode 100644 index 000000000000..71cf45cc1ade --- /dev/null +++ b/internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/id_workspace_test.go @@ -0,0 +1,279 @@ +package iotconnectors + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +var _ resourceids.ResourceId = WorkspaceId{} + +func TestNewWorkspaceID(t *testing.T) { + id := NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceValue") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.WorkspaceName != "workspaceValue" { + t.Fatalf("Expected %q but got %q for Segment 'WorkspaceName'", id.WorkspaceName, "workspaceValue") + } +} + +func TestFormatWorkspaceID(t *testing.T) { + actual := NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/workspaces/workspaceValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseWorkspaceID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *WorkspaceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/workspaces", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/workspaces/workspaceValue", + Expected: &WorkspaceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/workspaces/workspaceValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseWorkspaceID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + } +} + +func TestParseWorkspaceIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *WorkspaceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hEaLtHcArEaPiS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/workspaces", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hEaLtHcArEaPiS/wOrKsPaCeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/workspaces/workspaceValue", + Expected: &WorkspaceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/workspaces/workspaceValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hEaLtHcArEaPiS/wOrKsPaCeS/wOrKsPaCeVaLuE", + Expected: &WorkspaceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + WorkspaceName: "wOrKsPaCeVaLuE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hEaLtHcArEaPiS/wOrKsPaCeS/wOrKsPaCeVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseWorkspaceIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + } +} + +func TestSegmentsForWorkspaceId(t *testing.T) { + segments := WorkspaceId{}.Segments() + if len(segments) == 0 { + t.Fatalf("WorkspaceId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/method_createorupdate_autorest.go b/internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/method_createorupdate_autorest.go new file mode 100644 index 000000000000..ddd01a3d9e3c --- /dev/null +++ b/internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/method_createorupdate_autorest.go @@ -0,0 +1,75 @@ +package iotconnectors + +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" +) + +type CreateOrUpdateResponse struct { + Poller polling.LongRunningPoller + HttpResponse *http.Response +} + +// CreateOrUpdate ... +func (c IotConnectorsClient) CreateOrUpdate(ctx context.Context, id IotConnectorId, input IotConnector) (result CreateOrUpdateResponse, err error) { + req, err := c.preparerForCreateOrUpdate(ctx, id, input) + if err != nil { + err = autorest.NewErrorWithError(err, "iotconnectors.IotConnectorsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = c.senderForCreateOrUpdate(ctx, req) + if err != nil { + err = autorest.NewErrorWithError(err, "iotconnectors.IotConnectorsClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") + return + } + + return +} + +// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed +func (c IotConnectorsClient) CreateOrUpdateThenPoll(ctx context.Context, id IotConnectorId, input IotConnector) 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 IotConnectorsClient) preparerForCreateOrUpdate(ctx context.Context, id IotConnectorId, input IotConnector) (*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 IotConnectorsClient) senderForCreateOrUpdate(ctx context.Context, req *http.Request) (future CreateOrUpdateResponse, err error) { + var resp *http.Response + resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + return + } + future.Poller, err = polling.NewLongRunningPollerFromResponse(ctx, resp, c.Client) + return +} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/method_delete_autorest.go b/internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/method_delete_autorest.go new file mode 100644 index 000000000000..af3c325d03d3 --- /dev/null +++ b/internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/method_delete_autorest.go @@ -0,0 +1,74 @@ +package iotconnectors + +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" +) + +type DeleteResponse struct { + Poller polling.LongRunningPoller + HttpResponse *http.Response +} + +// Delete ... +func (c IotConnectorsClient) Delete(ctx context.Context, id IotConnectorId) (result DeleteResponse, err error) { + req, err := c.preparerForDelete(ctx, id) + if err != nil { + err = autorest.NewErrorWithError(err, "iotconnectors.IotConnectorsClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = c.senderForDelete(ctx, req) + if err != nil { + err = autorest.NewErrorWithError(err, "iotconnectors.IotConnectorsClient", "Delete", result.HttpResponse, "Failure sending request") + return + } + + return +} + +// DeleteThenPoll performs Delete then polls until it's completed +func (c IotConnectorsClient) DeleteThenPoll(ctx context.Context, id IotConnectorId) 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 IotConnectorsClient) preparerForDelete(ctx context.Context, id IotConnectorId) (*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 IotConnectorsClient) senderForDelete(ctx context.Context, req *http.Request) (future DeleteResponse, err error) { + var resp *http.Response + resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + return + } + future.Poller, err = polling.NewLongRunningPollerFromResponse(ctx, resp, c.Client) + return +} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/method_fhirdestinationslistbyiotconnector_autorest.go b/internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/method_fhirdestinationslistbyiotconnector_autorest.go new file mode 100644 index 000000000000..ef5526815211 --- /dev/null +++ b/internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/method_fhirdestinationslistbyiotconnector_autorest.go @@ -0,0 +1,183 @@ +package iotconnectors + +import ( + "context" + "fmt" + "net/http" + "net/url" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +type FhirDestinationsListByIotConnectorResponse struct { + HttpResponse *http.Response + Model *[]IotFhirDestination + + nextLink *string + nextPageFunc func(ctx context.Context, nextLink string) (FhirDestinationsListByIotConnectorResponse, error) +} + +type FhirDestinationsListByIotConnectorCompleteResult struct { + Items []IotFhirDestination +} + +func (r FhirDestinationsListByIotConnectorResponse) HasMore() bool { + return r.nextLink != nil +} + +func (r FhirDestinationsListByIotConnectorResponse) LoadMore(ctx context.Context) (resp FhirDestinationsListByIotConnectorResponse, err error) { + if !r.HasMore() { + err = fmt.Errorf("no more pages returned") + return + } + return r.nextPageFunc(ctx, *r.nextLink) +} + +// FhirDestinationsListByIotConnector ... +func (c IotConnectorsClient) FhirDestinationsListByIotConnector(ctx context.Context, id IotConnectorId) (resp FhirDestinationsListByIotConnectorResponse, err error) { + req, err := c.preparerForFhirDestinationsListByIotConnector(ctx, id) + if err != nil { + err = autorest.NewErrorWithError(err, "iotconnectors.IotConnectorsClient", "FhirDestinationsListByIotConnector", nil, "Failure preparing request") + return + } + + resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "iotconnectors.IotConnectorsClient", "FhirDestinationsListByIotConnector", resp.HttpResponse, "Failure sending request") + return + } + + resp, err = c.responderForFhirDestinationsListByIotConnector(resp.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "iotconnectors.IotConnectorsClient", "FhirDestinationsListByIotConnector", resp.HttpResponse, "Failure responding to request") + return + } + return +} + +// FhirDestinationsListByIotConnectorComplete retrieves all of the results into a single object +func (c IotConnectorsClient) FhirDestinationsListByIotConnectorComplete(ctx context.Context, id IotConnectorId) (FhirDestinationsListByIotConnectorCompleteResult, error) { + return c.FhirDestinationsListByIotConnectorCompleteMatchingPredicate(ctx, id, IotFhirDestinationPredicate{}) +} + +// FhirDestinationsListByIotConnectorCompleteMatchingPredicate retrieves all of the results and then applied the predicate +func (c IotConnectorsClient) FhirDestinationsListByIotConnectorCompleteMatchingPredicate(ctx context.Context, id IotConnectorId, predicate IotFhirDestinationPredicate) (resp FhirDestinationsListByIotConnectorCompleteResult, err error) { + items := make([]IotFhirDestination, 0) + + page, err := c.FhirDestinationsListByIotConnector(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 := FhirDestinationsListByIotConnectorCompleteResult{ + Items: items, + } + return out, nil +} + +// preparerForFhirDestinationsListByIotConnector prepares the FhirDestinationsListByIotConnector request. +func (c IotConnectorsClient) preparerForFhirDestinationsListByIotConnector(ctx context.Context, id IotConnectorId) (*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/fhirDestinations", id.ID())), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// preparerForFhirDestinationsListByIotConnectorWithNextLink prepares the FhirDestinationsListByIotConnector request with the given nextLink token. +func (c IotConnectorsClient) preparerForFhirDestinationsListByIotConnectorWithNextLink(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)) +} + +// responderForFhirDestinationsListByIotConnector handles the response to the FhirDestinationsListByIotConnector request. The method always +// closes the http.Response Body. +func (c IotConnectorsClient) responderForFhirDestinationsListByIotConnector(resp *http.Response) (result FhirDestinationsListByIotConnectorResponse, err error) { + type page struct { + Values []IotFhirDestination `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 FhirDestinationsListByIotConnectorResponse, err error) { + req, err := c.preparerForFhirDestinationsListByIotConnectorWithNextLink(ctx, nextLink) + if err != nil { + err = autorest.NewErrorWithError(err, "iotconnectors.IotConnectorsClient", "FhirDestinationsListByIotConnector", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "iotconnectors.IotConnectorsClient", "FhirDestinationsListByIotConnector", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForFhirDestinationsListByIotConnector(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "iotconnectors.IotConnectorsClient", "FhirDestinationsListByIotConnector", result.HttpResponse, "Failure responding to request") + return + } + + return + } + } + return +} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/method_get_autorest.go b/internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/method_get_autorest.go new file mode 100644 index 000000000000..097d83b2e092 --- /dev/null +++ b/internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/method_get_autorest.go @@ -0,0 +1,64 @@ +package iotconnectors + +import ( + "context" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +type GetResponse struct { + HttpResponse *http.Response + Model *IotConnector +} + +// Get ... +func (c IotConnectorsClient) Get(ctx context.Context, id IotConnectorId) (result GetResponse, err error) { + req, err := c.preparerForGet(ctx, id) + if err != nil { + err = autorest.NewErrorWithError(err, "iotconnectors.IotConnectorsClient", "Get", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "iotconnectors.IotConnectorsClient", "Get", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForGet(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "iotconnectors.IotConnectorsClient", "Get", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForGet prepares the Get request. +func (c IotConnectorsClient) preparerForGet(ctx context.Context, id IotConnectorId) (*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 IotConnectorsClient) responderForGet(resp *http.Response) (result GetResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Model), + autorest.ByClosing()) + result.HttpResponse = resp + return +} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/method_iotconnectorfhirdestinationcreateorupdate_autorest.go b/internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/method_iotconnectorfhirdestinationcreateorupdate_autorest.go new file mode 100644 index 000000000000..f2487864f453 --- /dev/null +++ b/internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/method_iotconnectorfhirdestinationcreateorupdate_autorest.go @@ -0,0 +1,75 @@ +package iotconnectors + +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" +) + +type IotConnectorFhirDestinationCreateOrUpdateResponse struct { + Poller polling.LongRunningPoller + HttpResponse *http.Response +} + +// IotConnectorFhirDestinationCreateOrUpdate ... +func (c IotConnectorsClient) IotConnectorFhirDestinationCreateOrUpdate(ctx context.Context, id FhirDestinationId, input IotFhirDestination) (result IotConnectorFhirDestinationCreateOrUpdateResponse, err error) { + req, err := c.preparerForIotConnectorFhirDestinationCreateOrUpdate(ctx, id, input) + if err != nil { + err = autorest.NewErrorWithError(err, "iotconnectors.IotConnectorsClient", "IotConnectorFhirDestinationCreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = c.senderForIotConnectorFhirDestinationCreateOrUpdate(ctx, req) + if err != nil { + err = autorest.NewErrorWithError(err, "iotconnectors.IotConnectorsClient", "IotConnectorFhirDestinationCreateOrUpdate", result.HttpResponse, "Failure sending request") + return + } + + return +} + +// IotConnectorFhirDestinationCreateOrUpdateThenPoll performs IotConnectorFhirDestinationCreateOrUpdate then polls until it's completed +func (c IotConnectorsClient) IotConnectorFhirDestinationCreateOrUpdateThenPoll(ctx context.Context, id FhirDestinationId, input IotFhirDestination) error { + result, err := c.IotConnectorFhirDestinationCreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing IotConnectorFhirDestinationCreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(); err != nil { + return fmt.Errorf("polling after IotConnectorFhirDestinationCreateOrUpdate: %+v", err) + } + + return nil +} + +// preparerForIotConnectorFhirDestinationCreateOrUpdate prepares the IotConnectorFhirDestinationCreateOrUpdate request. +func (c IotConnectorsClient) preparerForIotConnectorFhirDestinationCreateOrUpdate(ctx context.Context, id FhirDestinationId, input IotFhirDestination) (*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)) +} + +// senderForIotConnectorFhirDestinationCreateOrUpdate sends the IotConnectorFhirDestinationCreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (c IotConnectorsClient) senderForIotConnectorFhirDestinationCreateOrUpdate(ctx context.Context, req *http.Request) (future IotConnectorFhirDestinationCreateOrUpdateResponse, err error) { + var resp *http.Response + resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + return + } + future.Poller, err = polling.NewLongRunningPollerFromResponse(ctx, resp, c.Client) + return +} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/method_iotconnectorfhirdestinationdelete_autorest.go b/internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/method_iotconnectorfhirdestinationdelete_autorest.go new file mode 100644 index 000000000000..1c1c35e065e8 --- /dev/null +++ b/internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/method_iotconnectorfhirdestinationdelete_autorest.go @@ -0,0 +1,74 @@ +package iotconnectors + +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" +) + +type IotConnectorFhirDestinationDeleteResponse struct { + Poller polling.LongRunningPoller + HttpResponse *http.Response +} + +// IotConnectorFhirDestinationDelete ... +func (c IotConnectorsClient) IotConnectorFhirDestinationDelete(ctx context.Context, id FhirDestinationId) (result IotConnectorFhirDestinationDeleteResponse, err error) { + req, err := c.preparerForIotConnectorFhirDestinationDelete(ctx, id) + if err != nil { + err = autorest.NewErrorWithError(err, "iotconnectors.IotConnectorsClient", "IotConnectorFhirDestinationDelete", nil, "Failure preparing request") + return + } + + result, err = c.senderForIotConnectorFhirDestinationDelete(ctx, req) + if err != nil { + err = autorest.NewErrorWithError(err, "iotconnectors.IotConnectorsClient", "IotConnectorFhirDestinationDelete", result.HttpResponse, "Failure sending request") + return + } + + return +} + +// IotConnectorFhirDestinationDeleteThenPoll performs IotConnectorFhirDestinationDelete then polls until it's completed +func (c IotConnectorsClient) IotConnectorFhirDestinationDeleteThenPoll(ctx context.Context, id FhirDestinationId) error { + result, err := c.IotConnectorFhirDestinationDelete(ctx, id) + if err != nil { + return fmt.Errorf("performing IotConnectorFhirDestinationDelete: %+v", err) + } + + if err := result.Poller.PollUntilDone(); err != nil { + return fmt.Errorf("polling after IotConnectorFhirDestinationDelete: %+v", err) + } + + return nil +} + +// preparerForIotConnectorFhirDestinationDelete prepares the IotConnectorFhirDestinationDelete request. +func (c IotConnectorsClient) preparerForIotConnectorFhirDestinationDelete(ctx context.Context, id FhirDestinationId) (*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)) +} + +// senderForIotConnectorFhirDestinationDelete sends the IotConnectorFhirDestinationDelete request. The method will close the +// http.Response Body if it receives an error. +func (c IotConnectorsClient) senderForIotConnectorFhirDestinationDelete(ctx context.Context, req *http.Request) (future IotConnectorFhirDestinationDeleteResponse, err error) { + var resp *http.Response + resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + return + } + future.Poller, err = polling.NewLongRunningPollerFromResponse(ctx, resp, c.Client) + return +} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/method_iotconnectorfhirdestinationget_autorest.go b/internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/method_iotconnectorfhirdestinationget_autorest.go new file mode 100644 index 000000000000..81cf2854678a --- /dev/null +++ b/internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/method_iotconnectorfhirdestinationget_autorest.go @@ -0,0 +1,64 @@ +package iotconnectors + +import ( + "context" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +type IotConnectorFhirDestinationGetResponse struct { + HttpResponse *http.Response + Model *IotFhirDestination +} + +// IotConnectorFhirDestinationGet ... +func (c IotConnectorsClient) IotConnectorFhirDestinationGet(ctx context.Context, id FhirDestinationId) (result IotConnectorFhirDestinationGetResponse, err error) { + req, err := c.preparerForIotConnectorFhirDestinationGet(ctx, id) + if err != nil { + err = autorest.NewErrorWithError(err, "iotconnectors.IotConnectorsClient", "IotConnectorFhirDestinationGet", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "iotconnectors.IotConnectorsClient", "IotConnectorFhirDestinationGet", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForIotConnectorFhirDestinationGet(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "iotconnectors.IotConnectorsClient", "IotConnectorFhirDestinationGet", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForIotConnectorFhirDestinationGet prepares the IotConnectorFhirDestinationGet request. +func (c IotConnectorsClient) preparerForIotConnectorFhirDestinationGet(ctx context.Context, id FhirDestinationId) (*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)) +} + +// responderForIotConnectorFhirDestinationGet handles the response to the IotConnectorFhirDestinationGet request. The method always +// closes the http.Response Body. +func (c IotConnectorsClient) responderForIotConnectorFhirDestinationGet(resp *http.Response) (result IotConnectorFhirDestinationGetResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Model), + autorest.ByClosing()) + result.HttpResponse = resp + return +} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/method_listbyworkspace_autorest.go b/internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/method_listbyworkspace_autorest.go new file mode 100644 index 000000000000..20359d309383 --- /dev/null +++ b/internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/method_listbyworkspace_autorest.go @@ -0,0 +1,183 @@ +package iotconnectors + +import ( + "context" + "fmt" + "net/http" + "net/url" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +type ListByWorkspaceResponse struct { + HttpResponse *http.Response + Model *[]IotConnector + + nextLink *string + nextPageFunc func(ctx context.Context, nextLink string) (ListByWorkspaceResponse, error) +} + +type ListByWorkspaceCompleteResult struct { + Items []IotConnector +} + +func (r ListByWorkspaceResponse) HasMore() bool { + return r.nextLink != nil +} + +func (r ListByWorkspaceResponse) LoadMore(ctx context.Context) (resp ListByWorkspaceResponse, err error) { + if !r.HasMore() { + err = fmt.Errorf("no more pages returned") + return + } + return r.nextPageFunc(ctx, *r.nextLink) +} + +// ListByWorkspace ... +func (c IotConnectorsClient) ListByWorkspace(ctx context.Context, id WorkspaceId) (resp ListByWorkspaceResponse, err error) { + req, err := c.preparerForListByWorkspace(ctx, id) + if err != nil { + err = autorest.NewErrorWithError(err, "iotconnectors.IotConnectorsClient", "ListByWorkspace", nil, "Failure preparing request") + return + } + + resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "iotconnectors.IotConnectorsClient", "ListByWorkspace", resp.HttpResponse, "Failure sending request") + return + } + + resp, err = c.responderForListByWorkspace(resp.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "iotconnectors.IotConnectorsClient", "ListByWorkspace", resp.HttpResponse, "Failure responding to request") + return + } + return +} + +// ListByWorkspaceComplete retrieves all of the results into a single object +func (c IotConnectorsClient) ListByWorkspaceComplete(ctx context.Context, id WorkspaceId) (ListByWorkspaceCompleteResult, error) { + return c.ListByWorkspaceCompleteMatchingPredicate(ctx, id, IotConnectorPredicate{}) +} + +// ListByWorkspaceCompleteMatchingPredicate retrieves all of the results and then applied the predicate +func (c IotConnectorsClient) ListByWorkspaceCompleteMatchingPredicate(ctx context.Context, id WorkspaceId, predicate IotConnectorPredicate) (resp ListByWorkspaceCompleteResult, err error) { + items := make([]IotConnector, 0) + + page, err := c.ListByWorkspace(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 := ListByWorkspaceCompleteResult{ + Items: items, + } + return out, nil +} + +// preparerForListByWorkspace prepares the ListByWorkspace request. +func (c IotConnectorsClient) preparerForListByWorkspace(ctx context.Context, id WorkspaceId) (*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/iotConnectors", id.ID())), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// preparerForListByWorkspaceWithNextLink prepares the ListByWorkspace request with the given nextLink token. +func (c IotConnectorsClient) preparerForListByWorkspaceWithNextLink(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)) +} + +// responderForListByWorkspace handles the response to the ListByWorkspace request. The method always +// closes the http.Response Body. +func (c IotConnectorsClient) responderForListByWorkspace(resp *http.Response) (result ListByWorkspaceResponse, err error) { + type page struct { + Values []IotConnector `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 ListByWorkspaceResponse, err error) { + req, err := c.preparerForListByWorkspaceWithNextLink(ctx, nextLink) + if err != nil { + err = autorest.NewErrorWithError(err, "iotconnectors.IotConnectorsClient", "ListByWorkspace", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "iotconnectors.IotConnectorsClient", "ListByWorkspace", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForListByWorkspace(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "iotconnectors.IotConnectorsClient", "ListByWorkspace", result.HttpResponse, "Failure responding to request") + return + } + + return + } + } + return +} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/method_update_autorest.go b/internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/method_update_autorest.go new file mode 100644 index 000000000000..181a12ba76fd --- /dev/null +++ b/internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/method_update_autorest.go @@ -0,0 +1,75 @@ +package iotconnectors + +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" +) + +type UpdateResponse struct { + Poller polling.LongRunningPoller + HttpResponse *http.Response +} + +// Update ... +func (c IotConnectorsClient) Update(ctx context.Context, id IotConnectorId, input IotConnectorPatchResource) (result UpdateResponse, err error) { + req, err := c.preparerForUpdate(ctx, id, input) + if err != nil { + err = autorest.NewErrorWithError(err, "iotconnectors.IotConnectorsClient", "Update", nil, "Failure preparing request") + return + } + + result, err = c.senderForUpdate(ctx, req) + if err != nil { + err = autorest.NewErrorWithError(err, "iotconnectors.IotConnectorsClient", "Update", result.HttpResponse, "Failure sending request") + return + } + + return +} + +// UpdateThenPoll performs Update then polls until it's completed +func (c IotConnectorsClient) UpdateThenPoll(ctx context.Context, id IotConnectorId, input IotConnectorPatchResource) 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 IotConnectorsClient) preparerForUpdate(ctx context.Context, id IotConnectorId, input IotConnectorPatchResource) (*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 IotConnectorsClient) senderForUpdate(ctx context.Context, req *http.Request) (future UpdateResponse, err error) { + var resp *http.Response + resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + return + } + future.Poller, err = polling.NewLongRunningPollerFromResponse(ctx, resp, c.Client) + return +} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/model_iotconnector.go b/internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/model_iotconnector.go new file mode 100644 index 000000000000..3c9c43084af5 --- /dev/null +++ b/internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/model_iotconnector.go @@ -0,0 +1,13 @@ +package iotconnectors + +type IotConnector struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Identity *ServiceManagedIdentityIdentity `json:"identity,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *IotConnectorProperties `json:"properties,omitempty"` + SystemData *SystemData `json:"systemData,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/model_iotconnectorpatchresource.go b/internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/model_iotconnectorpatchresource.go new file mode 100644 index 000000000000..4c980b149b47 --- /dev/null +++ b/internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/model_iotconnectorpatchresource.go @@ -0,0 +1,6 @@ +package iotconnectors + +type IotConnectorPatchResource struct { + Identity *ServiceManagedIdentityIdentity `json:"identity,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/model_iotconnectorproperties.go b/internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/model_iotconnectorproperties.go new file mode 100644 index 000000000000..1102fd1e56f4 --- /dev/null +++ b/internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/model_iotconnectorproperties.go @@ -0,0 +1,7 @@ +package iotconnectors + +type IotConnectorProperties struct { + DeviceMapping *IotMappingProperties `json:"deviceMapping,omitempty"` + IngestionEndpointConfiguration *IotEventHubIngestionEndpointConfiguration `json:"ingestionEndpointConfiguration,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/model_ioteventhubingestionendpointconfiguration.go b/internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/model_ioteventhubingestionendpointconfiguration.go new file mode 100644 index 000000000000..e34400fc4440 --- /dev/null +++ b/internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/model_ioteventhubingestionendpointconfiguration.go @@ -0,0 +1,7 @@ +package iotconnectors + +type IotEventHubIngestionEndpointConfiguration struct { + ConsumerGroup *string `json:"consumerGroup,omitempty"` + EventHubName *string `json:"eventHubName,omitempty"` + FullyQualifiedEventHubNamespace *string `json:"fullyQualifiedEventHubNamespace,omitempty"` +} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/model_iotfhirdestination.go b/internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/model_iotfhirdestination.go new file mode 100644 index 000000000000..0a3bdef0662e --- /dev/null +++ b/internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/model_iotfhirdestination.go @@ -0,0 +1,11 @@ +package iotconnectors + +type IotFhirDestination struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties IotFhirDestinationProperties `json:"properties"` + SystemData *SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/model_iotfhirdestinationproperties.go b/internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/model_iotfhirdestinationproperties.go new file mode 100644 index 000000000000..b86368e0ce81 --- /dev/null +++ b/internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/model_iotfhirdestinationproperties.go @@ -0,0 +1,8 @@ +package iotconnectors + +type IotFhirDestinationProperties struct { + FhirMapping IotMappingProperties `json:"fhirMapping"` + FhirServiceResourceId string `json:"fhirServiceResourceId"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceIdentityResolutionType IotIdentityResolutionType `json:"resourceIdentityResolutionType"` +} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/model_iotmappingproperties.go b/internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/model_iotmappingproperties.go new file mode 100644 index 000000000000..9cba478c4d2b --- /dev/null +++ b/internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/model_iotmappingproperties.go @@ -0,0 +1,5 @@ +package iotconnectors + +type IotMappingProperties struct { + Content *interface{} `json:"content,omitempty"` +} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/model_servicemanagedidentityidentity.go b/internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/model_servicemanagedidentityidentity.go new file mode 100644 index 000000000000..eb6d993f1928 --- /dev/null +++ b/internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/model_servicemanagedidentityidentity.go @@ -0,0 +1,5 @@ +package iotconnectors + +type ServiceManagedIdentityIdentity struct { + Type *ManagedServiceIdentityType `json:"type,omitempty"` +} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/model_systemdata.go b/internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/model_systemdata.go new file mode 100644 index 000000000000..b911891fcd2f --- /dev/null +++ b/internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/model_systemdata.go @@ -0,0 +1,40 @@ +package iotconnectors + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +type SystemData struct { + CreatedAt *string `json:"createdAt,omitempty"` + CreatedBy *string `json:"createdBy,omitempty"` + CreatedByType *CreatedByType `json:"createdByType,omitempty"` + LastModifiedAt *string `json:"lastModifiedAt,omitempty"` + LastModifiedBy *string `json:"lastModifiedBy,omitempty"` + LastModifiedByType *CreatedByType `json:"lastModifiedByType,omitempty"` +} + +func (o SystemData) GetCreatedAtAsTime() (*time.Time, error) { + if o.CreatedAt == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreatedAt, "2006-01-02T15:04:05Z07:00") +} + +func (o SystemData) SetCreatedAtAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreatedAt = &formatted +} + +func (o SystemData) GetLastModifiedAtAsTime() (*time.Time, error) { + if o.LastModifiedAt == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastModifiedAt, "2006-01-02T15:04:05Z07:00") +} + +func (o SystemData) SetLastModifiedAtAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastModifiedAt = &formatted +} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/predicates.go b/internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/predicates.go new file mode 100644 index 000000000000..9d1c0b3fa06e --- /dev/null +++ b/internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/predicates.go @@ -0,0 +1,67 @@ +package iotconnectors + +type IotConnectorPredicate struct { + Etag *string + Id *string + Location *string + Name *string + Type *string +} + +func (p IotConnectorPredicate) Matches(input IotConnector) bool { + + if p.Etag != nil && (input.Etag == nil && *p.Etag != *input.Etag) { + return false + } + + if p.Id != nil && (input.Id == nil && *p.Id != *input.Id) { + return false + } + + if p.Location != nil && (input.Location == nil && *p.Location != *input.Location) { + return false + } + + if p.Name != nil && (input.Name == nil && *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil && *p.Type != *input.Type) { + return false + } + + return true +} + +type IotFhirDestinationPredicate struct { + Etag *string + Id *string + Location *string + Name *string + Type *string +} + +func (p IotFhirDestinationPredicate) Matches(input IotFhirDestination) bool { + + if p.Etag != nil && (input.Etag == nil && *p.Etag != *input.Etag) { + return false + } + + if p.Id != nil && (input.Id == nil && *p.Id != *input.Id) { + return false + } + + if p.Location != nil && (input.Location == nil && *p.Location != *input.Location) { + return false + } + + if p.Name != nil && (input.Name == nil && *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil && *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/version.go b/internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/version.go new file mode 100644 index 000000000000..1fd7f1e701a0 --- /dev/null +++ b/internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/version.go @@ -0,0 +1,9 @@ +package iotconnectors + +import "fmt" + +const defaultApiVersion = "2021-06-01-preview" + +func userAgent() string { + return fmt.Sprintf("pandora/iotconnectors/%s", defaultApiVersion) +} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/privateendpointconnections/client.go b/internal/services/healthcare/sdk/2021-06-01-preview/privateendpointconnections/client.go new file mode 100644 index 000000000000..adc4283affb2 --- /dev/null +++ b/internal/services/healthcare/sdk/2021-06-01-preview/privateendpointconnections/client.go @@ -0,0 +1,15 @@ +package privateendpointconnections + +import "github.com/Azure/go-autorest/autorest" + +type PrivateEndpointConnectionsClient struct { + Client autorest.Client + baseUri string +} + +func NewPrivateEndpointConnectionsClientWithBaseURI(endpoint string) PrivateEndpointConnectionsClient { + return PrivateEndpointConnectionsClient{ + Client: autorest.NewClientWithUserAgent(userAgent()), + baseUri: endpoint, + } +} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/privateendpointconnections/constants.go b/internal/services/healthcare/sdk/2021-06-01-preview/privateendpointconnections/constants.go new file mode 100644 index 000000000000..32001a4a5e77 --- /dev/null +++ b/internal/services/healthcare/sdk/2021-06-01-preview/privateendpointconnections/constants.go @@ -0,0 +1,102 @@ +package privateendpointconnections + +import "strings" + +type CreatedByType string + +const ( + CreatedByTypeApplication CreatedByType = "Application" + CreatedByTypeKey CreatedByType = "Key" + CreatedByTypeManagedIdentity CreatedByType = "ManagedIdentity" + CreatedByTypeUser CreatedByType = "User" +) + +func PossibleValuesForCreatedByType() []string { + return []string{ + string(CreatedByTypeApplication), + string(CreatedByTypeKey), + string(CreatedByTypeManagedIdentity), + string(CreatedByTypeUser), + } +} + +func parseCreatedByType(input string) (*CreatedByType, error) { + vals := map[string]CreatedByType{ + "application": CreatedByTypeApplication, + "key": CreatedByTypeKey, + "managedidentity": CreatedByTypeManagedIdentity, + "user": CreatedByTypeUser, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := CreatedByType(input) + return &out, nil +} + +type PrivateEndpointConnectionProvisioningState string + +const ( + PrivateEndpointConnectionProvisioningStateCreating PrivateEndpointConnectionProvisioningState = "Creating" + PrivateEndpointConnectionProvisioningStateDeleting PrivateEndpointConnectionProvisioningState = "Deleting" + PrivateEndpointConnectionProvisioningStateFailed PrivateEndpointConnectionProvisioningState = "Failed" + PrivateEndpointConnectionProvisioningStateSucceeded PrivateEndpointConnectionProvisioningState = "Succeeded" +) + +func PossibleValuesForPrivateEndpointConnectionProvisioningState() []string { + return []string{ + string(PrivateEndpointConnectionProvisioningStateCreating), + string(PrivateEndpointConnectionProvisioningStateDeleting), + string(PrivateEndpointConnectionProvisioningStateFailed), + string(PrivateEndpointConnectionProvisioningStateSucceeded), + } +} + +func parsePrivateEndpointConnectionProvisioningState(input string) (*PrivateEndpointConnectionProvisioningState, error) { + vals := map[string]PrivateEndpointConnectionProvisioningState{ + "creating": PrivateEndpointConnectionProvisioningStateCreating, + "deleting": PrivateEndpointConnectionProvisioningStateDeleting, + "failed": PrivateEndpointConnectionProvisioningStateFailed, + "succeeded": PrivateEndpointConnectionProvisioningStateSucceeded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PrivateEndpointConnectionProvisioningState(input) + return &out, nil +} + +type PrivateEndpointServiceConnectionStatus string + +const ( + PrivateEndpointServiceConnectionStatusApproved PrivateEndpointServiceConnectionStatus = "Approved" + PrivateEndpointServiceConnectionStatusPending PrivateEndpointServiceConnectionStatus = "Pending" + PrivateEndpointServiceConnectionStatusRejected PrivateEndpointServiceConnectionStatus = "Rejected" +) + +func PossibleValuesForPrivateEndpointServiceConnectionStatus() []string { + return []string{ + string(PrivateEndpointServiceConnectionStatusApproved), + string(PrivateEndpointServiceConnectionStatusPending), + string(PrivateEndpointServiceConnectionStatusRejected), + } +} + +func parsePrivateEndpointServiceConnectionStatus(input string) (*PrivateEndpointServiceConnectionStatus, error) { + vals := map[string]PrivateEndpointServiceConnectionStatus{ + "approved": PrivateEndpointServiceConnectionStatusApproved, + "pending": PrivateEndpointServiceConnectionStatusPending, + "rejected": PrivateEndpointServiceConnectionStatusRejected, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PrivateEndpointServiceConnectionStatus(input) + return &out, nil +} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/privateendpointconnections/id_privateendpointconnection.go b/internal/services/healthcare/sdk/2021-06-01-preview/privateendpointconnections/id_privateendpointconnection.go new file mode 100644 index 000000000000..f6e6cb11f4d1 --- /dev/null +++ b/internal/services/healthcare/sdk/2021-06-01-preview/privateendpointconnections/id_privateendpointconnection.go @@ -0,0 +1,137 @@ +package privateendpointconnections + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +var _ resourceids.ResourceId = PrivateEndpointConnectionId{} + +// PrivateEndpointConnectionId is a struct representing the Resource ID for a Private Endpoint Connection +type PrivateEndpointConnectionId struct { + SubscriptionId string + ResourceGroupName string + ResourceName string + PrivateEndpointConnectionName string +} + +// NewPrivateEndpointConnectionID returns a new PrivateEndpointConnectionId struct +func NewPrivateEndpointConnectionID(subscriptionId string, resourceGroupName string, resourceName string, privateEndpointConnectionName string) PrivateEndpointConnectionId { + return PrivateEndpointConnectionId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ResourceName: resourceName, + PrivateEndpointConnectionName: privateEndpointConnectionName, + } +} + +// ParsePrivateEndpointConnectionID parses 'input' into a PrivateEndpointConnectionId +func ParsePrivateEndpointConnectionID(input string) (*PrivateEndpointConnectionId, error) { + parser := resourceids.NewParserFromResourceIdType(PrivateEndpointConnectionId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := PrivateEndpointConnectionId{} + + if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { + return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) + } + + if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { + return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) + } + + if id.ResourceName, ok = parsed.Parsed["resourceName"]; !ok { + return nil, fmt.Errorf("the segment 'resourceName' was not found in the resource id %q", input) + } + + if id.PrivateEndpointConnectionName, ok = parsed.Parsed["privateEndpointConnectionName"]; !ok { + return nil, fmt.Errorf("the segment 'privateEndpointConnectionName' was not found in the resource id %q", input) + } + + return &id, nil +} + +// ParsePrivateEndpointConnectionIDInsensitively parses 'input' case-insensitively into a PrivateEndpointConnectionId +// note: this method should only be used for API response data and not user input +func ParsePrivateEndpointConnectionIDInsensitively(input string) (*PrivateEndpointConnectionId, error) { + parser := resourceids.NewParserFromResourceIdType(PrivateEndpointConnectionId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := PrivateEndpointConnectionId{} + + if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { + return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) + } + + if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { + return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) + } + + if id.ResourceName, ok = parsed.Parsed["resourceName"]; !ok { + return nil, fmt.Errorf("the segment 'resourceName' was not found in the resource id %q", input) + } + + if id.PrivateEndpointConnectionName, ok = parsed.Parsed["privateEndpointConnectionName"]; !ok { + return nil, fmt.Errorf("the segment 'privateEndpointConnectionName' was not found in the resource id %q", input) + } + + return &id, nil +} + +// ValidatePrivateEndpointConnectionID checks that 'input' can be parsed as a Private Endpoint Connection ID +func ValidatePrivateEndpointConnectionID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParsePrivateEndpointConnectionID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Private Endpoint Connection ID +func (id PrivateEndpointConnectionId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.HealthcareApis/services/%s/privateEndpointConnections/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ResourceName, id.PrivateEndpointConnectionName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Private Endpoint Connection ID +func (id PrivateEndpointConnectionId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftHealthcareApis", "Microsoft.HealthcareApis", "Microsoft.HealthcareApis"), + resourceids.StaticSegment("staticServices", "services", "services"), + resourceids.UserSpecifiedSegment("resourceName", "resourceValue"), + resourceids.StaticSegment("staticPrivateEndpointConnections", "privateEndpointConnections", "privateEndpointConnections"), + resourceids.UserSpecifiedSegment("privateEndpointConnectionName", "privateEndpointConnectionValue"), + } +} + +// String returns a human-readable description of this Private Endpoint Connection ID +func (id PrivateEndpointConnectionId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Resource Name: %q", id.ResourceName), + fmt.Sprintf("Private Endpoint Connection Name: %q", id.PrivateEndpointConnectionName), + } + return fmt.Sprintf("Private Endpoint Connection (%s)", strings.Join(components, "\n")) +} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/privateendpointconnections/id_privateendpointconnection_test.go b/internal/services/healthcare/sdk/2021-06-01-preview/privateendpointconnections/id_privateendpointconnection_test.go new file mode 100644 index 000000000000..7876560ae7a7 --- /dev/null +++ b/internal/services/healthcare/sdk/2021-06-01-preview/privateendpointconnections/id_privateendpointconnection_test.go @@ -0,0 +1,324 @@ +package privateendpointconnections + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +var _ resourceids.ResourceId = PrivateEndpointConnectionId{} + +func TestNewPrivateEndpointConnectionID(t *testing.T) { + id := NewPrivateEndpointConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "resourceValue", "privateEndpointConnectionValue") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.ResourceName != "resourceValue" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceName'", id.ResourceName, "resourceValue") + } + + if id.PrivateEndpointConnectionName != "privateEndpointConnectionValue" { + t.Fatalf("Expected %q but got %q for Segment 'PrivateEndpointConnectionName'", id.PrivateEndpointConnectionName, "privateEndpointConnectionValue") + } +} + +func TestFormatPrivateEndpointConnectionID(t *testing.T) { + actual := NewPrivateEndpointConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "resourceValue", "privateEndpointConnectionValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/services/resourceValue/privateEndpointConnections/privateEndpointConnectionValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParsePrivateEndpointConnectionID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *PrivateEndpointConnectionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/services", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/services/resourceValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/services/resourceValue/privateEndpointConnections", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/services/resourceValue/privateEndpointConnections/privateEndpointConnectionValue", + Expected: &PrivateEndpointConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ResourceName: "resourceValue", + PrivateEndpointConnectionName: "privateEndpointConnectionValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/services/resourceValue/privateEndpointConnections/privateEndpointConnectionValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParsePrivateEndpointConnectionID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ResourceName != v.Expected.ResourceName { + t.Fatalf("Expected %q but got %q for ResourceName", v.Expected.ResourceName, actual.ResourceName) + } + + if actual.PrivateEndpointConnectionName != v.Expected.PrivateEndpointConnectionName { + t.Fatalf("Expected %q but got %q for PrivateEndpointConnectionName", v.Expected.PrivateEndpointConnectionName, actual.PrivateEndpointConnectionName) + } + + } +} + +func TestParsePrivateEndpointConnectionIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *PrivateEndpointConnectionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hEaLtHcArEaPiS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/services", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hEaLtHcArEaPiS/sErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/services/resourceValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hEaLtHcArEaPiS/sErViCeS/rEsOuRcEvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/services/resourceValue/privateEndpointConnections", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hEaLtHcArEaPiS/sErViCeS/rEsOuRcEvAlUe/pRiVaTeEnDpOiNtCoNnEcTiOnS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/services/resourceValue/privateEndpointConnections/privateEndpointConnectionValue", + Expected: &PrivateEndpointConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ResourceName: "resourceValue", + PrivateEndpointConnectionName: "privateEndpointConnectionValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/services/resourceValue/privateEndpointConnections/privateEndpointConnectionValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hEaLtHcArEaPiS/sErViCeS/rEsOuRcEvAlUe/pRiVaTeEnDpOiNtCoNnEcTiOnS/pRiVaTeEnDpOiNtCoNnEcTiOnVaLuE", + Expected: &PrivateEndpointConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ResourceName: "rEsOuRcEvAlUe", + PrivateEndpointConnectionName: "pRiVaTeEnDpOiNtCoNnEcTiOnVaLuE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hEaLtHcArEaPiS/sErViCeS/rEsOuRcEvAlUe/pRiVaTeEnDpOiNtCoNnEcTiOnS/pRiVaTeEnDpOiNtCoNnEcTiOnVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParsePrivateEndpointConnectionIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ResourceName != v.Expected.ResourceName { + t.Fatalf("Expected %q but got %q for ResourceName", v.Expected.ResourceName, actual.ResourceName) + } + + if actual.PrivateEndpointConnectionName != v.Expected.PrivateEndpointConnectionName { + t.Fatalf("Expected %q but got %q for PrivateEndpointConnectionName", v.Expected.PrivateEndpointConnectionName, actual.PrivateEndpointConnectionName) + } + + } +} + +func TestSegmentsForPrivateEndpointConnectionId(t *testing.T) { + segments := PrivateEndpointConnectionId{}.Segments() + if len(segments) == 0 { + t.Fatalf("PrivateEndpointConnectionId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/privateendpointconnections/id_service.go b/internal/services/healthcare/sdk/2021-06-01-preview/privateendpointconnections/id_service.go new file mode 100644 index 000000000000..cb8692be3199 --- /dev/null +++ b/internal/services/healthcare/sdk/2021-06-01-preview/privateendpointconnections/id_service.go @@ -0,0 +1,124 @@ +package privateendpointconnections + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +var _ resourceids.ResourceId = ServiceId{} + +// ServiceId is a struct representing the Resource ID for a Service +type ServiceId struct { + SubscriptionId string + ResourceGroupName string + ResourceName string +} + +// NewServiceID returns a new ServiceId struct +func NewServiceID(subscriptionId string, resourceGroupName string, resourceName string) ServiceId { + return ServiceId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ResourceName: resourceName, + } +} + +// ParseServiceID parses 'input' into a ServiceId +func ParseServiceID(input string) (*ServiceId, error) { + parser := resourceids.NewParserFromResourceIdType(ServiceId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := ServiceId{} + + if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { + return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) + } + + if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { + return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) + } + + if id.ResourceName, ok = parsed.Parsed["resourceName"]; !ok { + return nil, fmt.Errorf("the segment 'resourceName' was not found in the resource id %q", input) + } + + return &id, nil +} + +// ParseServiceIDInsensitively parses 'input' case-insensitively into a ServiceId +// note: this method should only be used for API response data and not user input +func ParseServiceIDInsensitively(input string) (*ServiceId, error) { + parser := resourceids.NewParserFromResourceIdType(ServiceId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := ServiceId{} + + if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { + return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) + } + + if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { + return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) + } + + if id.ResourceName, ok = parsed.Parsed["resourceName"]; !ok { + return nil, fmt.Errorf("the segment 'resourceName' was not found in the resource id %q", input) + } + + return &id, nil +} + +// ValidateServiceID checks that 'input' can be parsed as a Service ID +func ValidateServiceID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseServiceID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Service ID +func (id ServiceId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.HealthcareApis/services/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ResourceName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Service ID +func (id ServiceId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftHealthcareApis", "Microsoft.HealthcareApis", "Microsoft.HealthcareApis"), + resourceids.StaticSegment("staticServices", "services", "services"), + resourceids.UserSpecifiedSegment("resourceName", "resourceValue"), + } +} + +// String returns a human-readable description of this Service ID +func (id ServiceId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Resource Name: %q", id.ResourceName), + } + return fmt.Sprintf("Service (%s)", strings.Join(components, "\n")) +} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/privateendpointconnections/id_service_test.go b/internal/services/healthcare/sdk/2021-06-01-preview/privateendpointconnections/id_service_test.go new file mode 100644 index 000000000000..d879c6948696 --- /dev/null +++ b/internal/services/healthcare/sdk/2021-06-01-preview/privateendpointconnections/id_service_test.go @@ -0,0 +1,279 @@ +package privateendpointconnections + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +var _ resourceids.ResourceId = ServiceId{} + +func TestNewServiceID(t *testing.T) { + id := NewServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "resourceValue") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.ResourceName != "resourceValue" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceName'", id.ResourceName, "resourceValue") + } +} + +func TestFormatServiceID(t *testing.T) { + actual := NewServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "resourceValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/services/resourceValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseServiceID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ServiceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/services", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/services/resourceValue", + Expected: &ServiceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ResourceName: "resourceValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/services/resourceValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseServiceID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ResourceName != v.Expected.ResourceName { + t.Fatalf("Expected %q but got %q for ResourceName", v.Expected.ResourceName, actual.ResourceName) + } + + } +} + +func TestParseServiceIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ServiceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hEaLtHcArEaPiS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/services", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hEaLtHcArEaPiS/sErViCeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/services/resourceValue", + Expected: &ServiceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ResourceName: "resourceValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/services/resourceValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hEaLtHcArEaPiS/sErViCeS/rEsOuRcEvAlUe", + Expected: &ServiceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ResourceName: "rEsOuRcEvAlUe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hEaLtHcArEaPiS/sErViCeS/rEsOuRcEvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseServiceIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ResourceName != v.Expected.ResourceName { + t.Fatalf("Expected %q but got %q for ResourceName", v.Expected.ResourceName, actual.ResourceName) + } + + } +} + +func TestSegmentsForServiceId(t *testing.T) { + segments := ServiceId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ServiceId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/privateendpointconnections/method_createorupdate_autorest.go b/internal/services/healthcare/sdk/2021-06-01-preview/privateendpointconnections/method_createorupdate_autorest.go new file mode 100644 index 000000000000..986cb8f4f626 --- /dev/null +++ b/internal/services/healthcare/sdk/2021-06-01-preview/privateendpointconnections/method_createorupdate_autorest.go @@ -0,0 +1,75 @@ +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" +) + +type CreateOrUpdateResponse struct { + Poller polling.LongRunningPoller + HttpResponse *http.Response +} + +// CreateOrUpdate ... +func (c PrivateEndpointConnectionsClient) CreateOrUpdate(ctx context.Context, id PrivateEndpointConnectionId, input PrivateEndpointConnection) (result CreateOrUpdateResponse, err error) { + req, err := c.preparerForCreateOrUpdate(ctx, id, input) + if err != nil { + err = autorest.NewErrorWithError(err, "privateendpointconnections.PrivateEndpointConnectionsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = c.senderForCreateOrUpdate(ctx, req) + if err != nil { + err = autorest.NewErrorWithError(err, "privateendpointconnections.PrivateEndpointConnectionsClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") + return + } + + return +} + +// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed +func (c PrivateEndpointConnectionsClient) CreateOrUpdateThenPoll(ctx context.Context, id PrivateEndpointConnectionId, input PrivateEndpointConnection) 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 PrivateEndpointConnectionsClient) preparerForCreateOrUpdate(ctx context.Context, id PrivateEndpointConnectionId, input PrivateEndpointConnection) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(id.ID()), + autorest.WithJSON(input), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// senderForCreateOrUpdate sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (c PrivateEndpointConnectionsClient) senderForCreateOrUpdate(ctx context.Context, req *http.Request) (future CreateOrUpdateResponse, err error) { + var resp *http.Response + resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + return + } + future.Poller, err = polling.NewLongRunningPollerFromResponse(ctx, resp, c.Client) + return +} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/privateendpointconnections/method_delete_autorest.go b/internal/services/healthcare/sdk/2021-06-01-preview/privateendpointconnections/method_delete_autorest.go new file mode 100644 index 000000000000..3c4a86df694f --- /dev/null +++ b/internal/services/healthcare/sdk/2021-06-01-preview/privateendpointconnections/method_delete_autorest.go @@ -0,0 +1,74 @@ +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" +) + +type DeleteResponse struct { + Poller polling.LongRunningPoller + HttpResponse *http.Response +} + +// Delete ... +func (c PrivateEndpointConnectionsClient) Delete(ctx context.Context, id PrivateEndpointConnectionId) (result DeleteResponse, err error) { + req, err := c.preparerForDelete(ctx, id) + if err != nil { + err = autorest.NewErrorWithError(err, "privateendpointconnections.PrivateEndpointConnectionsClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = c.senderForDelete(ctx, req) + if err != nil { + err = autorest.NewErrorWithError(err, "privateendpointconnections.PrivateEndpointConnectionsClient", "Delete", result.HttpResponse, "Failure sending request") + return + } + + return +} + +// DeleteThenPoll performs Delete then polls until it's completed +func (c PrivateEndpointConnectionsClient) DeleteThenPoll(ctx context.Context, id PrivateEndpointConnectionId) error { + result, err := c.Delete(ctx, id) + if err != nil { + return fmt.Errorf("performing Delete: %+v", err) + } + + if err := result.Poller.PollUntilDone(); err != nil { + return fmt.Errorf("polling after Delete: %+v", err) + } + + return nil +} + +// preparerForDelete prepares the Delete request. +func (c PrivateEndpointConnectionsClient) preparerForDelete(ctx context.Context, id PrivateEndpointConnectionId) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsDelete(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(id.ID()), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// senderForDelete sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (c PrivateEndpointConnectionsClient) senderForDelete(ctx context.Context, req *http.Request) (future DeleteResponse, err error) { + var resp *http.Response + resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + return + } + future.Poller, err = polling.NewLongRunningPollerFromResponse(ctx, resp, c.Client) + return +} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/privateendpointconnections/method_get_autorest.go b/internal/services/healthcare/sdk/2021-06-01-preview/privateendpointconnections/method_get_autorest.go new file mode 100644 index 000000000000..349a61376bc5 --- /dev/null +++ b/internal/services/healthcare/sdk/2021-06-01-preview/privateendpointconnections/method_get_autorest.go @@ -0,0 +1,64 @@ +package privateendpointconnections + +import ( + "context" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +type GetResponse struct { + HttpResponse *http.Response + Model *PrivateEndpointConnectionDescription +} + +// Get ... +func (c PrivateEndpointConnectionsClient) Get(ctx context.Context, id PrivateEndpointConnectionId) (result GetResponse, err error) { + req, err := c.preparerForGet(ctx, id) + if err != nil { + err = autorest.NewErrorWithError(err, "privateendpointconnections.PrivateEndpointConnectionsClient", "Get", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "privateendpointconnections.PrivateEndpointConnectionsClient", "Get", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForGet(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "privateendpointconnections.PrivateEndpointConnectionsClient", "Get", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForGet prepares the Get request. +func (c PrivateEndpointConnectionsClient) preparerForGet(ctx context.Context, id PrivateEndpointConnectionId) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsGet(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(id.ID()), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForGet handles the response to the Get request. The method always +// closes the http.Response Body. +func (c PrivateEndpointConnectionsClient) responderForGet(resp *http.Response) (result GetResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Model), + autorest.ByClosing()) + result.HttpResponse = resp + return +} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/privateendpointconnections/method_listbyservice_autorest.go b/internal/services/healthcare/sdk/2021-06-01-preview/privateendpointconnections/method_listbyservice_autorest.go new file mode 100644 index 000000000000..a908376bfddb --- /dev/null +++ b/internal/services/healthcare/sdk/2021-06-01-preview/privateendpointconnections/method_listbyservice_autorest.go @@ -0,0 +1,65 @@ +package privateendpointconnections + +import ( + "context" + "fmt" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +type ListByServiceResponse struct { + HttpResponse *http.Response + Model *PrivateEndpointConnectionListResultDescription +} + +// ListByService ... +func (c PrivateEndpointConnectionsClient) ListByService(ctx context.Context, id ServiceId) (result ListByServiceResponse, err error) { + req, err := c.preparerForListByService(ctx, id) + if err != nil { + err = autorest.NewErrorWithError(err, "privateendpointconnections.PrivateEndpointConnectionsClient", "ListByService", 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", "ListByService", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForListByService(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "privateendpointconnections.PrivateEndpointConnectionsClient", "ListByService", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForListByService prepares the ListByService request. +func (c PrivateEndpointConnectionsClient) 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/privateEndpointConnections", 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 PrivateEndpointConnectionsClient) responderForListByService(resp *http.Response) (result ListByServiceResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Model), + autorest.ByClosing()) + result.HttpResponse = resp + return +} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/privateendpointconnections/model_privateendpoint.go b/internal/services/healthcare/sdk/2021-06-01-preview/privateendpointconnections/model_privateendpoint.go new file mode 100644 index 000000000000..33ffc888d58a --- /dev/null +++ b/internal/services/healthcare/sdk/2021-06-01-preview/privateendpointconnections/model_privateendpoint.go @@ -0,0 +1,5 @@ +package privateendpointconnections + +type PrivateEndpoint struct { + Id *string `json:"id,omitempty"` +} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/privateendpointconnections/model_privateendpointconnection.go b/internal/services/healthcare/sdk/2021-06-01-preview/privateendpointconnections/model_privateendpointconnection.go new file mode 100644 index 000000000000..597d3e71746a --- /dev/null +++ b/internal/services/healthcare/sdk/2021-06-01-preview/privateendpointconnections/model_privateendpointconnection.go @@ -0,0 +1,8 @@ +package privateendpointconnections + +type PrivateEndpointConnection struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateEndpointConnectionProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/privateendpointconnections/model_privateendpointconnectiondescription.go b/internal/services/healthcare/sdk/2021-06-01-preview/privateendpointconnections/model_privateendpointconnectiondescription.go new file mode 100644 index 000000000000..95543c352044 --- /dev/null +++ b/internal/services/healthcare/sdk/2021-06-01-preview/privateendpointconnections/model_privateendpointconnectiondescription.go @@ -0,0 +1,9 @@ +package privateendpointconnections + +type PrivateEndpointConnectionDescription struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateEndpointConnectionProperties `json:"properties,omitempty"` + SystemData *SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/privateendpointconnections/model_privateendpointconnectionlistresultdescription.go b/internal/services/healthcare/sdk/2021-06-01-preview/privateendpointconnections/model_privateendpointconnectionlistresultdescription.go new file mode 100644 index 000000000000..579bed999b3d --- /dev/null +++ b/internal/services/healthcare/sdk/2021-06-01-preview/privateendpointconnections/model_privateendpointconnectionlistresultdescription.go @@ -0,0 +1,5 @@ +package privateendpointconnections + +type PrivateEndpointConnectionListResultDescription struct { + Value *[]PrivateEndpointConnectionDescription `json:"value,omitempty"` +} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/privateendpointconnections/model_privateendpointconnectionproperties.go b/internal/services/healthcare/sdk/2021-06-01-preview/privateendpointconnections/model_privateendpointconnectionproperties.go new file mode 100644 index 000000000000..252bd91cbe86 --- /dev/null +++ b/internal/services/healthcare/sdk/2021-06-01-preview/privateendpointconnections/model_privateendpointconnectionproperties.go @@ -0,0 +1,7 @@ +package privateendpointconnections + +type PrivateEndpointConnectionProperties struct { + PrivateEndpoint *PrivateEndpoint `json:"privateEndpoint,omitempty"` + PrivateLinkServiceConnectionState PrivateLinkServiceConnectionState `json:"privateLinkServiceConnectionState"` + ProvisioningState *PrivateEndpointConnectionProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/privateendpointconnections/model_privatelinkserviceconnectionstate.go b/internal/services/healthcare/sdk/2021-06-01-preview/privateendpointconnections/model_privatelinkserviceconnectionstate.go new file mode 100644 index 000000000000..def138656add --- /dev/null +++ b/internal/services/healthcare/sdk/2021-06-01-preview/privateendpointconnections/model_privatelinkserviceconnectionstate.go @@ -0,0 +1,7 @@ +package privateendpointconnections + +type PrivateLinkServiceConnectionState struct { + ActionsRequired *string `json:"actionsRequired,omitempty"` + Description *string `json:"description,omitempty"` + Status *PrivateEndpointServiceConnectionStatus `json:"status,omitempty"` +} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/privateendpointconnections/model_systemdata.go b/internal/services/healthcare/sdk/2021-06-01-preview/privateendpointconnections/model_systemdata.go new file mode 100644 index 000000000000..3d46829edeb6 --- /dev/null +++ b/internal/services/healthcare/sdk/2021-06-01-preview/privateendpointconnections/model_systemdata.go @@ -0,0 +1,40 @@ +package privateendpointconnections + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +type SystemData struct { + CreatedAt *string `json:"createdAt,omitempty"` + CreatedBy *string `json:"createdBy,omitempty"` + CreatedByType *CreatedByType `json:"createdByType,omitempty"` + LastModifiedAt *string `json:"lastModifiedAt,omitempty"` + LastModifiedBy *string `json:"lastModifiedBy,omitempty"` + LastModifiedByType *CreatedByType `json:"lastModifiedByType,omitempty"` +} + +func (o SystemData) GetCreatedAtAsTime() (*time.Time, error) { + if o.CreatedAt == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreatedAt, "2006-01-02T15:04:05Z07:00") +} + +func (o SystemData) SetCreatedAtAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreatedAt = &formatted +} + +func (o SystemData) GetLastModifiedAtAsTime() (*time.Time, error) { + if o.LastModifiedAt == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastModifiedAt, "2006-01-02T15:04:05Z07:00") +} + +func (o SystemData) SetLastModifiedAtAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastModifiedAt = &formatted +} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/privateendpointconnections/version.go b/internal/services/healthcare/sdk/2021-06-01-preview/privateendpointconnections/version.go new file mode 100644 index 000000000000..0e3da44caa60 --- /dev/null +++ b/internal/services/healthcare/sdk/2021-06-01-preview/privateendpointconnections/version.go @@ -0,0 +1,9 @@ +package privateendpointconnections + +import "fmt" + +const defaultApiVersion = "2021-06-01-preview" + +func userAgent() string { + return fmt.Sprintf("pandora/privateendpointconnections/%s", defaultApiVersion) +} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/privatelinkresources/client.go b/internal/services/healthcare/sdk/2021-06-01-preview/privatelinkresources/client.go new file mode 100644 index 000000000000..3ccc015d4fe1 --- /dev/null +++ b/internal/services/healthcare/sdk/2021-06-01-preview/privatelinkresources/client.go @@ -0,0 +1,15 @@ +package privatelinkresources + +import "github.com/Azure/go-autorest/autorest" + +type PrivateLinkResourcesClient struct { + Client autorest.Client + baseUri string +} + +func NewPrivateLinkResourcesClientWithBaseURI(endpoint string) PrivateLinkResourcesClient { + return PrivateLinkResourcesClient{ + Client: autorest.NewClientWithUserAgent(userAgent()), + baseUri: endpoint, + } +} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/privatelinkresources/constants.go b/internal/services/healthcare/sdk/2021-06-01-preview/privatelinkresources/constants.go new file mode 100644 index 000000000000..8b7848581899 --- /dev/null +++ b/internal/services/healthcare/sdk/2021-06-01-preview/privatelinkresources/constants.go @@ -0,0 +1,37 @@ +package privatelinkresources + +import "strings" + +type CreatedByType string + +const ( + CreatedByTypeApplication CreatedByType = "Application" + CreatedByTypeKey CreatedByType = "Key" + CreatedByTypeManagedIdentity CreatedByType = "ManagedIdentity" + CreatedByTypeUser CreatedByType = "User" +) + +func PossibleValuesForCreatedByType() []string { + return []string{ + string(CreatedByTypeApplication), + string(CreatedByTypeKey), + string(CreatedByTypeManagedIdentity), + string(CreatedByTypeUser), + } +} + +func parseCreatedByType(input string) (*CreatedByType, error) { + vals := map[string]CreatedByType{ + "application": CreatedByTypeApplication, + "key": CreatedByTypeKey, + "managedidentity": CreatedByTypeManagedIdentity, + "user": CreatedByTypeUser, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := CreatedByType(input) + return &out, nil +} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/privatelinkresources/id_privatelinkresource.go b/internal/services/healthcare/sdk/2021-06-01-preview/privatelinkresources/id_privatelinkresource.go new file mode 100644 index 000000000000..4a716efea2d6 --- /dev/null +++ b/internal/services/healthcare/sdk/2021-06-01-preview/privatelinkresources/id_privatelinkresource.go @@ -0,0 +1,137 @@ +package privatelinkresources + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +var _ resourceids.ResourceId = PrivateLinkResourceId{} + +// PrivateLinkResourceId is a struct representing the Resource ID for a Private Link Resource +type PrivateLinkResourceId struct { + SubscriptionId string + ResourceGroupName string + ResourceName string + GroupName string +} + +// NewPrivateLinkResourceID returns a new PrivateLinkResourceId struct +func NewPrivateLinkResourceID(subscriptionId string, resourceGroupName string, resourceName string, groupName string) PrivateLinkResourceId { + return PrivateLinkResourceId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ResourceName: resourceName, + GroupName: groupName, + } +} + +// ParsePrivateLinkResourceID parses 'input' into a PrivateLinkResourceId +func ParsePrivateLinkResourceID(input string) (*PrivateLinkResourceId, error) { + parser := resourceids.NewParserFromResourceIdType(PrivateLinkResourceId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := PrivateLinkResourceId{} + + if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { + return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) + } + + if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { + return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) + } + + if id.ResourceName, ok = parsed.Parsed["resourceName"]; !ok { + return nil, fmt.Errorf("the segment 'resourceName' was not found in the resource id %q", input) + } + + if id.GroupName, ok = parsed.Parsed["groupName"]; !ok { + return nil, fmt.Errorf("the segment 'groupName' was not found in the resource id %q", input) + } + + return &id, nil +} + +// ParsePrivateLinkResourceIDInsensitively parses 'input' case-insensitively into a PrivateLinkResourceId +// note: this method should only be used for API response data and not user input +func ParsePrivateLinkResourceIDInsensitively(input string) (*PrivateLinkResourceId, error) { + parser := resourceids.NewParserFromResourceIdType(PrivateLinkResourceId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := PrivateLinkResourceId{} + + if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { + return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) + } + + if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { + return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) + } + + if id.ResourceName, ok = parsed.Parsed["resourceName"]; !ok { + return nil, fmt.Errorf("the segment 'resourceName' was not found in the resource id %q", input) + } + + if id.GroupName, ok = parsed.Parsed["groupName"]; !ok { + return nil, fmt.Errorf("the segment 'groupName' was not found in the resource id %q", input) + } + + return &id, nil +} + +// ValidatePrivateLinkResourceID checks that 'input' can be parsed as a Private Link Resource ID +func ValidatePrivateLinkResourceID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParsePrivateLinkResourceID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Private Link Resource ID +func (id PrivateLinkResourceId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.HealthcareApis/services/%s/privateLinkResources/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ResourceName, id.GroupName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Private Link Resource ID +func (id PrivateLinkResourceId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftHealthcareApis", "Microsoft.HealthcareApis", "Microsoft.HealthcareApis"), + resourceids.StaticSegment("staticServices", "services", "services"), + resourceids.UserSpecifiedSegment("resourceName", "resourceValue"), + resourceids.StaticSegment("staticPrivateLinkResources", "privateLinkResources", "privateLinkResources"), + resourceids.UserSpecifiedSegment("groupName", "groupValue"), + } +} + +// String returns a human-readable description of this Private Link Resource ID +func (id PrivateLinkResourceId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Resource Name: %q", id.ResourceName), + fmt.Sprintf("Group Name: %q", id.GroupName), + } + return fmt.Sprintf("Private Link Resource (%s)", strings.Join(components, "\n")) +} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/privatelinkresources/id_privatelinkresource_test.go b/internal/services/healthcare/sdk/2021-06-01-preview/privatelinkresources/id_privatelinkresource_test.go new file mode 100644 index 000000000000..a7334abc33b5 --- /dev/null +++ b/internal/services/healthcare/sdk/2021-06-01-preview/privatelinkresources/id_privatelinkresource_test.go @@ -0,0 +1,324 @@ +package privatelinkresources + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +var _ resourceids.ResourceId = PrivateLinkResourceId{} + +func TestNewPrivateLinkResourceID(t *testing.T) { + id := NewPrivateLinkResourceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "resourceValue", "groupValue") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.ResourceName != "resourceValue" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceName'", id.ResourceName, "resourceValue") + } + + if id.GroupName != "groupValue" { + t.Fatalf("Expected %q but got %q for Segment 'GroupName'", id.GroupName, "groupValue") + } +} + +func TestFormatPrivateLinkResourceID(t *testing.T) { + actual := NewPrivateLinkResourceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "resourceValue", "groupValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/services/resourceValue/privateLinkResources/groupValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParsePrivateLinkResourceID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *PrivateLinkResourceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/services", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/services/resourceValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/services/resourceValue/privateLinkResources", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/services/resourceValue/privateLinkResources/groupValue", + Expected: &PrivateLinkResourceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ResourceName: "resourceValue", + GroupName: "groupValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/services/resourceValue/privateLinkResources/groupValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParsePrivateLinkResourceID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ResourceName != v.Expected.ResourceName { + t.Fatalf("Expected %q but got %q for ResourceName", v.Expected.ResourceName, actual.ResourceName) + } + + if actual.GroupName != v.Expected.GroupName { + t.Fatalf("Expected %q but got %q for GroupName", v.Expected.GroupName, actual.GroupName) + } + + } +} + +func TestParsePrivateLinkResourceIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *PrivateLinkResourceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hEaLtHcArEaPiS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/services", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hEaLtHcArEaPiS/sErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/services/resourceValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hEaLtHcArEaPiS/sErViCeS/rEsOuRcEvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/services/resourceValue/privateLinkResources", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hEaLtHcArEaPiS/sErViCeS/rEsOuRcEvAlUe/pRiVaTeLiNkReSoUrCeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/services/resourceValue/privateLinkResources/groupValue", + Expected: &PrivateLinkResourceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ResourceName: "resourceValue", + GroupName: "groupValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/services/resourceValue/privateLinkResources/groupValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hEaLtHcArEaPiS/sErViCeS/rEsOuRcEvAlUe/pRiVaTeLiNkReSoUrCeS/gRoUpVaLuE", + Expected: &PrivateLinkResourceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ResourceName: "rEsOuRcEvAlUe", + GroupName: "gRoUpVaLuE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hEaLtHcArEaPiS/sErViCeS/rEsOuRcEvAlUe/pRiVaTeLiNkReSoUrCeS/gRoUpVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParsePrivateLinkResourceIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ResourceName != v.Expected.ResourceName { + t.Fatalf("Expected %q but got %q for ResourceName", v.Expected.ResourceName, actual.ResourceName) + } + + if actual.GroupName != v.Expected.GroupName { + t.Fatalf("Expected %q but got %q for GroupName", v.Expected.GroupName, actual.GroupName) + } + + } +} + +func TestSegmentsForPrivateLinkResourceId(t *testing.T) { + segments := PrivateLinkResourceId{}.Segments() + if len(segments) == 0 { + t.Fatalf("PrivateLinkResourceId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/privatelinkresources/id_service.go b/internal/services/healthcare/sdk/2021-06-01-preview/privatelinkresources/id_service.go new file mode 100644 index 000000000000..f87dd953cbc0 --- /dev/null +++ b/internal/services/healthcare/sdk/2021-06-01-preview/privatelinkresources/id_service.go @@ -0,0 +1,124 @@ +package privatelinkresources + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +var _ resourceids.ResourceId = ServiceId{} + +// ServiceId is a struct representing the Resource ID for a Service +type ServiceId struct { + SubscriptionId string + ResourceGroupName string + ResourceName string +} + +// NewServiceID returns a new ServiceId struct +func NewServiceID(subscriptionId string, resourceGroupName string, resourceName string) ServiceId { + return ServiceId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ResourceName: resourceName, + } +} + +// ParseServiceID parses 'input' into a ServiceId +func ParseServiceID(input string) (*ServiceId, error) { + parser := resourceids.NewParserFromResourceIdType(ServiceId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := ServiceId{} + + if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { + return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) + } + + if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { + return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) + } + + if id.ResourceName, ok = parsed.Parsed["resourceName"]; !ok { + return nil, fmt.Errorf("the segment 'resourceName' was not found in the resource id %q", input) + } + + return &id, nil +} + +// ParseServiceIDInsensitively parses 'input' case-insensitively into a ServiceId +// note: this method should only be used for API response data and not user input +func ParseServiceIDInsensitively(input string) (*ServiceId, error) { + parser := resourceids.NewParserFromResourceIdType(ServiceId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := ServiceId{} + + if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { + return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) + } + + if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { + return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) + } + + if id.ResourceName, ok = parsed.Parsed["resourceName"]; !ok { + return nil, fmt.Errorf("the segment 'resourceName' was not found in the resource id %q", input) + } + + return &id, nil +} + +// ValidateServiceID checks that 'input' can be parsed as a Service ID +func ValidateServiceID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseServiceID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Service ID +func (id ServiceId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.HealthcareApis/services/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ResourceName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Service ID +func (id ServiceId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftHealthcareApis", "Microsoft.HealthcareApis", "Microsoft.HealthcareApis"), + resourceids.StaticSegment("staticServices", "services", "services"), + resourceids.UserSpecifiedSegment("resourceName", "resourceValue"), + } +} + +// String returns a human-readable description of this Service ID +func (id ServiceId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Resource Name: %q", id.ResourceName), + } + return fmt.Sprintf("Service (%s)", strings.Join(components, "\n")) +} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/privatelinkresources/id_service_test.go b/internal/services/healthcare/sdk/2021-06-01-preview/privatelinkresources/id_service_test.go new file mode 100644 index 000000000000..32a385125ba0 --- /dev/null +++ b/internal/services/healthcare/sdk/2021-06-01-preview/privatelinkresources/id_service_test.go @@ -0,0 +1,279 @@ +package privatelinkresources + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +var _ resourceids.ResourceId = ServiceId{} + +func TestNewServiceID(t *testing.T) { + id := NewServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "resourceValue") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.ResourceName != "resourceValue" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceName'", id.ResourceName, "resourceValue") + } +} + +func TestFormatServiceID(t *testing.T) { + actual := NewServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "resourceValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/services/resourceValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseServiceID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ServiceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/services", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/services/resourceValue", + Expected: &ServiceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ResourceName: "resourceValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/services/resourceValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseServiceID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ResourceName != v.Expected.ResourceName { + t.Fatalf("Expected %q but got %q for ResourceName", v.Expected.ResourceName, actual.ResourceName) + } + + } +} + +func TestParseServiceIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ServiceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hEaLtHcArEaPiS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/services", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hEaLtHcArEaPiS/sErViCeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/services/resourceValue", + Expected: &ServiceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ResourceName: "resourceValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/services/resourceValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hEaLtHcArEaPiS/sErViCeS/rEsOuRcEvAlUe", + Expected: &ServiceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ResourceName: "rEsOuRcEvAlUe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hEaLtHcArEaPiS/sErViCeS/rEsOuRcEvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseServiceIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ResourceName != v.Expected.ResourceName { + t.Fatalf("Expected %q but got %q for ResourceName", v.Expected.ResourceName, actual.ResourceName) + } + + } +} + +func TestSegmentsForServiceId(t *testing.T) { + segments := ServiceId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ServiceId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/privatelinkresources/method_get_autorest.go b/internal/services/healthcare/sdk/2021-06-01-preview/privatelinkresources/method_get_autorest.go new file mode 100644 index 000000000000..097c32ab3809 --- /dev/null +++ b/internal/services/healthcare/sdk/2021-06-01-preview/privatelinkresources/method_get_autorest.go @@ -0,0 +1,64 @@ +package privatelinkresources + +import ( + "context" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +type GetResponse struct { + HttpResponse *http.Response + Model *PrivateLinkResourceDescription +} + +// Get ... +func (c PrivateLinkResourcesClient) Get(ctx context.Context, id PrivateLinkResourceId) (result GetResponse, err error) { + req, err := c.preparerForGet(ctx, id) + if err != nil { + err = autorest.NewErrorWithError(err, "privatelinkresources.PrivateLinkResourcesClient", "Get", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "privatelinkresources.PrivateLinkResourcesClient", "Get", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForGet(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "privatelinkresources.PrivateLinkResourcesClient", "Get", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForGet prepares the Get request. +func (c PrivateLinkResourcesClient) preparerForGet(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)) +} + +// responderForGet handles the response to the Get request. The method always +// closes the http.Response Body. +func (c PrivateLinkResourcesClient) responderForGet(resp *http.Response) (result GetResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Model), + autorest.ByClosing()) + result.HttpResponse = resp + return +} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/privatelinkresources/method_listbyservice_autorest.go b/internal/services/healthcare/sdk/2021-06-01-preview/privatelinkresources/method_listbyservice_autorest.go new file mode 100644 index 000000000000..a13255a4d1bb --- /dev/null +++ b/internal/services/healthcare/sdk/2021-06-01-preview/privatelinkresources/method_listbyservice_autorest.go @@ -0,0 +1,65 @@ +package privatelinkresources + +import ( + "context" + "fmt" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +type ListByServiceResponse struct { + HttpResponse *http.Response + Model *PrivateLinkResourceListResultDescription +} + +// ListByService ... +func (c PrivateLinkResourcesClient) ListByService(ctx context.Context, id ServiceId) (result ListByServiceResponse, err error) { + req, err := c.preparerForListByService(ctx, id) + if err != nil { + err = autorest.NewErrorWithError(err, "privatelinkresources.PrivateLinkResourcesClient", "ListByService", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "privatelinkresources.PrivateLinkResourcesClient", "ListByService", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForListByService(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "privatelinkresources.PrivateLinkResourcesClient", "ListByService", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForListByService prepares the ListByService request. +func (c PrivateLinkResourcesClient) 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/privateLinkResources", 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 PrivateLinkResourcesClient) responderForListByService(resp *http.Response) (result ListByServiceResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Model), + autorest.ByClosing()) + result.HttpResponse = resp + return +} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/privatelinkresources/model_privatelinkresourcedescription.go b/internal/services/healthcare/sdk/2021-06-01-preview/privatelinkresources/model_privatelinkresourcedescription.go new file mode 100644 index 000000000000..cd11d5179a60 --- /dev/null +++ b/internal/services/healthcare/sdk/2021-06-01-preview/privatelinkresources/model_privatelinkresourcedescription.go @@ -0,0 +1,9 @@ +package privatelinkresources + +type PrivateLinkResourceDescription struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateLinkResourceProperties `json:"properties,omitempty"` + SystemData *SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/privatelinkresources/model_privatelinkresourcelistresultdescription.go b/internal/services/healthcare/sdk/2021-06-01-preview/privatelinkresources/model_privatelinkresourcelistresultdescription.go new file mode 100644 index 000000000000..9bf0baa227c8 --- /dev/null +++ b/internal/services/healthcare/sdk/2021-06-01-preview/privatelinkresources/model_privatelinkresourcelistresultdescription.go @@ -0,0 +1,5 @@ +package privatelinkresources + +type PrivateLinkResourceListResultDescription struct { + Value *[]PrivateLinkResourceDescription `json:"value,omitempty"` +} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/privatelinkresources/model_privatelinkresourceproperties.go b/internal/services/healthcare/sdk/2021-06-01-preview/privatelinkresources/model_privatelinkresourceproperties.go new file mode 100644 index 000000000000..51bc838c1fbd --- /dev/null +++ b/internal/services/healthcare/sdk/2021-06-01-preview/privatelinkresources/model_privatelinkresourceproperties.go @@ -0,0 +1,7 @@ +package privatelinkresources + +type PrivateLinkResourceProperties struct { + GroupId *string `json:"groupId,omitempty"` + RequiredMembers *[]string `json:"requiredMembers,omitempty"` + RequiredZoneNames *[]string `json:"requiredZoneNames,omitempty"` +} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/privatelinkresources/model_systemdata.go b/internal/services/healthcare/sdk/2021-06-01-preview/privatelinkresources/model_systemdata.go new file mode 100644 index 000000000000..f9327b762df1 --- /dev/null +++ b/internal/services/healthcare/sdk/2021-06-01-preview/privatelinkresources/model_systemdata.go @@ -0,0 +1,40 @@ +package privatelinkresources + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +type SystemData struct { + CreatedAt *string `json:"createdAt,omitempty"` + CreatedBy *string `json:"createdBy,omitempty"` + CreatedByType *CreatedByType `json:"createdByType,omitempty"` + LastModifiedAt *string `json:"lastModifiedAt,omitempty"` + LastModifiedBy *string `json:"lastModifiedBy,omitempty"` + LastModifiedByType *CreatedByType `json:"lastModifiedByType,omitempty"` +} + +func (o SystemData) GetCreatedAtAsTime() (*time.Time, error) { + if o.CreatedAt == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreatedAt, "2006-01-02T15:04:05Z07:00") +} + +func (o SystemData) SetCreatedAtAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreatedAt = &formatted +} + +func (o SystemData) GetLastModifiedAtAsTime() (*time.Time, error) { + if o.LastModifiedAt == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastModifiedAt, "2006-01-02T15:04:05Z07:00") +} + +func (o SystemData) SetLastModifiedAtAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastModifiedAt = &formatted +} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/privatelinkresources/version.go b/internal/services/healthcare/sdk/2021-06-01-preview/privatelinkresources/version.go new file mode 100644 index 000000000000..3b010fbce310 --- /dev/null +++ b/internal/services/healthcare/sdk/2021-06-01-preview/privatelinkresources/version.go @@ -0,0 +1,9 @@ +package privatelinkresources + +import "fmt" + +const defaultApiVersion = "2021-06-01-preview" + +func userAgent() string { + return fmt.Sprintf("pandora/privatelinkresources/%s", defaultApiVersion) +} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/proxy/client.go b/internal/services/healthcare/sdk/2021-06-01-preview/proxy/client.go new file mode 100644 index 000000000000..6acefce56ad5 --- /dev/null +++ b/internal/services/healthcare/sdk/2021-06-01-preview/proxy/client.go @@ -0,0 +1,15 @@ +package proxy + +import "github.com/Azure/go-autorest/autorest" + +type ProxyClient struct { + Client autorest.Client + baseUri string +} + +func NewProxyClientWithBaseURI(endpoint string) ProxyClient { + return ProxyClient{ + Client: autorest.NewClientWithUserAgent(userAgent()), + baseUri: endpoint, + } +} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/proxy/constants.go b/internal/services/healthcare/sdk/2021-06-01-preview/proxy/constants.go new file mode 100644 index 000000000000..6e0c4744ebfc --- /dev/null +++ b/internal/services/healthcare/sdk/2021-06-01-preview/proxy/constants.go @@ -0,0 +1,31 @@ +package proxy + +import "strings" + +type ServiceNameUnavailabilityReason string + +const ( + ServiceNameUnavailabilityReasonAlreadyExists ServiceNameUnavailabilityReason = "AlreadyExists" + ServiceNameUnavailabilityReasonInvalid ServiceNameUnavailabilityReason = "Invalid" +) + +func PossibleValuesForServiceNameUnavailabilityReason() []string { + return []string{ + string(ServiceNameUnavailabilityReasonAlreadyExists), + string(ServiceNameUnavailabilityReasonInvalid), + } +} + +func parseServiceNameUnavailabilityReason(input string) (*ServiceNameUnavailabilityReason, error) { + vals := map[string]ServiceNameUnavailabilityReason{ + "alreadyexists": ServiceNameUnavailabilityReasonAlreadyExists, + "invalid": ServiceNameUnavailabilityReasonInvalid, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ServiceNameUnavailabilityReason(input) + return &out, nil +} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/proxy/method_serviceschecknameavailability_autorest.go b/internal/services/healthcare/sdk/2021-06-01-preview/proxy/method_serviceschecknameavailability_autorest.go new file mode 100644 index 000000000000..b44d479fa8e6 --- /dev/null +++ b/internal/services/healthcare/sdk/2021-06-01-preview/proxy/method_serviceschecknameavailability_autorest.go @@ -0,0 +1,67 @@ +package proxy + +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" +) + +type ServicesCheckNameAvailabilityResponse struct { + HttpResponse *http.Response + Model *ServicesNameAvailabilityInfo +} + +// ServicesCheckNameAvailability ... +func (c ProxyClient) ServicesCheckNameAvailability(ctx context.Context, id commonids.SubscriptionId, input CheckNameAvailabilityParameters) (result ServicesCheckNameAvailabilityResponse, err error) { + req, err := c.preparerForServicesCheckNameAvailability(ctx, id, input) + if err != nil { + err = autorest.NewErrorWithError(err, "proxy.ProxyClient", "ServicesCheckNameAvailability", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "proxy.ProxyClient", "ServicesCheckNameAvailability", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForServicesCheckNameAvailability(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "proxy.ProxyClient", "ServicesCheckNameAvailability", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForServicesCheckNameAvailability prepares the ServicesCheckNameAvailability request. +func (c ProxyClient) preparerForServicesCheckNameAvailability(ctx context.Context, id commonids.SubscriptionId, input CheckNameAvailabilityParameters) (*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.HealthcareApis/checkNameAvailability", id.ID())), + autorest.WithJSON(input), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForServicesCheckNameAvailability handles the response to the ServicesCheckNameAvailability request. The method always +// closes the http.Response Body. +func (c ProxyClient) responderForServicesCheckNameAvailability(resp *http.Response) (result ServicesCheckNameAvailabilityResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Model), + autorest.ByClosing()) + result.HttpResponse = resp + return +} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/proxy/model_checknameavailabilityparameters.go b/internal/services/healthcare/sdk/2021-06-01-preview/proxy/model_checknameavailabilityparameters.go new file mode 100644 index 000000000000..0759b12e6f95 --- /dev/null +++ b/internal/services/healthcare/sdk/2021-06-01-preview/proxy/model_checknameavailabilityparameters.go @@ -0,0 +1,6 @@ +package proxy + +type CheckNameAvailabilityParameters struct { + Name string `json:"name"` + Type string `json:"type"` +} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/proxy/model_servicesnameavailabilityinfo.go b/internal/services/healthcare/sdk/2021-06-01-preview/proxy/model_servicesnameavailabilityinfo.go new file mode 100644 index 000000000000..1a5e4c9f2cfa --- /dev/null +++ b/internal/services/healthcare/sdk/2021-06-01-preview/proxy/model_servicesnameavailabilityinfo.go @@ -0,0 +1,7 @@ +package proxy + +type ServicesNameAvailabilityInfo struct { + Message *string `json:"message,omitempty"` + NameAvailable *bool `json:"nameAvailable,omitempty"` + Reason *ServiceNameUnavailabilityReason `json:"reason,omitempty"` +} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/proxy/version.go b/internal/services/healthcare/sdk/2021-06-01-preview/proxy/version.go new file mode 100644 index 000000000000..f29045459778 --- /dev/null +++ b/internal/services/healthcare/sdk/2021-06-01-preview/proxy/version.go @@ -0,0 +1,9 @@ +package proxy + +import "fmt" + +const defaultApiVersion = "2021-06-01-preview" + +func userAgent() string { + return fmt.Sprintf("pandora/proxy/%s", defaultApiVersion) +} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/resource/client.go b/internal/services/healthcare/sdk/2021-06-01-preview/resource/client.go new file mode 100644 index 000000000000..d9f8bbb20ce1 --- /dev/null +++ b/internal/services/healthcare/sdk/2021-06-01-preview/resource/client.go @@ -0,0 +1,15 @@ +package resource + +import "github.com/Azure/go-autorest/autorest" + +type ResourceClient struct { + Client autorest.Client + baseUri string +} + +func NewResourceClientWithBaseURI(endpoint string) ResourceClient { + return ResourceClient{ + Client: autorest.NewClientWithUserAgent(userAgent()), + baseUri: endpoint, + } +} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/resource/constants.go b/internal/services/healthcare/sdk/2021-06-01-preview/resource/constants.go new file mode 100644 index 000000000000..cf424b1eea1a --- /dev/null +++ b/internal/services/healthcare/sdk/2021-06-01-preview/resource/constants.go @@ -0,0 +1,210 @@ +package resource + +import "strings" + +type CreatedByType string + +const ( + CreatedByTypeApplication CreatedByType = "Application" + CreatedByTypeKey CreatedByType = "Key" + CreatedByTypeManagedIdentity CreatedByType = "ManagedIdentity" + CreatedByTypeUser CreatedByType = "User" +) + +func PossibleValuesForCreatedByType() []string { + return []string{ + string(CreatedByTypeApplication), + string(CreatedByTypeKey), + string(CreatedByTypeManagedIdentity), + string(CreatedByTypeUser), + } +} + +func parseCreatedByType(input string) (*CreatedByType, error) { + vals := map[string]CreatedByType{ + "application": CreatedByTypeApplication, + "key": CreatedByTypeKey, + "managedidentity": CreatedByTypeManagedIdentity, + "user": CreatedByTypeUser, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := CreatedByType(input) + return &out, nil +} + +type Kind string + +const ( + KindFhir Kind = "fhir" + KindFhirNegativeRFour Kind = "fhir-R4" + KindFhirNegativeStuThree Kind = "fhir-Stu3" +) + +func PossibleValuesForKind() []string { + return []string{ + string(KindFhir), + string(KindFhirNegativeRFour), + string(KindFhirNegativeStuThree), + } +} + +func parseKind(input string) (*Kind, error) { + vals := map[string]Kind{ + "fhir": KindFhir, + "fhir-r4": KindFhirNegativeRFour, + "fhir-stu3": KindFhirNegativeStuThree, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := Kind(input) + return &out, nil +} + +type PrivateEndpointConnectionProvisioningState string + +const ( + PrivateEndpointConnectionProvisioningStateCreating PrivateEndpointConnectionProvisioningState = "Creating" + PrivateEndpointConnectionProvisioningStateDeleting PrivateEndpointConnectionProvisioningState = "Deleting" + PrivateEndpointConnectionProvisioningStateFailed PrivateEndpointConnectionProvisioningState = "Failed" + PrivateEndpointConnectionProvisioningStateSucceeded PrivateEndpointConnectionProvisioningState = "Succeeded" +) + +func PossibleValuesForPrivateEndpointConnectionProvisioningState() []string { + return []string{ + string(PrivateEndpointConnectionProvisioningStateCreating), + string(PrivateEndpointConnectionProvisioningStateDeleting), + string(PrivateEndpointConnectionProvisioningStateFailed), + string(PrivateEndpointConnectionProvisioningStateSucceeded), + } +} + +func parsePrivateEndpointConnectionProvisioningState(input string) (*PrivateEndpointConnectionProvisioningState, error) { + vals := map[string]PrivateEndpointConnectionProvisioningState{ + "creating": PrivateEndpointConnectionProvisioningStateCreating, + "deleting": PrivateEndpointConnectionProvisioningStateDeleting, + "failed": PrivateEndpointConnectionProvisioningStateFailed, + "succeeded": PrivateEndpointConnectionProvisioningStateSucceeded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PrivateEndpointConnectionProvisioningState(input) + return &out, nil +} + +type PrivateEndpointServiceConnectionStatus string + +const ( + PrivateEndpointServiceConnectionStatusApproved PrivateEndpointServiceConnectionStatus = "Approved" + PrivateEndpointServiceConnectionStatusPending PrivateEndpointServiceConnectionStatus = "Pending" + PrivateEndpointServiceConnectionStatusRejected PrivateEndpointServiceConnectionStatus = "Rejected" +) + +func PossibleValuesForPrivateEndpointServiceConnectionStatus() []string { + return []string{ + string(PrivateEndpointServiceConnectionStatusApproved), + string(PrivateEndpointServiceConnectionStatusPending), + string(PrivateEndpointServiceConnectionStatusRejected), + } +} + +func parsePrivateEndpointServiceConnectionStatus(input string) (*PrivateEndpointServiceConnectionStatus, error) { + vals := map[string]PrivateEndpointServiceConnectionStatus{ + "approved": PrivateEndpointServiceConnectionStatusApproved, + "pending": PrivateEndpointServiceConnectionStatusPending, + "rejected": PrivateEndpointServiceConnectionStatusRejected, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PrivateEndpointServiceConnectionStatus(input) + return &out, nil +} + +type ProvisioningState string + +const ( + ProvisioningStateAccepted ProvisioningState = "Accepted" + ProvisioningStateCanceled ProvisioningState = "Canceled" + ProvisioningStateCreating ProvisioningState = "Creating" + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateDeprovisioned ProvisioningState = "Deprovisioned" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + ProvisioningStateUpdating ProvisioningState = "Updating" + ProvisioningStateVerifying ProvisioningState = "Verifying" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateAccepted), + string(ProvisioningStateCanceled), + string(ProvisioningStateCreating), + string(ProvisioningStateDeleting), + string(ProvisioningStateDeprovisioned), + string(ProvisioningStateFailed), + string(ProvisioningStateSucceeded), + string(ProvisioningStateUpdating), + string(ProvisioningStateVerifying), + } +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "accepted": ProvisioningStateAccepted, + "canceled": ProvisioningStateCanceled, + "creating": ProvisioningStateCreating, + "deleting": ProvisioningStateDeleting, + "deprovisioned": ProvisioningStateDeprovisioned, + "failed": ProvisioningStateFailed, + "succeeded": ProvisioningStateSucceeded, + "updating": ProvisioningStateUpdating, + "verifying": ProvisioningStateVerifying, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} + +type PublicNetworkAccess string + +const ( + PublicNetworkAccessDisabled PublicNetworkAccess = "Disabled" + PublicNetworkAccessEnabled PublicNetworkAccess = "Enabled" +) + +func PossibleValuesForPublicNetworkAccess() []string { + return []string{ + string(PublicNetworkAccessDisabled), + string(PublicNetworkAccessEnabled), + } +} + +func parsePublicNetworkAccess(input string) (*PublicNetworkAccess, error) { + vals := map[string]PublicNetworkAccess{ + "disabled": PublicNetworkAccessDisabled, + "enabled": PublicNetworkAccessEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PublicNetworkAccess(input) + return &out, nil +} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/resource/id_service.go b/internal/services/healthcare/sdk/2021-06-01-preview/resource/id_service.go new file mode 100644 index 000000000000..89356f6a5a16 --- /dev/null +++ b/internal/services/healthcare/sdk/2021-06-01-preview/resource/id_service.go @@ -0,0 +1,124 @@ +package resource + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +var _ resourceids.ResourceId = ServiceId{} + +// ServiceId is a struct representing the Resource ID for a Service +type ServiceId struct { + SubscriptionId string + ResourceGroupName string + ResourceName string +} + +// NewServiceID returns a new ServiceId struct +func NewServiceID(subscriptionId string, resourceGroupName string, resourceName string) ServiceId { + return ServiceId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ResourceName: resourceName, + } +} + +// ParseServiceID parses 'input' into a ServiceId +func ParseServiceID(input string) (*ServiceId, error) { + parser := resourceids.NewParserFromResourceIdType(ServiceId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := ServiceId{} + + if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { + return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) + } + + if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { + return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) + } + + if id.ResourceName, ok = parsed.Parsed["resourceName"]; !ok { + return nil, fmt.Errorf("the segment 'resourceName' was not found in the resource id %q", input) + } + + return &id, nil +} + +// ParseServiceIDInsensitively parses 'input' case-insensitively into a ServiceId +// note: this method should only be used for API response data and not user input +func ParseServiceIDInsensitively(input string) (*ServiceId, error) { + parser := resourceids.NewParserFromResourceIdType(ServiceId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := ServiceId{} + + if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { + return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) + } + + if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { + return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) + } + + if id.ResourceName, ok = parsed.Parsed["resourceName"]; !ok { + return nil, fmt.Errorf("the segment 'resourceName' was not found in the resource id %q", input) + } + + return &id, nil +} + +// ValidateServiceID checks that 'input' can be parsed as a Service ID +func ValidateServiceID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseServiceID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Service ID +func (id ServiceId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.HealthcareApis/services/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ResourceName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Service ID +func (id ServiceId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftHealthcareApis", "Microsoft.HealthcareApis", "Microsoft.HealthcareApis"), + resourceids.StaticSegment("staticServices", "services", "services"), + resourceids.UserSpecifiedSegment("resourceName", "resourceValue"), + } +} + +// String returns a human-readable description of this Service ID +func (id ServiceId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Resource Name: %q", id.ResourceName), + } + return fmt.Sprintf("Service (%s)", strings.Join(components, "\n")) +} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/resource/id_service_test.go b/internal/services/healthcare/sdk/2021-06-01-preview/resource/id_service_test.go new file mode 100644 index 000000000000..d10df20a6de0 --- /dev/null +++ b/internal/services/healthcare/sdk/2021-06-01-preview/resource/id_service_test.go @@ -0,0 +1,279 @@ +package resource + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +var _ resourceids.ResourceId = ServiceId{} + +func TestNewServiceID(t *testing.T) { + id := NewServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "resourceValue") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.ResourceName != "resourceValue" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceName'", id.ResourceName, "resourceValue") + } +} + +func TestFormatServiceID(t *testing.T) { + actual := NewServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "resourceValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/services/resourceValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseServiceID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ServiceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/services", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/services/resourceValue", + Expected: &ServiceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ResourceName: "resourceValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/services/resourceValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseServiceID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ResourceName != v.Expected.ResourceName { + t.Fatalf("Expected %q but got %q for ResourceName", v.Expected.ResourceName, actual.ResourceName) + } + + } +} + +func TestParseServiceIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ServiceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hEaLtHcArEaPiS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/services", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hEaLtHcArEaPiS/sErViCeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/services/resourceValue", + Expected: &ServiceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ResourceName: "resourceValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/services/resourceValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hEaLtHcArEaPiS/sErViCeS/rEsOuRcEvAlUe", + Expected: &ServiceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ResourceName: "rEsOuRcEvAlUe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hEaLtHcArEaPiS/sErViCeS/rEsOuRcEvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseServiceIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ResourceName != v.Expected.ResourceName { + t.Fatalf("Expected %q but got %q for ResourceName", v.Expected.ResourceName, actual.ResourceName) + } + + } +} + +func TestSegmentsForServiceId(t *testing.T) { + segments := ServiceId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ServiceId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/resource/method_servicescreateorupdate_autorest.go b/internal/services/healthcare/sdk/2021-06-01-preview/resource/method_servicescreateorupdate_autorest.go new file mode 100644 index 000000000000..2f038ae8eecf --- /dev/null +++ b/internal/services/healthcare/sdk/2021-06-01-preview/resource/method_servicescreateorupdate_autorest.go @@ -0,0 +1,75 @@ +package resource + +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" +) + +type ServicesCreateOrUpdateResponse struct { + Poller polling.LongRunningPoller + HttpResponse *http.Response +} + +// ServicesCreateOrUpdate ... +func (c ResourceClient) ServicesCreateOrUpdate(ctx context.Context, id ServiceId, input ServicesDescription) (result ServicesCreateOrUpdateResponse, err error) { + req, err := c.preparerForServicesCreateOrUpdate(ctx, id, input) + if err != nil { + err = autorest.NewErrorWithError(err, "resource.ResourceClient", "ServicesCreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = c.senderForServicesCreateOrUpdate(ctx, req) + if err != nil { + err = autorest.NewErrorWithError(err, "resource.ResourceClient", "ServicesCreateOrUpdate", result.HttpResponse, "Failure sending request") + return + } + + return +} + +// ServicesCreateOrUpdateThenPoll performs ServicesCreateOrUpdate then polls until it's completed +func (c ResourceClient) ServicesCreateOrUpdateThenPoll(ctx context.Context, id ServiceId, input ServicesDescription) error { + result, err := c.ServicesCreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing ServicesCreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(); err != nil { + return fmt.Errorf("polling after ServicesCreateOrUpdate: %+v", err) + } + + return nil +} + +// preparerForServicesCreateOrUpdate prepares the ServicesCreateOrUpdate request. +func (c ResourceClient) preparerForServicesCreateOrUpdate(ctx context.Context, id ServiceId, input ServicesDescription) (*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)) +} + +// senderForServicesCreateOrUpdate sends the ServicesCreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (c ResourceClient) senderForServicesCreateOrUpdate(ctx context.Context, req *http.Request) (future ServicesCreateOrUpdateResponse, err error) { + var resp *http.Response + resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + return + } + future.Poller, err = polling.NewLongRunningPollerFromResponse(ctx, resp, c.Client) + return +} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/resource/method_servicesdelete_autorest.go b/internal/services/healthcare/sdk/2021-06-01-preview/resource/method_servicesdelete_autorest.go new file mode 100644 index 000000000000..dbe35e0b6207 --- /dev/null +++ b/internal/services/healthcare/sdk/2021-06-01-preview/resource/method_servicesdelete_autorest.go @@ -0,0 +1,74 @@ +package resource + +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" +) + +type ServicesDeleteResponse struct { + Poller polling.LongRunningPoller + HttpResponse *http.Response +} + +// ServicesDelete ... +func (c ResourceClient) ServicesDelete(ctx context.Context, id ServiceId) (result ServicesDeleteResponse, err error) { + req, err := c.preparerForServicesDelete(ctx, id) + if err != nil { + err = autorest.NewErrorWithError(err, "resource.ResourceClient", "ServicesDelete", nil, "Failure preparing request") + return + } + + result, err = c.senderForServicesDelete(ctx, req) + if err != nil { + err = autorest.NewErrorWithError(err, "resource.ResourceClient", "ServicesDelete", result.HttpResponse, "Failure sending request") + return + } + + return +} + +// ServicesDeleteThenPoll performs ServicesDelete then polls until it's completed +func (c ResourceClient) ServicesDeleteThenPoll(ctx context.Context, id ServiceId) error { + result, err := c.ServicesDelete(ctx, id) + if err != nil { + return fmt.Errorf("performing ServicesDelete: %+v", err) + } + + if err := result.Poller.PollUntilDone(); err != nil { + return fmt.Errorf("polling after ServicesDelete: %+v", err) + } + + return nil +} + +// preparerForServicesDelete prepares the ServicesDelete request. +func (c ResourceClient) preparerForServicesDelete(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)) +} + +// senderForServicesDelete sends the ServicesDelete request. The method will close the +// http.Response Body if it receives an error. +func (c ResourceClient) senderForServicesDelete(ctx context.Context, req *http.Request) (future ServicesDeleteResponse, err error) { + var resp *http.Response + resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + return + } + future.Poller, err = polling.NewLongRunningPollerFromResponse(ctx, resp, c.Client) + return +} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/resource/method_servicesget_autorest.go b/internal/services/healthcare/sdk/2021-06-01-preview/resource/method_servicesget_autorest.go new file mode 100644 index 000000000000..6bf9442cb8a1 --- /dev/null +++ b/internal/services/healthcare/sdk/2021-06-01-preview/resource/method_servicesget_autorest.go @@ -0,0 +1,64 @@ +package resource + +import ( + "context" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +type ServicesGetResponse struct { + HttpResponse *http.Response + Model *ServicesDescription +} + +// ServicesGet ... +func (c ResourceClient) ServicesGet(ctx context.Context, id ServiceId) (result ServicesGetResponse, err error) { + req, err := c.preparerForServicesGet(ctx, id) + if err != nil { + err = autorest.NewErrorWithError(err, "resource.ResourceClient", "ServicesGet", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "resource.ResourceClient", "ServicesGet", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForServicesGet(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "resource.ResourceClient", "ServicesGet", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForServicesGet prepares the ServicesGet request. +func (c ResourceClient) preparerForServicesGet(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)) +} + +// responderForServicesGet handles the response to the ServicesGet request. The method always +// closes the http.Response Body. +func (c ResourceClient) responderForServicesGet(resp *http.Response) (result ServicesGetResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Model), + autorest.ByClosing()) + result.HttpResponse = resp + return +} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/resource/method_servicesupdate_autorest.go b/internal/services/healthcare/sdk/2021-06-01-preview/resource/method_servicesupdate_autorest.go new file mode 100644 index 000000000000..9f8acc63f12a --- /dev/null +++ b/internal/services/healthcare/sdk/2021-06-01-preview/resource/method_servicesupdate_autorest.go @@ -0,0 +1,75 @@ +package resource + +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" +) + +type ServicesUpdateResponse struct { + Poller polling.LongRunningPoller + HttpResponse *http.Response +} + +// ServicesUpdate ... +func (c ResourceClient) ServicesUpdate(ctx context.Context, id ServiceId, input ServicesPatchDescription) (result ServicesUpdateResponse, err error) { + req, err := c.preparerForServicesUpdate(ctx, id, input) + if err != nil { + err = autorest.NewErrorWithError(err, "resource.ResourceClient", "ServicesUpdate", nil, "Failure preparing request") + return + } + + result, err = c.senderForServicesUpdate(ctx, req) + if err != nil { + err = autorest.NewErrorWithError(err, "resource.ResourceClient", "ServicesUpdate", result.HttpResponse, "Failure sending request") + return + } + + return +} + +// ServicesUpdateThenPoll performs ServicesUpdate then polls until it's completed +func (c ResourceClient) ServicesUpdateThenPoll(ctx context.Context, id ServiceId, input ServicesPatchDescription) error { + result, err := c.ServicesUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing ServicesUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(); err != nil { + return fmt.Errorf("polling after ServicesUpdate: %+v", err) + } + + return nil +} + +// preparerForServicesUpdate prepares the ServicesUpdate request. +func (c ResourceClient) preparerForServicesUpdate(ctx context.Context, id ServiceId, input ServicesPatchDescription) (*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)) +} + +// senderForServicesUpdate sends the ServicesUpdate request. The method will close the +// http.Response Body if it receives an error. +func (c ResourceClient) senderForServicesUpdate(ctx context.Context, req *http.Request) (future ServicesUpdateResponse, err error) { + var resp *http.Response + resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + return + } + future.Poller, err = polling.NewLongRunningPollerFromResponse(ctx, resp, c.Client) + return +} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/resource/model_privateendpoint.go b/internal/services/healthcare/sdk/2021-06-01-preview/resource/model_privateendpoint.go new file mode 100644 index 000000000000..91d2298ebef4 --- /dev/null +++ b/internal/services/healthcare/sdk/2021-06-01-preview/resource/model_privateendpoint.go @@ -0,0 +1,5 @@ +package resource + +type PrivateEndpoint struct { + Id *string `json:"id,omitempty"` +} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/resource/model_privateendpointconnection.go b/internal/services/healthcare/sdk/2021-06-01-preview/resource/model_privateendpointconnection.go new file mode 100644 index 000000000000..8a588e9071b9 --- /dev/null +++ b/internal/services/healthcare/sdk/2021-06-01-preview/resource/model_privateendpointconnection.go @@ -0,0 +1,8 @@ +package resource + +type PrivateEndpointConnection struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateEndpointConnectionProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/resource/model_privateendpointconnectionproperties.go b/internal/services/healthcare/sdk/2021-06-01-preview/resource/model_privateendpointconnectionproperties.go new file mode 100644 index 000000000000..f2b79dce8bc5 --- /dev/null +++ b/internal/services/healthcare/sdk/2021-06-01-preview/resource/model_privateendpointconnectionproperties.go @@ -0,0 +1,7 @@ +package resource + +type PrivateEndpointConnectionProperties struct { + PrivateEndpoint *PrivateEndpoint `json:"privateEndpoint,omitempty"` + PrivateLinkServiceConnectionState PrivateLinkServiceConnectionState `json:"privateLinkServiceConnectionState"` + ProvisioningState *PrivateEndpointConnectionProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/resource/model_privatelinkserviceconnectionstate.go b/internal/services/healthcare/sdk/2021-06-01-preview/resource/model_privatelinkserviceconnectionstate.go new file mode 100644 index 000000000000..3617e3db806b --- /dev/null +++ b/internal/services/healthcare/sdk/2021-06-01-preview/resource/model_privatelinkserviceconnectionstate.go @@ -0,0 +1,7 @@ +package resource + +type PrivateLinkServiceConnectionState struct { + ActionsRequired *string `json:"actionsRequired,omitempty"` + Description *string `json:"description,omitempty"` + Status *PrivateEndpointServiceConnectionStatus `json:"status,omitempty"` +} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/resource/model_serviceaccesspolicyentry.go b/internal/services/healthcare/sdk/2021-06-01-preview/resource/model_serviceaccesspolicyentry.go new file mode 100644 index 000000000000..bb7d73d7f581 --- /dev/null +++ b/internal/services/healthcare/sdk/2021-06-01-preview/resource/model_serviceaccesspolicyentry.go @@ -0,0 +1,5 @@ +package resource + +type ServiceAccessPolicyEntry struct { + ObjectId string `json:"objectId"` +} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/resource/model_serviceacrconfigurationinfo.go b/internal/services/healthcare/sdk/2021-06-01-preview/resource/model_serviceacrconfigurationinfo.go new file mode 100644 index 000000000000..45d58c3f22c2 --- /dev/null +++ b/internal/services/healthcare/sdk/2021-06-01-preview/resource/model_serviceacrconfigurationinfo.go @@ -0,0 +1,5 @@ +package resource + +type ServiceAcrConfigurationInfo struct { + LoginServers *[]string `json:"loginServers,omitempty"` +} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/resource/model_serviceauthenticationconfigurationinfo.go b/internal/services/healthcare/sdk/2021-06-01-preview/resource/model_serviceauthenticationconfigurationinfo.go new file mode 100644 index 000000000000..b15aeecb91eb --- /dev/null +++ b/internal/services/healthcare/sdk/2021-06-01-preview/resource/model_serviceauthenticationconfigurationinfo.go @@ -0,0 +1,7 @@ +package resource + +type ServiceAuthenticationConfigurationInfo struct { + Audience *string `json:"audience,omitempty"` + Authority *string `json:"authority,omitempty"` + SmartProxyEnabled *bool `json:"smartProxyEnabled,omitempty"` +} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/resource/model_servicecorsconfigurationinfo.go b/internal/services/healthcare/sdk/2021-06-01-preview/resource/model_servicecorsconfigurationinfo.go new file mode 100644 index 000000000000..3222eb38f35f --- /dev/null +++ b/internal/services/healthcare/sdk/2021-06-01-preview/resource/model_servicecorsconfigurationinfo.go @@ -0,0 +1,9 @@ +package resource + +type ServiceCorsConfigurationInfo struct { + AllowCredentials *bool `json:"allowCredentials,omitempty"` + Headers *[]string `json:"headers,omitempty"` + MaxAge *int64 `json:"maxAge,omitempty"` + Methods *[]string `json:"methods,omitempty"` + Origins *[]string `json:"origins,omitempty"` +} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/resource/model_servicecosmosdbconfigurationinfo.go b/internal/services/healthcare/sdk/2021-06-01-preview/resource/model_servicecosmosdbconfigurationinfo.go new file mode 100644 index 000000000000..bbdfe7992e43 --- /dev/null +++ b/internal/services/healthcare/sdk/2021-06-01-preview/resource/model_servicecosmosdbconfigurationinfo.go @@ -0,0 +1,6 @@ +package resource + +type ServiceCosmosDbConfigurationInfo struct { + KeyVaultKeyUri *string `json:"keyVaultKeyUri,omitempty"` + OfferThroughput *int64 `json:"offerThroughput,omitempty"` +} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/resource/model_serviceexportconfigurationinfo.go b/internal/services/healthcare/sdk/2021-06-01-preview/resource/model_serviceexportconfigurationinfo.go new file mode 100644 index 000000000000..35ea1dbe59c1 --- /dev/null +++ b/internal/services/healthcare/sdk/2021-06-01-preview/resource/model_serviceexportconfigurationinfo.go @@ -0,0 +1,5 @@ +package resource + +type ServiceExportConfigurationInfo struct { + StorageAccountName *string `json:"storageAccountName,omitempty"` +} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/resource/model_servicesdescription.go b/internal/services/healthcare/sdk/2021-06-01-preview/resource/model_servicesdescription.go new file mode 100644 index 000000000000..94364d8f618b --- /dev/null +++ b/internal/services/healthcare/sdk/2021-06-01-preview/resource/model_servicesdescription.go @@ -0,0 +1,18 @@ +package resource + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/identity" +) + +type ServicesDescription struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Identity *identity.SystemAssigned `json:"identity,omitempty"` + Kind Kind `json:"kind"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties *ServicesProperties `json:"properties,omitempty"` + SystemData *SystemData `json:"systemData,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/resource/model_servicespatchdescription.go b/internal/services/healthcare/sdk/2021-06-01-preview/resource/model_servicespatchdescription.go new file mode 100644 index 000000000000..d1bcdfe6c558 --- /dev/null +++ b/internal/services/healthcare/sdk/2021-06-01-preview/resource/model_servicespatchdescription.go @@ -0,0 +1,6 @@ +package resource + +type ServicesPatchDescription struct { + Properties *ServicesPropertiesUpdateParameters `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/resource/model_servicesproperties.go b/internal/services/healthcare/sdk/2021-06-01-preview/resource/model_servicesproperties.go new file mode 100644 index 000000000000..83dd58e7f604 --- /dev/null +++ b/internal/services/healthcare/sdk/2021-06-01-preview/resource/model_servicesproperties.go @@ -0,0 +1,13 @@ +package resource + +type ServicesProperties struct { + AccessPolicies *[]ServiceAccessPolicyEntry `json:"accessPolicies,omitempty"` + AcrConfiguration *ServiceAcrConfigurationInfo `json:"acrConfiguration,omitempty"` + AuthenticationConfiguration *ServiceAuthenticationConfigurationInfo `json:"authenticationConfiguration,omitempty"` + CorsConfiguration *ServiceCorsConfigurationInfo `json:"corsConfiguration,omitempty"` + CosmosDbConfiguration *ServiceCosmosDbConfigurationInfo `json:"cosmosDbConfiguration,omitempty"` + ExportConfiguration *ServiceExportConfigurationInfo `json:"exportConfiguration,omitempty"` + PrivateEndpointConnections *[]PrivateEndpointConnection `json:"privateEndpointConnections,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + PublicNetworkAccess *PublicNetworkAccess `json:"publicNetworkAccess,omitempty"` +} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/resource/model_servicespropertiesupdateparameters.go b/internal/services/healthcare/sdk/2021-06-01-preview/resource/model_servicespropertiesupdateparameters.go new file mode 100644 index 000000000000..bdee5e5622b7 --- /dev/null +++ b/internal/services/healthcare/sdk/2021-06-01-preview/resource/model_servicespropertiesupdateparameters.go @@ -0,0 +1,5 @@ +package resource + +type ServicesPropertiesUpdateParameters struct { + PublicNetworkAccess *PublicNetworkAccess `json:"publicNetworkAccess,omitempty"` +} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/resource/model_systemdata.go b/internal/services/healthcare/sdk/2021-06-01-preview/resource/model_systemdata.go new file mode 100644 index 000000000000..8d282622850b --- /dev/null +++ b/internal/services/healthcare/sdk/2021-06-01-preview/resource/model_systemdata.go @@ -0,0 +1,40 @@ +package resource + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +type SystemData struct { + CreatedAt *string `json:"createdAt,omitempty"` + CreatedBy *string `json:"createdBy,omitempty"` + CreatedByType *CreatedByType `json:"createdByType,omitempty"` + LastModifiedAt *string `json:"lastModifiedAt,omitempty"` + LastModifiedBy *string `json:"lastModifiedBy,omitempty"` + LastModifiedByType *CreatedByType `json:"lastModifiedByType,omitempty"` +} + +func (o SystemData) GetCreatedAtAsTime() (*time.Time, error) { + if o.CreatedAt == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreatedAt, "2006-01-02T15:04:05Z07:00") +} + +func (o SystemData) SetCreatedAtAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreatedAt = &formatted +} + +func (o SystemData) GetLastModifiedAtAsTime() (*time.Time, error) { + if o.LastModifiedAt == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastModifiedAt, "2006-01-02T15:04:05Z07:00") +} + +func (o SystemData) SetLastModifiedAtAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastModifiedAt = &formatted +} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/resource/version.go b/internal/services/healthcare/sdk/2021-06-01-preview/resource/version.go new file mode 100644 index 000000000000..ee7683965bcd --- /dev/null +++ b/internal/services/healthcare/sdk/2021-06-01-preview/resource/version.go @@ -0,0 +1,9 @@ +package resource + +import "fmt" + +const defaultApiVersion = "2021-06-01-preview" + +func userAgent() string { + return fmt.Sprintf("pandora/resource/%s", defaultApiVersion) +} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/workspaces/client.go b/internal/services/healthcare/sdk/2021-06-01-preview/workspaces/client.go new file mode 100644 index 000000000000..bc9eafbb30e3 --- /dev/null +++ b/internal/services/healthcare/sdk/2021-06-01-preview/workspaces/client.go @@ -0,0 +1,15 @@ +package workspaces + +import "github.com/Azure/go-autorest/autorest" + +type WorkspacesClient struct { + Client autorest.Client + baseUri string +} + +func NewWorkspacesClientWithBaseURI(endpoint string) WorkspacesClient { + return WorkspacesClient{ + Client: autorest.NewClientWithUserAgent(userAgent()), + baseUri: endpoint, + } +} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/workspaces/constants.go b/internal/services/healthcare/sdk/2021-06-01-preview/workspaces/constants.go new file mode 100644 index 000000000000..40caca680578 --- /dev/null +++ b/internal/services/healthcare/sdk/2021-06-01-preview/workspaces/constants.go @@ -0,0 +1,98 @@ +package workspaces + +import "strings" + +type CreatedByType string + +const ( + CreatedByTypeApplication CreatedByType = "Application" + CreatedByTypeKey CreatedByType = "Key" + CreatedByTypeManagedIdentity CreatedByType = "ManagedIdentity" + CreatedByTypeUser CreatedByType = "User" +) + +func PossibleValuesForCreatedByType() []string { + return []string{ + string(CreatedByTypeApplication), + string(CreatedByTypeKey), + string(CreatedByTypeManagedIdentity), + string(CreatedByTypeUser), + } +} + +func parseCreatedByType(input string) (*CreatedByType, error) { + vals := map[string]CreatedByType{ + "application": CreatedByTypeApplication, + "key": CreatedByTypeKey, + "managedidentity": CreatedByTypeManagedIdentity, + "user": CreatedByTypeUser, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := CreatedByType(input) + return &out, nil +} + +type ProvisioningState string + +const ( + ProvisioningStateAccepted ProvisioningState = "Accepted" + ProvisioningStateCanceled ProvisioningState = "Canceled" + ProvisioningStateCreating ProvisioningState = "Creating" + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateDeprovisioned ProvisioningState = "Deprovisioned" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateMoving ProvisioningState = "Moving" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + ProvisioningStateSuspended ProvisioningState = "Suspended" + ProvisioningStateSystemMaintenance ProvisioningState = "SystemMaintenance" + ProvisioningStateUpdating ProvisioningState = "Updating" + ProvisioningStateVerifying ProvisioningState = "Verifying" + ProvisioningStateWarned ProvisioningState = "Warned" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateAccepted), + string(ProvisioningStateCanceled), + string(ProvisioningStateCreating), + string(ProvisioningStateDeleting), + string(ProvisioningStateDeprovisioned), + string(ProvisioningStateFailed), + string(ProvisioningStateMoving), + string(ProvisioningStateSucceeded), + string(ProvisioningStateSuspended), + string(ProvisioningStateSystemMaintenance), + string(ProvisioningStateUpdating), + string(ProvisioningStateVerifying), + string(ProvisioningStateWarned), + } +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "accepted": ProvisioningStateAccepted, + "canceled": ProvisioningStateCanceled, + "creating": ProvisioningStateCreating, + "deleting": ProvisioningStateDeleting, + "deprovisioned": ProvisioningStateDeprovisioned, + "failed": ProvisioningStateFailed, + "moving": ProvisioningStateMoving, + "succeeded": ProvisioningStateSucceeded, + "suspended": ProvisioningStateSuspended, + "systemmaintenance": ProvisioningStateSystemMaintenance, + "updating": ProvisioningStateUpdating, + "verifying": ProvisioningStateVerifying, + "warned": ProvisioningStateWarned, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/workspaces/id_workspace.go b/internal/services/healthcare/sdk/2021-06-01-preview/workspaces/id_workspace.go new file mode 100644 index 000000000000..fbf5773dda06 --- /dev/null +++ b/internal/services/healthcare/sdk/2021-06-01-preview/workspaces/id_workspace.go @@ -0,0 +1,124 @@ +package workspaces + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +var _ resourceids.ResourceId = WorkspaceId{} + +// WorkspaceId is a struct representing the Resource ID for a Workspace +type WorkspaceId struct { + SubscriptionId string + ResourceGroupName string + WorkspaceName string +} + +// NewWorkspaceID returns a new WorkspaceId struct +func NewWorkspaceID(subscriptionId string, resourceGroupName string, workspaceName string) WorkspaceId { + return WorkspaceId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + WorkspaceName: workspaceName, + } +} + +// ParseWorkspaceID parses 'input' into a WorkspaceId +func ParseWorkspaceID(input string) (*WorkspaceId, error) { + parser := resourceids.NewParserFromResourceIdType(WorkspaceId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := WorkspaceId{} + + if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { + return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) + } + + if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { + return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) + } + + if id.WorkspaceName, ok = parsed.Parsed["workspaceName"]; !ok { + return nil, fmt.Errorf("the segment 'workspaceName' was not found in the resource id %q", input) + } + + return &id, nil +} + +// ParseWorkspaceIDInsensitively parses 'input' case-insensitively into a WorkspaceId +// note: this method should only be used for API response data and not user input +func ParseWorkspaceIDInsensitively(input string) (*WorkspaceId, error) { + parser := resourceids.NewParserFromResourceIdType(WorkspaceId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := WorkspaceId{} + + if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { + return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) + } + + if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { + return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) + } + + if id.WorkspaceName, ok = parsed.Parsed["workspaceName"]; !ok { + return nil, fmt.Errorf("the segment 'workspaceName' was not found in the resource id %q", input) + } + + return &id, nil +} + +// ValidateWorkspaceID checks that 'input' can be parsed as a Workspace ID +func ValidateWorkspaceID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseWorkspaceID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Workspace ID +func (id WorkspaceId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.HealthcareApis/workspaces/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.WorkspaceName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Workspace ID +func (id WorkspaceId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftHealthcareApis", "Microsoft.HealthcareApis", "Microsoft.HealthcareApis"), + resourceids.StaticSegment("staticWorkspaces", "workspaces", "workspaces"), + resourceids.UserSpecifiedSegment("workspaceName", "workspaceValue"), + } +} + +// String returns a human-readable description of this Workspace ID +func (id WorkspaceId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Workspace Name: %q", id.WorkspaceName), + } + return fmt.Sprintf("Workspace (%s)", strings.Join(components, "\n")) +} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/workspaces/id_workspace_test.go b/internal/services/healthcare/sdk/2021-06-01-preview/workspaces/id_workspace_test.go new file mode 100644 index 000000000000..892b4435322e --- /dev/null +++ b/internal/services/healthcare/sdk/2021-06-01-preview/workspaces/id_workspace_test.go @@ -0,0 +1,279 @@ +package workspaces + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +var _ resourceids.ResourceId = WorkspaceId{} + +func TestNewWorkspaceID(t *testing.T) { + id := NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceValue") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.WorkspaceName != "workspaceValue" { + t.Fatalf("Expected %q but got %q for Segment 'WorkspaceName'", id.WorkspaceName, "workspaceValue") + } +} + +func TestFormatWorkspaceID(t *testing.T) { + actual := NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/workspaces/workspaceValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseWorkspaceID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *WorkspaceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/workspaces", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/workspaces/workspaceValue", + Expected: &WorkspaceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/workspaces/workspaceValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseWorkspaceID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + } +} + +func TestParseWorkspaceIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *WorkspaceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hEaLtHcArEaPiS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/workspaces", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hEaLtHcArEaPiS/wOrKsPaCeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/workspaces/workspaceValue", + Expected: &WorkspaceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/workspaces/workspaceValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hEaLtHcArEaPiS/wOrKsPaCeS/wOrKsPaCeVaLuE", + Expected: &WorkspaceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + WorkspaceName: "wOrKsPaCeVaLuE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hEaLtHcArEaPiS/wOrKsPaCeS/wOrKsPaCeVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseWorkspaceIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + } +} + +func TestSegmentsForWorkspaceId(t *testing.T) { + segments := WorkspaceId{}.Segments() + if len(segments) == 0 { + t.Fatalf("WorkspaceId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/workspaces/method_createorupdate_autorest.go b/internal/services/healthcare/sdk/2021-06-01-preview/workspaces/method_createorupdate_autorest.go new file mode 100644 index 000000000000..d354068f8614 --- /dev/null +++ b/internal/services/healthcare/sdk/2021-06-01-preview/workspaces/method_createorupdate_autorest.go @@ -0,0 +1,75 @@ +package workspaces + +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" +) + +type CreateOrUpdateResponse struct { + Poller polling.LongRunningPoller + HttpResponse *http.Response +} + +// CreateOrUpdate ... +func (c WorkspacesClient) CreateOrUpdate(ctx context.Context, id WorkspaceId, input Workspace) (result CreateOrUpdateResponse, err error) { + req, err := c.preparerForCreateOrUpdate(ctx, id, input) + if err != nil { + err = autorest.NewErrorWithError(err, "workspaces.WorkspacesClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = c.senderForCreateOrUpdate(ctx, req) + if err != nil { + err = autorest.NewErrorWithError(err, "workspaces.WorkspacesClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") + return + } + + return +} + +// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed +func (c WorkspacesClient) CreateOrUpdateThenPoll(ctx context.Context, id WorkspaceId, input Workspace) 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 WorkspacesClient) preparerForCreateOrUpdate(ctx context.Context, id WorkspaceId, input Workspace) (*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 WorkspacesClient) senderForCreateOrUpdate(ctx context.Context, req *http.Request) (future CreateOrUpdateResponse, err error) { + var resp *http.Response + resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + return + } + future.Poller, err = polling.NewLongRunningPollerFromResponse(ctx, resp, c.Client) + return +} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/workspaces/method_delete_autorest.go b/internal/services/healthcare/sdk/2021-06-01-preview/workspaces/method_delete_autorest.go new file mode 100644 index 000000000000..c6053b007c77 --- /dev/null +++ b/internal/services/healthcare/sdk/2021-06-01-preview/workspaces/method_delete_autorest.go @@ -0,0 +1,74 @@ +package workspaces + +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" +) + +type DeleteResponse struct { + Poller polling.LongRunningPoller + HttpResponse *http.Response +} + +// Delete ... +func (c WorkspacesClient) Delete(ctx context.Context, id WorkspaceId) (result DeleteResponse, err error) { + req, err := c.preparerForDelete(ctx, id) + if err != nil { + err = autorest.NewErrorWithError(err, "workspaces.WorkspacesClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = c.senderForDelete(ctx, req) + if err != nil { + err = autorest.NewErrorWithError(err, "workspaces.WorkspacesClient", "Delete", result.HttpResponse, "Failure sending request") + return + } + + return +} + +// DeleteThenPoll performs Delete then polls until it's completed +func (c WorkspacesClient) DeleteThenPoll(ctx context.Context, id WorkspaceId) 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 WorkspacesClient) preparerForDelete(ctx context.Context, id WorkspaceId) (*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 WorkspacesClient) senderForDelete(ctx context.Context, req *http.Request) (future DeleteResponse, err error) { + var resp *http.Response + resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + return + } + future.Poller, err = polling.NewLongRunningPollerFromResponse(ctx, resp, c.Client) + return +} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/workspaces/method_get_autorest.go b/internal/services/healthcare/sdk/2021-06-01-preview/workspaces/method_get_autorest.go new file mode 100644 index 000000000000..2402fbbfb144 --- /dev/null +++ b/internal/services/healthcare/sdk/2021-06-01-preview/workspaces/method_get_autorest.go @@ -0,0 +1,64 @@ +package workspaces + +import ( + "context" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +type GetResponse struct { + HttpResponse *http.Response + Model *Workspace +} + +// Get ... +func (c WorkspacesClient) Get(ctx context.Context, id WorkspaceId) (result GetResponse, err error) { + req, err := c.preparerForGet(ctx, id) + if err != nil { + err = autorest.NewErrorWithError(err, "workspaces.WorkspacesClient", "Get", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "workspaces.WorkspacesClient", "Get", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForGet(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "workspaces.WorkspacesClient", "Get", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForGet prepares the Get request. +func (c WorkspacesClient) preparerForGet(ctx context.Context, id WorkspaceId) (*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 WorkspacesClient) responderForGet(resp *http.Response) (result GetResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Model), + autorest.ByClosing()) + result.HttpResponse = resp + return +} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/workspaces/method_listbyresourcegroup_autorest.go b/internal/services/healthcare/sdk/2021-06-01-preview/workspaces/method_listbyresourcegroup_autorest.go new file mode 100644 index 000000000000..1ae247c0aa96 --- /dev/null +++ b/internal/services/healthcare/sdk/2021-06-01-preview/workspaces/method_listbyresourcegroup_autorest.go @@ -0,0 +1,184 @@ +package workspaces + +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" +) + +type ListByResourceGroupResponse struct { + HttpResponse *http.Response + Model *[]Workspace + + nextLink *string + nextPageFunc func(ctx context.Context, nextLink string) (ListByResourceGroupResponse, error) +} + +type ListByResourceGroupCompleteResult struct { + Items []Workspace +} + +func (r ListByResourceGroupResponse) HasMore() bool { + return r.nextLink != nil +} + +func (r ListByResourceGroupResponse) LoadMore(ctx context.Context) (resp ListByResourceGroupResponse, err error) { + if !r.HasMore() { + err = fmt.Errorf("no more pages returned") + return + } + return r.nextPageFunc(ctx, *r.nextLink) +} + +// ListByResourceGroup ... +func (c WorkspacesClient) ListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (resp ListByResourceGroupResponse, err error) { + req, err := c.preparerForListByResourceGroup(ctx, id) + if err != nil { + err = autorest.NewErrorWithError(err, "workspaces.WorkspacesClient", "ListByResourceGroup", nil, "Failure preparing request") + return + } + + resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "workspaces.WorkspacesClient", "ListByResourceGroup", resp.HttpResponse, "Failure sending request") + return + } + + resp, err = c.responderForListByResourceGroup(resp.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "workspaces.WorkspacesClient", "ListByResourceGroup", resp.HttpResponse, "Failure responding to request") + return + } + return +} + +// ListByResourceGroupComplete retrieves all of the results into a single object +func (c WorkspacesClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (ListByResourceGroupCompleteResult, error) { + return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, WorkspacePredicate{}) +} + +// ListByResourceGroupCompleteMatchingPredicate retrieves all of the results and then applied the predicate +func (c WorkspacesClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate WorkspacePredicate) (resp ListByResourceGroupCompleteResult, err error) { + items := make([]Workspace, 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 +} + +// preparerForListByResourceGroup prepares the ListByResourceGroup request. +func (c WorkspacesClient) 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.HealthcareApis/workspaces", id.ID())), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// preparerForListByResourceGroupWithNextLink prepares the ListByResourceGroup request with the given nextLink token. +func (c WorkspacesClient) 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 WorkspacesClient) responderForListByResourceGroup(resp *http.Response) (result ListByResourceGroupResponse, err error) { + type page struct { + Values []Workspace `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 ListByResourceGroupResponse, err error) { + req, err := c.preparerForListByResourceGroupWithNextLink(ctx, nextLink) + if err != nil { + err = autorest.NewErrorWithError(err, "workspaces.WorkspacesClient", "ListByResourceGroup", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "workspaces.WorkspacesClient", "ListByResourceGroup", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForListByResourceGroup(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "workspaces.WorkspacesClient", "ListByResourceGroup", result.HttpResponse, "Failure responding to request") + return + } + + return + } + } + return +} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/workspaces/method_listbysubscription_autorest.go b/internal/services/healthcare/sdk/2021-06-01-preview/workspaces/method_listbysubscription_autorest.go new file mode 100644 index 000000000000..0c5834156c71 --- /dev/null +++ b/internal/services/healthcare/sdk/2021-06-01-preview/workspaces/method_listbysubscription_autorest.go @@ -0,0 +1,184 @@ +package workspaces + +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" +) + +type ListBySubscriptionResponse struct { + HttpResponse *http.Response + Model *[]Workspace + + nextLink *string + nextPageFunc func(ctx context.Context, nextLink string) (ListBySubscriptionResponse, error) +} + +type ListBySubscriptionCompleteResult struct { + Items []Workspace +} + +func (r ListBySubscriptionResponse) HasMore() bool { + return r.nextLink != nil +} + +func (r ListBySubscriptionResponse) LoadMore(ctx context.Context) (resp ListBySubscriptionResponse, err error) { + if !r.HasMore() { + err = fmt.Errorf("no more pages returned") + return + } + return r.nextPageFunc(ctx, *r.nextLink) +} + +// ListBySubscription ... +func (c WorkspacesClient) ListBySubscription(ctx context.Context, id commonids.SubscriptionId) (resp ListBySubscriptionResponse, err error) { + req, err := c.preparerForListBySubscription(ctx, id) + if err != nil { + err = autorest.NewErrorWithError(err, "workspaces.WorkspacesClient", "ListBySubscription", nil, "Failure preparing request") + return + } + + resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "workspaces.WorkspacesClient", "ListBySubscription", resp.HttpResponse, "Failure sending request") + return + } + + resp, err = c.responderForListBySubscription(resp.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "workspaces.WorkspacesClient", "ListBySubscription", resp.HttpResponse, "Failure responding to request") + return + } + return +} + +// ListBySubscriptionComplete retrieves all of the results into a single object +func (c WorkspacesClient) ListBySubscriptionComplete(ctx context.Context, id commonids.SubscriptionId) (ListBySubscriptionCompleteResult, error) { + return c.ListBySubscriptionCompleteMatchingPredicate(ctx, id, WorkspacePredicate{}) +} + +// ListBySubscriptionCompleteMatchingPredicate retrieves all of the results and then applied the predicate +func (c WorkspacesClient) ListBySubscriptionCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate WorkspacePredicate) (resp ListBySubscriptionCompleteResult, err error) { + items := make([]Workspace, 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 +} + +// preparerForListBySubscription prepares the ListBySubscription request. +func (c WorkspacesClient) 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.HealthcareApis/workspaces", id.ID())), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// preparerForListBySubscriptionWithNextLink prepares the ListBySubscription request with the given nextLink token. +func (c WorkspacesClient) 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 WorkspacesClient) responderForListBySubscription(resp *http.Response) (result ListBySubscriptionResponse, err error) { + type page struct { + Values []Workspace `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 ListBySubscriptionResponse, err error) { + req, err := c.preparerForListBySubscriptionWithNextLink(ctx, nextLink) + if err != nil { + err = autorest.NewErrorWithError(err, "workspaces.WorkspacesClient", "ListBySubscription", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "workspaces.WorkspacesClient", "ListBySubscription", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForListBySubscription(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "workspaces.WorkspacesClient", "ListBySubscription", result.HttpResponse, "Failure responding to request") + return + } + + return + } + } + return +} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/workspaces/method_update_autorest.go b/internal/services/healthcare/sdk/2021-06-01-preview/workspaces/method_update_autorest.go new file mode 100644 index 000000000000..d60952d2207d --- /dev/null +++ b/internal/services/healthcare/sdk/2021-06-01-preview/workspaces/method_update_autorest.go @@ -0,0 +1,75 @@ +package workspaces + +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" +) + +type UpdateResponse struct { + Poller polling.LongRunningPoller + HttpResponse *http.Response +} + +// Update ... +func (c WorkspacesClient) Update(ctx context.Context, id WorkspaceId, input ResourceTags) (result UpdateResponse, err error) { + req, err := c.preparerForUpdate(ctx, id, input) + if err != nil { + err = autorest.NewErrorWithError(err, "workspaces.WorkspacesClient", "Update", nil, "Failure preparing request") + return + } + + result, err = c.senderForUpdate(ctx, req) + if err != nil { + err = autorest.NewErrorWithError(err, "workspaces.WorkspacesClient", "Update", result.HttpResponse, "Failure sending request") + return + } + + return +} + +// UpdateThenPoll performs Update then polls until it's completed +func (c WorkspacesClient) UpdateThenPoll(ctx context.Context, id WorkspaceId, input ResourceTags) 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 WorkspacesClient) preparerForUpdate(ctx context.Context, id WorkspaceId, input ResourceTags) (*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 WorkspacesClient) senderForUpdate(ctx context.Context, req *http.Request) (future UpdateResponse, err error) { + var resp *http.Response + resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + return + } + future.Poller, err = polling.NewLongRunningPollerFromResponse(ctx, resp, c.Client) + return +} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/workspaces/model_resourcetags.go b/internal/services/healthcare/sdk/2021-06-01-preview/workspaces/model_resourcetags.go new file mode 100644 index 000000000000..550bf57173a5 --- /dev/null +++ b/internal/services/healthcare/sdk/2021-06-01-preview/workspaces/model_resourcetags.go @@ -0,0 +1,5 @@ +package workspaces + +type ResourceTags struct { + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/workspaces/model_systemdata.go b/internal/services/healthcare/sdk/2021-06-01-preview/workspaces/model_systemdata.go new file mode 100644 index 000000000000..c7da0009ca71 --- /dev/null +++ b/internal/services/healthcare/sdk/2021-06-01-preview/workspaces/model_systemdata.go @@ -0,0 +1,40 @@ +package workspaces + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +type SystemData struct { + CreatedAt *string `json:"createdAt,omitempty"` + CreatedBy *string `json:"createdBy,omitempty"` + CreatedByType *CreatedByType `json:"createdByType,omitempty"` + LastModifiedAt *string `json:"lastModifiedAt,omitempty"` + LastModifiedBy *string `json:"lastModifiedBy,omitempty"` + LastModifiedByType *CreatedByType `json:"lastModifiedByType,omitempty"` +} + +func (o SystemData) GetCreatedAtAsTime() (*time.Time, error) { + if o.CreatedAt == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreatedAt, "2006-01-02T15:04:05Z07:00") +} + +func (o SystemData) SetCreatedAtAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreatedAt = &formatted +} + +func (o SystemData) GetLastModifiedAtAsTime() (*time.Time, error) { + if o.LastModifiedAt == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastModifiedAt, "2006-01-02T15:04:05Z07:00") +} + +func (o SystemData) SetLastModifiedAtAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastModifiedAt = &formatted +} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/workspaces/model_workspace.go b/internal/services/healthcare/sdk/2021-06-01-preview/workspaces/model_workspace.go new file mode 100644 index 000000000000..940ed6e98599 --- /dev/null +++ b/internal/services/healthcare/sdk/2021-06-01-preview/workspaces/model_workspace.go @@ -0,0 +1,12 @@ +package workspaces + +type Workspace struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *WorkspaceProperties `json:"properties,omitempty"` + SystemData *SystemData `json:"systemData,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/workspaces/model_workspaceproperties.go b/internal/services/healthcare/sdk/2021-06-01-preview/workspaces/model_workspaceproperties.go new file mode 100644 index 000000000000..ed0d90894d8e --- /dev/null +++ b/internal/services/healthcare/sdk/2021-06-01-preview/workspaces/model_workspaceproperties.go @@ -0,0 +1,5 @@ +package workspaces + +type WorkspaceProperties struct { + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/workspaces/predicates.go b/internal/services/healthcare/sdk/2021-06-01-preview/workspaces/predicates.go new file mode 100644 index 000000000000..50ea8247215e --- /dev/null +++ b/internal/services/healthcare/sdk/2021-06-01-preview/workspaces/predicates.go @@ -0,0 +1,34 @@ +package workspaces + +type WorkspacePredicate struct { + Etag *string + Id *string + Location *string + Name *string + Type *string +} + +func (p WorkspacePredicate) Matches(input Workspace) bool { + + if p.Etag != nil && (input.Etag == nil && *p.Etag != *input.Etag) { + return false + } + + if p.Id != nil && (input.Id == nil && *p.Id != *input.Id) { + return false + } + + if p.Location != nil && (input.Location == nil && *p.Location != *input.Location) { + return false + } + + if p.Name != nil && (input.Name == nil && *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil && *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/workspaces/version.go b/internal/services/healthcare/sdk/2021-06-01-preview/workspaces/version.go new file mode 100644 index 000000000000..8029fe6f0a14 --- /dev/null +++ b/internal/services/healthcare/sdk/2021-06-01-preview/workspaces/version.go @@ -0,0 +1,9 @@ +package workspaces + +import "fmt" + +const defaultApiVersion = "2021-06-01-preview" + +func userAgent() string { + return fmt.Sprintf("pandora/workspaces/%s", defaultApiVersion) +} From 8f2d7bf74bdda708ee1ad4ff0473a35d456d158a Mon Sep 17 00:00:00 2001 From: xiaxin18 Date: Thu, 17 Feb 2022 14:04:45 +0800 Subject: [PATCH 02/22] dicom service --- .../healthcare_apis_dicom_data_source.go | 102 ++++++++++ .../healthcare_apis_dicom_resource.go | 177 ++++++++++++++++-- internal/services/healthcare/registration.go | 6 +- 3 files changed, 267 insertions(+), 18 deletions(-) create mode 100644 internal/services/healthcare/healthcare_apis_dicom_data_source.go diff --git a/internal/services/healthcare/healthcare_apis_dicom_data_source.go b/internal/services/healthcare/healthcare_apis_dicom_data_source.go new file mode 100644 index 000000000000..f559526dc9ca --- /dev/null +++ b/internal/services/healthcare/healthcare_apis_dicom_data_source.go @@ -0,0 +1,102 @@ +package healthcare + +import ( + "fmt" + "time" + + "github.com/hashicorp/go-azure-helpers/lang/response" + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema" + "github.com/hashicorp/go-azure-helpers/resourcemanager/tags" + "github.com/hashicorp/terraform-provider-azurerm/helpers/azure" + "github.com/hashicorp/terraform-provider-azurerm/internal/clients" + "github.com/hashicorp/terraform-provider-azurerm/internal/location" + dicomService "github.com/hashicorp/terraform-provider-azurerm/internal/services/healthcare/sdk/2021-06-01-preview/dicomservices" + "github.com/hashicorp/terraform-provider-azurerm/internal/services/healthcare/sdk/2021-06-01-preview/workspaces" + "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" + "github.com/hashicorp/terraform-provider-azurerm/internal/tf/validation" + "github.com/hashicorp/terraform-provider-azurerm/internal/timeouts" +) + +func dataSourceHealthcareApisDicomService() *pluginsdk.Resource{ + return &pluginsdk.Resource{ + Read: dataSourceHealthcareApisDicomServiceRead, + + Timeouts: &pluginsdk.ResourceTimeout{ + Read: pluginsdk.DefaultTimeout(5*time.Minute), + }, + + Schema: map[string]*pluginsdk.Schema{ + "name":{ + Type: pluginsdk.TypeString, + Required: true, + ValidateFunc: validation.StringIsNotEmpty, + }, + + "location":azure.SchemaLocationForDataSource(), + + "authentication_configuration": { + Type: pluginsdk.TypeList, + Computed: true, + Elem: &pluginsdk.Resource{ + Schema: map[string]*pluginsdk.Schema{ + "authority": { + Type: pluginsdk.TypeString, + Computed: true, + }, + "audience": { + Type: pluginsdk.TypeSet, + Computed: true, + Elem: &pluginsdk.Schema{Type: pluginsdk.TypeString}, + }, + }, + }, + }, + + "service_url": { + Type: pluginsdk.TypeString, + Computed: true, + }, + + "tags": commonschema.Tags(), + }, + } +} + +func dataSourceHealthcareApisDicomServiceRead(d *pluginsdk.ResourceData, meta interface{}) error { + client := meta.(*clients.Client).HealthCare.HealthcareWorkspaceDicomServiceClient + ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d) + defer cancel() + + id, err := dicomService.ParseDicomServiceIDInsensitively(d.Id()) + if err != nil { + return fmt.Errorf("parsing Dicom service error: %+v", err) + } + + resp, err := client.Get(ctx, *id) + if err != nil { + if response.WasNotFound(resp.HttpResponse) { + d.SetId("") + return nil + } + return fmt.Errorf("retrieving %s: %+v", *id, err) + } + + d.Set("name", id.DicomServiceName) + workspaceId := workspaces.NewWorkspaceID(id.SubscriptionId, id.ResourceGroupName, id.WorkspaceName) + d.Set("workspace_id", workspaceId.ID()) + + if model := resp.Model; model != nil { + d.Set("location", location.NormalizeNilable(model.Location)) + + if props := model.Properties; props != nil { + d.Set("authentication_configuration", flattenDicomAuthentication(props.AuthenticationConfiguration)) + d.Set("service_url", props.ServiceUrl) + } + + if err := tags.FlattenAndSet(d, model.Tags); err != nil { + return err + } + } + + return nil +} \ No newline at end of file diff --git a/internal/services/healthcare/healthcare_apis_dicom_resource.go b/internal/services/healthcare/healthcare_apis_dicom_resource.go index 150b45d726b3..8ca95546cd68 100644 --- a/internal/services/healthcare/healthcare_apis_dicom_resource.go +++ b/internal/services/healthcare/healthcare_apis_dicom_resource.go @@ -1,18 +1,24 @@ package healthcare import ( + "context" "fmt" + "log" + "strconv" + "time" + "github.com/hashicorp/go-azure-helpers/lang/response" "github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema" + "github.com/hashicorp/go-azure-helpers/resourcemanager/tags" "github.com/hashicorp/terraform-provider-azurerm/helpers/azure" "github.com/hashicorp/terraform-provider-azurerm/helpers/tf" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" + "github.com/hashicorp/terraform-provider-azurerm/internal/location" dicomService "github.com/hashicorp/terraform-provider-azurerm/internal/services/healthcare/sdk/2021-06-01-preview/dicomservices" "github.com/hashicorp/terraform-provider-azurerm/internal/services/healthcare/sdk/2021-06-01-preview/workspaces" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/internal/timeouts" - "log" - "time" + "github.com/hashicorp/terraform-provider-azurerm/utils" ) func resourceHealthcareApisDicomService() *pluginsdk.Resource { @@ -53,27 +59,27 @@ func resourceHealthcareApisDicomService() *pluginsdk.Resource { "authentication_configuration": { Type: pluginsdk.TypeList, - Optional: true, - MaxItems: 1, + Computed: true, Elem: &pluginsdk.Resource{ Schema: map[string]*pluginsdk.Schema{ "authority": { Type: pluginsdk.TypeString, - Optional: true, - //todo: must follow https://login.microsoft.com/tenantid + Computed: true, }, "audience": { - Type: pluginsdk.TypeString, - Optional: true, - }, - "smart_proxy_enabled": { - Type: pluginsdk.TypeBool, - Optional: true, + Type: pluginsdk.TypeSet, + Computed: true, + Elem: &pluginsdk.Schema{Type: pluginsdk.TypeString}, }, }, }, }, + "service_url": { + Type: pluginsdk.TypeString, + Computed: true, + }, + "tags": commonschema.Tags(), }, } @@ -105,17 +111,156 @@ func resourceHealthcareApisDicomServiceCreateUpdate(d *pluginsdk.ResourceData, m } } - //parameters := dicomService.DicomService{ - // Name: utils.String(dicomServiceId.DicomServiceName), - // Location: utils.String(azure.NormalizeLocation(d.Get("location").(string))), - //} + parameters := dicomService.DicomService{ + Name: utils.String(dicomServiceId.DicomServiceName), + Location: utils.String(azure.NormalizeLocation(d.Get("location").(string))), + } + + if err := client.CreateOrUpdateThenPoll(ctx, dicomServiceId, parameters); err != nil { + return fmt.Errorf("creating %s: %+v", dicomServiceId, err) + } + + d.SetId(dicomServiceId.ID()) return resourceHealthcareApisDicomServiceRead(d, meta) } func resourceHealthcareApisDicomServiceRead(d *pluginsdk.ResourceData, meta interface{}) error { + client := meta.(*clients.Client).HealthCare.HealthcareWorkspaceDicomServiceClient + ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d) + defer cancel() + + id, err := dicomService.ParseDicomServiceIDInsensitively(d.Id()) + if err != nil { + return fmt.Errorf("parsing Dicom service error: %+v", err) + } + + resp, err := client.Get(ctx, *id) + if err != nil { + if response.WasNotFound(resp.HttpResponse) { + d.SetId("") + return nil + } + return fmt.Errorf("retrieving %s: %+v", *id, err) + } + + d.Set("name", id.DicomServiceName) + workspaceId := workspaces.NewWorkspaceID(id.SubscriptionId, id.ResourceGroupName, id.WorkspaceName) + d.Set("workspace_id", workspaceId.ID()) + + if model := resp.Model; model != nil { + d.Set("location", location.NormalizeNilable(model.Location)) + + if props := model.Properties; props != nil { + d.Set("authentication_configuration", flattenDicomAuthentication(props.AuthenticationConfiguration)) + d.Set("service_url", props.ServiceUrl) + } + + if err := tags.FlattenAndSet(d, model.Tags); err != nil { + return err + } + } + return nil } func resourceHealthcareApisDicomServiceDelete(d *pluginsdk.ResourceData, meta interface{}) error { + client := meta.(*clients.Client).HealthCare.HealthcareWorkspaceDicomServiceClient + ctx, cancel := timeouts.ForDelete(meta.(*clients.Client).StopContext, d) + defer cancel() + + id, err := dicomService.ParseDicomServiceID(d.Id()) + if err != nil { + return fmt.Errorf("parsing Dicom service error: %+v", err) + } + + future, err := client.Delete(ctx, *id) + if err != nil { + if response.WasNotFound(future.HttpResponse) { + return nil + } + return fmt.Errorf("deleting %s: %+v", *id, err) + } + return waitForHealthcareApiDicomServiceToBeDelete(ctx, client, *id) +} + +func waitForHealthcareApiDicomServiceToBeDelete(ctx context.Context, client *dicomService.DicomServicesClient, id dicomService.DicomServiceId) error { + deadline, ok := ctx.Deadline() + if !ok { + return fmt.Errorf("context has no deadline") + } + + log.Printf("[DEBUG] Waiting for %s to be deleted...", id) + stateConf := &pluginsdk.StateChangeConf{ + Pending: []string{"200"}, + Target: []string{"404"}, + Refresh: healthcareApiDicomServiceStateCodeRefreshFunc(ctx, client, id), + Timeout: time.Until(deadline), + } + + if _, err := stateConf.WaitForStateContext(ctx); err != nil { + return fmt.Errorf("waiting for %s to be deleted: %+v", id, err) + } + return nil } + +func healthcareApiDicomServiceStateCodeRefreshFunc(ctx context.Context, client *dicomService.DicomServicesClient, id dicomService.DicomServiceId) pluginsdk.StateRefreshFunc{ + return func()(interface{}, string, error) { + res, err := client.Get(ctx, id) + if res.HttpResponse != nil { + log.Printf("Retrieving %s returned status %d", id, res.HttpResponse.StatusCode) + } + + if err != nil { + if response.WasNotFound(res.HttpResponse) { + return res, strconv.Itoa(res.HttpResponse.StatusCode), nil + } + return nil, "", fmt.Errorf("polling for the status of %s: %+v", id, err) + } + return res, strconv.Itoa(res.HttpResponse.StatusCode), nil + } +} + +func expandDicomAuthentication(input []interface{}) *dicomService.DicomServiceAuthenticationConfiguration { + if len(input) == 0 { + return &dicomService.DicomServiceAuthenticationConfiguration{} + } + + authConfiguration := input[0].(map[string]interface{}) + authority := authConfiguration["authority"].(string) + + audienceList := make([]string, 0) + if v := authConfiguration["audience"]; v != nil { + audienceRawData := v.(*pluginsdk.Set).List() + for _, audience := range audienceRawData { + url := audience.(string) + audienceList = append(audienceList, url) + } + } + + return &dicomService.DicomServiceAuthenticationConfiguration{ + Authority: &authority, + Audiences: &audienceList, + } +} + +func flattenDicomAuthentication(input *dicomService.DicomServiceAuthenticationConfiguration) []interface{} { + if input == nil { + return []interface{}{} + } + + authBlock := make(map[string]interface{}) + if input.Authority != nil { + authBlock["authority"] = *input.Authority + } + + audience := make([]interface{}, 0) + if input.Audiences != nil { + for _, data := range *input.Audiences { + audience = append(audience, data) + } + } + authBlock["audience"] = pluginsdk.NewSet(pluginsdk.HashString, audience) + + return []interface{}{authBlock} +} diff --git a/internal/services/healthcare/registration.go b/internal/services/healthcare/registration.go index bba2df08bc85..2ec8aa2e1ad7 100644 --- a/internal/services/healthcare/registration.go +++ b/internal/services/healthcare/registration.go @@ -28,13 +28,15 @@ func (r Registration) WebsiteCategories() []string { // SupportedDataSources returns the supported Data Sources supported by this Service func (r Registration) SupportedDataSources() map[string]*pluginsdk.Resource { return map[string]*pluginsdk.Resource{ - "azurerm_healthcare_service": dataSourceHealthcareService(), + "azurerm_healthcare_service": dataSourceHealthcareService(), + "azurerm_healthcare_apis_dicom_service": dataSourceHealthcareApisDicomService(), } } // SupportedResources returns the supported Resources supported by this Service func (r Registration) SupportedResources() map[string]*pluginsdk.Resource { return map[string]*pluginsdk.Resource{ - "azurerm_healthcare_service": resourceHealthcareService(), + "azurerm_healthcare_service": resourceHealthcareService(), + "azurerm_healthcare_apis_dicom_service": resourceHealthcareApisDicomService(), } } From f6f46d719734623a01caa8a15586b367c4b8c481 Mon Sep 17 00:00:00 2001 From: xiaxyi Date: Tue, 15 Mar 2022 20:33:10 +0800 Subject: [PATCH 03/22] hc/dicom --- internal/services/healthcare/client/client.go | 4 +- .../healthcare_apis_dicom_data_source.go | 59 +- .../healthcare_apis_dicom_resource.go | 199 +- .../healthcare_apis_dicom_resource_test.go | 30 + .../healthcare/parse/dicom_service.go | 75 + .../healthcare/parse/dicom_service_test.go | 128 + .../services/healthcare/parse/workspace.go | 69 + .../healthcare/parse/workspace_test.go | 112 + internal/services/healthcare/resourceids.go | 2 + .../healthcare/validate/dicom_name.go | 16 + .../healthcare/validate/dicom_service_id.go | 23 + .../validate/dicom_service_id_test.go | 88 + .../healthcare/validate/workspace_id.go | 23 + .../healthcare/validate/workspace_id_test.go | 76 + .../2021-11-01/healthcareapis/CHANGELOG.md | 2 + .../mgmt/2021-11-01/healthcareapis/_meta.json | 11 + .../mgmt/2021-11-01/healthcareapis/client.go | 41 + .../healthcareapis/dicomservices.go | 543 +++ .../mgmt/2021-11-01/healthcareapis/enums.go | 279 ++ .../healthcareapis/fhirdestinations.go | 167 + .../2021-11-01/healthcareapis/fhirservices.go | 552 +++ .../iotconnectorfhirdestination.go | 337 ++ .../healthcareapis/iotconnectors.go | 543 +++ .../mgmt/2021-11-01/healthcareapis/models.go | 3810 +++++++++++++++++ .../healthcareapis/operationresults.go | 108 + .../2021-11-01/healthcareapis/operations.go | 140 + .../privateendpointconnections.go | 401 ++ .../healthcareapis/privatelinkresources.go | 209 + .../2021-11-01/healthcareapis/services.go | 729 ++++ .../mgmt/2021-11-01/healthcareapis/version.go | 19 + .../workspaceprivateendpointconnections.go | 399 ++ .../workspaceprivatelinkresources.go | 209 + .../2021-11-01/healthcareapis/workspaces.go | 631 +++ vendor/modules.txt | 1 + 34 files changed, 9903 insertions(+), 132 deletions(-) create mode 100644 internal/services/healthcare/healthcare_apis_dicom_resource_test.go create mode 100644 internal/services/healthcare/parse/dicom_service.go create mode 100644 internal/services/healthcare/parse/dicom_service_test.go create mode 100644 internal/services/healthcare/parse/workspace.go create mode 100644 internal/services/healthcare/parse/workspace_test.go create mode 100644 internal/services/healthcare/validate/dicom_name.go create mode 100644 internal/services/healthcare/validate/dicom_service_id.go create mode 100644 internal/services/healthcare/validate/dicom_service_id_test.go create mode 100644 internal/services/healthcare/validate/workspace_id.go create mode 100644 internal/services/healthcare/validate/workspace_id_test.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/healthcareapis/mgmt/2021-11-01/healthcareapis/CHANGELOG.md create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/healthcareapis/mgmt/2021-11-01/healthcareapis/_meta.json create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/healthcareapis/mgmt/2021-11-01/healthcareapis/client.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/healthcareapis/mgmt/2021-11-01/healthcareapis/dicomservices.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/healthcareapis/mgmt/2021-11-01/healthcareapis/enums.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/healthcareapis/mgmt/2021-11-01/healthcareapis/fhirdestinations.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/healthcareapis/mgmt/2021-11-01/healthcareapis/fhirservices.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/healthcareapis/mgmt/2021-11-01/healthcareapis/iotconnectorfhirdestination.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/healthcareapis/mgmt/2021-11-01/healthcareapis/iotconnectors.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/healthcareapis/mgmt/2021-11-01/healthcareapis/models.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/healthcareapis/mgmt/2021-11-01/healthcareapis/operationresults.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/healthcareapis/mgmt/2021-11-01/healthcareapis/operations.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/healthcareapis/mgmt/2021-11-01/healthcareapis/privateendpointconnections.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/healthcareapis/mgmt/2021-11-01/healthcareapis/privatelinkresources.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/healthcareapis/mgmt/2021-11-01/healthcareapis/services.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/healthcareapis/mgmt/2021-11-01/healthcareapis/version.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/healthcareapis/mgmt/2021-11-01/healthcareapis/workspaceprivateendpointconnections.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/healthcareapis/mgmt/2021-11-01/healthcareapis/workspaceprivatelinkresources.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/healthcareapis/mgmt/2021-11-01/healthcareapis/workspaces.go diff --git a/internal/services/healthcare/client/client.go b/internal/services/healthcare/client/client.go index 52a344a1bef5..1a7591ef1c2d 100644 --- a/internal/services/healthcare/client/client.go +++ b/internal/services/healthcare/client/client.go @@ -3,7 +3,7 @@ package client import ( healthcare "github.com/Azure/azure-sdk-for-go/services/healthcareapis/mgmt/2020-03-30/healthcareapis" "github.com/hashicorp/terraform-provider-azurerm/internal/common" - healthcareWorkspaceDicom "github.com/hashicorp/terraform-provider-azurerm/internal/services/healthcare/sdk/2021-06-01-preview/dicomservices" + healthcareWorkspaceDicom "github.com/Azure/azure-sdk-for-go/services/healthcareapis/mgmt/2021-11-01/healthcareapis" ) @@ -16,7 +16,7 @@ func NewClient(o *common.ClientOptions) *Client { HealthcareServiceClient := healthcare.NewServicesClientWithBaseURI(o.ResourceManagerEndpoint, o.SubscriptionId) o.ConfigureClient(&HealthcareServiceClient.Client, o.ResourceManagerAuthorizer) - HealthcareWorkspaceDicomServiceClient := healthcareWorkspaceDicom.NewDicomServicesClientWithBaseURI(o.ResourceManagerEndpoint) + HealthcareWorkspaceDicomServiceClient := healthcareWorkspaceDicom.NewDicomServicesClientWithBaseURI(o.ResourceManagerEndpoint, o.SubscriptionId) o.ConfigureClient(&HealthcareWorkspaceDicomServiceClient.Client, o.ResourceManagerAuthorizer) return &Client{ diff --git a/internal/services/healthcare/healthcare_apis_dicom_data_source.go b/internal/services/healthcare/healthcare_apis_dicom_data_source.go index f559526dc9ca..4b7299a8f859 100644 --- a/internal/services/healthcare/healthcare_apis_dicom_data_source.go +++ b/internal/services/healthcare/healthcare_apis_dicom_data_source.go @@ -4,35 +4,35 @@ import ( "fmt" "time" - "github.com/hashicorp/go-azure-helpers/lang/response" "github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema" - "github.com/hashicorp/go-azure-helpers/resourcemanager/tags" "github.com/hashicorp/terraform-provider-azurerm/helpers/azure" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" - "github.com/hashicorp/terraform-provider-azurerm/internal/location" - dicomService "github.com/hashicorp/terraform-provider-azurerm/internal/services/healthcare/sdk/2021-06-01-preview/dicomservices" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/healthcare/sdk/2021-06-01-preview/workspaces" + "github.com/hashicorp/terraform-provider-azurerm/internal/services/healthcare/parse" + "github.com/hashicorp/terraform-provider-azurerm/internal/services/healthcare/validate" + "github.com/hashicorp/terraform-provider-azurerm/internal/tags" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" - "github.com/hashicorp/terraform-provider-azurerm/internal/tf/validation" "github.com/hashicorp/terraform-provider-azurerm/internal/timeouts" + "github.com/hashicorp/terraform-provider-azurerm/utils" ) -func dataSourceHealthcareApisDicomService() *pluginsdk.Resource{ +func dataSourceHealthcareApisDicomService() *pluginsdk.Resource { return &pluginsdk.Resource{ Read: dataSourceHealthcareApisDicomServiceRead, Timeouts: &pluginsdk.ResourceTimeout{ - Read: pluginsdk.DefaultTimeout(5*time.Minute), + Read: pluginsdk.DefaultTimeout(5 * time.Minute), }, Schema: map[string]*pluginsdk.Schema{ - "name":{ - Type: pluginsdk.TypeString, - Required: true, - ValidateFunc: validation.StringIsNotEmpty, + "name": { + Type: pluginsdk.TypeString, + Required: true, + ValidateFunc: validate.DicomServiceName(), }, - "location":azure.SchemaLocationForDataSource(), + "location": commonschema.LocationComputed(), + + "resource_group_name": azure.SchemaResourceGroupName(), "authentication_configuration": { Type: pluginsdk.TypeList, @@ -44,7 +44,7 @@ func dataSourceHealthcareApisDicomService() *pluginsdk.Resource{ Computed: true, }, "audience": { - Type: pluginsdk.TypeSet, + Type: pluginsdk.TypeList, Computed: true, Elem: &pluginsdk.Schema{Type: pluginsdk.TypeString}, }, @@ -67,36 +67,37 @@ func dataSourceHealthcareApisDicomServiceRead(d *pluginsdk.ResourceData, meta in ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d) defer cancel() - id, err := dicomService.ParseDicomServiceIDInsensitively(d.Id()) + id, err := parse.DicomServiceID(d.Id()) if err != nil { return fmt.Errorf("parsing Dicom service error: %+v", err) } - resp, err := client.Get(ctx, *id) + resp, err := client.Get(ctx, id.ResourceGroup, id.WorkspaceName, id.Name) if err != nil { - if response.WasNotFound(resp.HttpResponse) { + if utils.ResponseWasNotFound(resp.Response) { d.SetId("") return nil } return fmt.Errorf("retrieving %s: %+v", *id, err) } - d.Set("name", id.DicomServiceName) - workspaceId := workspaces.NewWorkspaceID(id.SubscriptionId, id.ResourceGroupName, id.WorkspaceName) + d.Set("name", id.Name) + workspaceId := parse.NewWorkspaceID(id.SubscriptionId, id.ResourceGroup, id.WorkspaceName) d.Set("workspace_id", workspaceId.ID()) - if model := resp.Model; model != nil { - d.Set("location", location.NormalizeNilable(model.Location)) + if resp.Location != nil { + d.Set("location", azure.NormalizeLocation(*resp.Location)) + } - if props := model.Properties; props != nil { - d.Set("authentication_configuration", flattenDicomAuthentication(props.AuthenticationConfiguration)) - d.Set("service_url", props.ServiceUrl) - } + if props := resp.DicomServiceProperties; props != nil { + d.Set("authentication_configuration", flattenDicomAuthentication(props.AuthenticationConfiguration)) + d.Set("private_endpoint_connection", flattenDicomServicePrivateEndpoint(props.PrivateEndpointConnections)) + d.Set("service_url", props.ServiceURL) + } - if err := tags.FlattenAndSet(d, model.Tags); err != nil { - return err - } + if err := tags.FlattenAndSet(d, resp.Tags); err != nil { + return err } return nil -} \ No newline at end of file +} diff --git a/internal/services/healthcare/healthcare_apis_dicom_resource.go b/internal/services/healthcare/healthcare_apis_dicom_resource.go index 8ca95546cd68..4780728cc1c4 100644 --- a/internal/services/healthcare/healthcare_apis_dicom_resource.go +++ b/internal/services/healthcare/healthcare_apis_dicom_resource.go @@ -1,21 +1,18 @@ package healthcare import ( - "context" "fmt" "log" - "strconv" "time" - "github.com/hashicorp/go-azure-helpers/lang/response" + "github.com/Azure/azure-sdk-for-go/services/healthcareapis/mgmt/2021-11-01/healthcareapis" "github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema" - "github.com/hashicorp/go-azure-helpers/resourcemanager/tags" "github.com/hashicorp/terraform-provider-azurerm/helpers/azure" "github.com/hashicorp/terraform-provider-azurerm/helpers/tf" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" - "github.com/hashicorp/terraform-provider-azurerm/internal/location" - dicomService "github.com/hashicorp/terraform-provider-azurerm/internal/services/healthcare/sdk/2021-06-01-preview/dicomservices" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/healthcare/sdk/2021-06-01-preview/workspaces" + "github.com/hashicorp/terraform-provider-azurerm/internal/services/healthcare/parse" + "github.com/hashicorp/terraform-provider-azurerm/internal/services/healthcare/validate" + "github.com/hashicorp/terraform-provider-azurerm/internal/tags" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/internal/timeouts" "github.com/hashicorp/terraform-provider-azurerm/utils" @@ -36,30 +33,36 @@ func resourceHealthcareApisDicomService() *pluginsdk.Resource { }, Importer: pluginsdk.ImporterValidatingResourceId(func(id string) error { - _, err := dicomService.ParseDicomServiceID(id) + _, err := parse.DicomServiceID(id) return err }), Schema: map[string]*pluginsdk.Schema{ "name": { - Type: pluginsdk.TypeString, - Required: true, - ForceNew: true, - //todo check the validation func + Type: pluginsdk.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: validate.DicomServiceName(), }, "workspace_id": { Type: pluginsdk.TypeString, Required: true, ForceNew: true, - ValidateFunc: workspaces.ValidateWorkspaceID, + ValidateFunc: validate.WorkspaceID, }, "location": azure.SchemaLocation(), + "public_network_access_enabled": { + Type: pluginsdk.TypeBool, + Optional: true, + Default: true, + }, + "authentication_configuration": { Type: pluginsdk.TypeList, - Computed: true, + Optional: true, Elem: &pluginsdk.Resource{ Schema: map[string]*pluginsdk.Schema{ "authority": { @@ -75,6 +78,24 @@ func resourceHealthcareApisDicomService() *pluginsdk.Resource { }, }, + "private_endpoint_connection": { + Type: pluginsdk.TypeSet, + Computed: true, + Elem: &pluginsdk.Resource{ + Schema: map[string]*pluginsdk.Schema{ + "name": { + Type: pluginsdk.TypeString, + Computed: true, + }, + + "id": { + Type: pluginsdk.TypeString, + Computed: true, + }, + }, + }, + }, + "service_url": { Type: pluginsdk.TypeString, Computed: true, @@ -91,33 +112,48 @@ func resourceHealthcareApisDicomServiceCreateUpdate(d *pluginsdk.ResourceData, m defer cancel() log.Printf("[INFO] preparing arguments for AzureRM Healthcare Dicom Service creation.") - workspace, err := workspaces.ParseWorkspaceIDInsensitively(d.Get("workspace_id").(string)) + workspace, err := parse.WorkspaceID(d.Get("workspace_id").(string)) if err != nil { return fmt.Errorf("parsing healthcare workspace error: %+v", err) } - dicomServiceId := dicomService.NewDicomServiceID(workspace.SubscriptionId, workspace.ResourceGroupName, workspace.WorkspaceName, d.Get("name").(string)) + dicomServiceId := parse.NewDicomServiceID(workspace.SubscriptionId, workspace.ResourceGroup, workspace.Name, d.Get("name").(string)) if d.IsNewResource() { - existing, err := client.Get(ctx, dicomServiceId) + existing, err := client.Get(ctx, dicomServiceId.ResourceGroup, dicomServiceId.WorkspaceName, dicomServiceId.Name) if err != nil { - if !response.WasNotFound(existing.HttpResponse) { + if !utils.ResponseWasNotFound(existing.Response) { return fmt.Errorf("checking for presense of existing %s: %+v", dicomServiceId, err) } } - if existing.Model != nil { + if !utils.ResponseWasNotFound(existing.Response) { return tf.ImportAsExistsError("azurerm_healthcareapis_dicom_service", dicomServiceId.ID()) } } - parameters := dicomService.DicomService{ - Name: utils.String(dicomServiceId.DicomServiceName), + t := d.Get("tags").(map[string]interface{}) + + publicNetworkAccess := healthcareapis.PublicNetworkAccessEnabled + if !d.Get("public_network_access_enabled").(bool) { + publicNetworkAccess = healthcareapis.PublicNetworkAccessDisabled + } + + parameters := healthcareapis.DicomService{ Location: utils.String(azure.NormalizeLocation(d.Get("location").(string))), + Tags: tags.Expand(t), + DicomServiceProperties: &healthcareapis.DicomServiceProperties{ + PublicNetworkAccess: publicNetworkAccess, + }, } - if err := client.CreateOrUpdateThenPoll(ctx, dicomServiceId, parameters); err != nil { - return fmt.Errorf("creating %s: %+v", dicomServiceId, err) + future, err := client.CreateOrUpdate(ctx, dicomServiceId.ResourceGroup, dicomServiceId.WorkspaceName, dicomServiceId.Name, parameters) + if err != nil { + return fmt.Errorf("creating/updating %s: %+v", dicomServiceId, err) + } + + if err = future.WaitForCompletionRef(ctx, client.Client); err != nil { + return fmt.Errorf("waiting for creation/update %s: %+v", dicomServiceId, err) } d.SetId(dicomServiceId.ID()) @@ -129,35 +165,36 @@ func resourceHealthcareApisDicomServiceRead(d *pluginsdk.ResourceData, meta inte ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d) defer cancel() - id, err := dicomService.ParseDicomServiceIDInsensitively(d.Id()) + id, err := parse.DicomServiceID(d.Id()) if err != nil { return fmt.Errorf("parsing Dicom service error: %+v", err) } - resp, err := client.Get(ctx, *id) + resp, err := client.Get(ctx, id.ResourceGroup, id.WorkspaceName, id.Name) if err != nil { - if response.WasNotFound(resp.HttpResponse) { + if utils.ResponseWasNotFound(resp.Response) { d.SetId("") return nil } return fmt.Errorf("retrieving %s: %+v", *id, err) } - d.Set("name", id.DicomServiceName) - workspaceId := workspaces.NewWorkspaceID(id.SubscriptionId, id.ResourceGroupName, id.WorkspaceName) + d.Set("name", id.Name) + workspaceId := parse.NewWorkspaceID(id.SubscriptionId, id.ResourceGroup, id.WorkspaceName) d.Set("workspace_id", workspaceId.ID()) - if model := resp.Model; model != nil { - d.Set("location", location.NormalizeNilable(model.Location)) + if resp.Location != nil { + d.Set("location", azure.NormalizeLocation(*resp.Location)) + } - if props := model.Properties; props != nil { - d.Set("authentication_configuration", flattenDicomAuthentication(props.AuthenticationConfiguration)) - d.Set("service_url", props.ServiceUrl) - } + if props := resp.DicomServiceProperties; props != nil { + d.Set("authentication_configuration", flattenDicomAuthentication(props.AuthenticationConfiguration)) + d.Set("private_endpoint_connection", flattenDicomServicePrivateEndpoint(props.PrivateEndpointConnections)) + d.Set("service_url", props.ServiceURL) + } - if err := tags.FlattenAndSet(d, model.Tags); err != nil { - return err - } + if err := tags.FlattenAndSet(d, resp.Tags); err != nil { + return err } return nil @@ -168,83 +205,24 @@ func resourceHealthcareApisDicomServiceDelete(d *pluginsdk.ResourceData, meta in ctx, cancel := timeouts.ForDelete(meta.(*clients.Client).StopContext, d) defer cancel() - id, err := dicomService.ParseDicomServiceID(d.Id()) + id, err := parse.DicomServiceID(d.Id()) if err != nil { return fmt.Errorf("parsing Dicom service error: %+v", err) } - future, err := client.Delete(ctx, *id) + future, err := client.Delete(ctx, id.ResourceGroup, id.Name, id.WorkspaceName) if err != nil { - if response.WasNotFound(future.HttpResponse) { - return nil - } return fmt.Errorf("deleting %s: %+v", *id, err) } - return waitForHealthcareApiDicomServiceToBeDelete(ctx, client, *id) -} - -func waitForHealthcareApiDicomServiceToBeDelete(ctx context.Context, client *dicomService.DicomServicesClient, id dicomService.DicomServiceId) error { - deadline, ok := ctx.Deadline() - if !ok { - return fmt.Errorf("context has no deadline") - } - log.Printf("[DEBUG] Waiting for %s to be deleted...", id) - stateConf := &pluginsdk.StateChangeConf{ - Pending: []string{"200"}, - Target: []string{"404"}, - Refresh: healthcareApiDicomServiceStateCodeRefreshFunc(ctx, client, id), - Timeout: time.Until(deadline), - } - - if _, err := stateConf.WaitForStateContext(ctx); err != nil { - return fmt.Errorf("waiting for %s to be deleted: %+v", id, err) + if err = future.WaitForCompletionRef(ctx, client.Client); err != nil { + return fmt.Errorf("waiting for deletion of %s: %+v", *id, err) } return nil } -func healthcareApiDicomServiceStateCodeRefreshFunc(ctx context.Context, client *dicomService.DicomServicesClient, id dicomService.DicomServiceId) pluginsdk.StateRefreshFunc{ - return func()(interface{}, string, error) { - res, err := client.Get(ctx, id) - if res.HttpResponse != nil { - log.Printf("Retrieving %s returned status %d", id, res.HttpResponse.StatusCode) - } - - if err != nil { - if response.WasNotFound(res.HttpResponse) { - return res, strconv.Itoa(res.HttpResponse.StatusCode), nil - } - return nil, "", fmt.Errorf("polling for the status of %s: %+v", id, err) - } - return res, strconv.Itoa(res.HttpResponse.StatusCode), nil - } -} - -func expandDicomAuthentication(input []interface{}) *dicomService.DicomServiceAuthenticationConfiguration { - if len(input) == 0 { - return &dicomService.DicomServiceAuthenticationConfiguration{} - } - - authConfiguration := input[0].(map[string]interface{}) - authority := authConfiguration["authority"].(string) - - audienceList := make([]string, 0) - if v := authConfiguration["audience"]; v != nil { - audienceRawData := v.(*pluginsdk.Set).List() - for _, audience := range audienceRawData { - url := audience.(string) - audienceList = append(audienceList, url) - } - } - - return &dicomService.DicomServiceAuthenticationConfiguration{ - Authority: &authority, - Audiences: &audienceList, - } -} - -func flattenDicomAuthentication(input *dicomService.DicomServiceAuthenticationConfiguration) []interface{} { +func flattenDicomAuthentication(input *healthcareapis.DicomServiceAuthenticationConfiguration) []interface{} { if input == nil { return []interface{}{} } @@ -264,3 +242,22 @@ func flattenDicomAuthentication(input *dicomService.DicomServiceAuthenticationCo return []interface{}{authBlock} } + +func flattenDicomServicePrivateEndpoint(input *[]healthcareapis.PrivateEndpointConnection) []interface{} { + results := make([]interface{}, 0) + if input == nil { + return results + } + + for _, endpoint := range *input { + result := map[string]interface{}{} + if endpoint.Name != nil { + result["name"] = *endpoint.Name + } + + if endpoint.ID != nil { + result["id"] = *endpoint.ID + } + } + return results +} diff --git a/internal/services/healthcare/healthcare_apis_dicom_resource_test.go b/internal/services/healthcare/healthcare_apis_dicom_resource_test.go new file mode 100644 index 000000000000..4c7609031c7c --- /dev/null +++ b/internal/services/healthcare/healthcare_apis_dicom_resource_test.go @@ -0,0 +1,30 @@ +package healthcare_test + +import ( + "fmt" + "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance" +) + +type HealthCareApisDicomResource struct{} + +func (HealthCareApisDicomResource) basic (data acceptance.TestData) string { + return fmt.Sprintf(` +provider "azurerm" { + features {} +} + +resource "azurerm_resource_group" "test" { + name = "acctestRG-hcwk-%d" + location = "%s" +} + +resource "azurerm_healthcare_apis_dicom_service" "test"{ + name = "acctest-dicom%d" + workspace_id = "/subscriptions/85b3dbca-5974-4067-9669-67a141095a76/resourceGroups/xiaxintestrg-healthcare/providers/Microsoft.HealthcareApis/workspaces/xiaxintestworkspace" + location = "east us" + public_network_access_enabled = false +} +`, data.RandomInteger, data.Locations.Primary, data.RandomIntOfLength(8)) +} + + diff --git a/internal/services/healthcare/parse/dicom_service.go b/internal/services/healthcare/parse/dicom_service.go new file mode 100644 index 000000000000..6309633f0cc0 --- /dev/null +++ b/internal/services/healthcare/parse/dicom_service.go @@ -0,0 +1,75 @@ +package parse + +// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +type DicomServiceId struct { + SubscriptionId string + ResourceGroup string + WorkspaceName string + Name string +} + +func NewDicomServiceID(subscriptionId, resourceGroup, workspaceName, name string) DicomServiceId { + return DicomServiceId{ + SubscriptionId: subscriptionId, + ResourceGroup: resourceGroup, + WorkspaceName: workspaceName, + Name: name, + } +} + +func (id DicomServiceId) String() string { + segments := []string{ + fmt.Sprintf("Name %q", id.Name), + fmt.Sprintf("Workspace Name %q", id.WorkspaceName), + fmt.Sprintf("Resource Group %q", id.ResourceGroup), + } + segmentsStr := strings.Join(segments, " / ") + return fmt.Sprintf("%s: (%s)", "Dicom Service", segmentsStr) +} + +func (id DicomServiceId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.HealthcareApis/workspaces/%s/dicomservices/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroup, id.WorkspaceName, id.Name) +} + +// DicomServiceID parses a DicomService ID into an DicomServiceId struct +func DicomServiceID(input string) (*DicomServiceId, error) { + id, err := resourceids.ParseAzureResourceID(input) + if err != nil { + return nil, err + } + + resourceId := DicomServiceId{ + SubscriptionId: id.SubscriptionID, + ResourceGroup: id.ResourceGroup, + } + + if resourceId.SubscriptionId == "" { + return nil, fmt.Errorf("ID was missing the 'subscriptions' element") + } + + if resourceId.ResourceGroup == "" { + return nil, fmt.Errorf("ID was missing the 'resourceGroups' element") + } + + if resourceId.WorkspaceName, err = id.PopSegment("workspaces"); err != nil { + return nil, err + } + if resourceId.Name, err = id.PopSegment("dicomservices"); err != nil { + return nil, err + } + + if err := id.ValidateNoEmptySegments(input); err != nil { + return nil, err + } + + return &resourceId, nil +} diff --git a/internal/services/healthcare/parse/dicom_service_test.go b/internal/services/healthcare/parse/dicom_service_test.go new file mode 100644 index 000000000000..473490011e54 --- /dev/null +++ b/internal/services/healthcare/parse/dicom_service_test.go @@ -0,0 +1,128 @@ +package parse + +// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +var _ resourceids.Id = DicomServiceId{} + +func TestDicomServiceIDFormatter(t *testing.T) { + actual := NewDicomServiceID("12345678-1234-9876-4563-123456789012", "group1", "workspace1", "service1").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/group1/providers/Microsoft.HealthcareApis/workspaces/workspace1/dicomservices/service1" + if actual != expected { + t.Fatalf("Expected %q but got %q", expected, actual) + } +} + +func TestDicomServiceID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DicomServiceId + }{ + + { + // empty + Input: "", + Error: true, + }, + + { + // missing SubscriptionId + Input: "/", + Error: true, + }, + + { + // missing value for SubscriptionId + Input: "/subscriptions/", + Error: true, + }, + + { + // missing ResourceGroup + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", + Error: true, + }, + + { + // missing value for ResourceGroup + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", + Error: true, + }, + + { + // missing WorkspaceName + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/group1/providers/Microsoft.HealthcareApis/", + Error: true, + }, + + { + // missing value for WorkspaceName + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/group1/providers/Microsoft.HealthcareApis/workspaces/", + Error: true, + }, + + { + // missing Name + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/group1/providers/Microsoft.HealthcareApis/workspaces/workspace1/", + Error: true, + }, + + { + // missing value for Name + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/group1/providers/Microsoft.HealthcareApis/workspaces/workspace1/dicomservices/", + Error: true, + }, + + { + // valid + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/group1/providers/Microsoft.HealthcareApis/workspaces/workspace1/dicomservices/service1", + Expected: &DicomServiceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroup: "group1", + WorkspaceName: "workspace1", + Name: "service1", + }, + }, + + { + // upper-cased + Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/GROUP1/PROVIDERS/MICROSOFT.HEALTHCAREAPIS/WORKSPACES/WORKSPACE1/DICOMSERVICES/SERVICE1", + Error: true, + }, + } + + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := DicomServiceID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %s", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + if actual.ResourceGroup != v.Expected.ResourceGroup { + t.Fatalf("Expected %q but got %q for ResourceGroup", v.Expected.ResourceGroup, actual.ResourceGroup) + } + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + if actual.Name != v.Expected.Name { + t.Fatalf("Expected %q but got %q for Name", v.Expected.Name, actual.Name) + } + } +} diff --git a/internal/services/healthcare/parse/workspace.go b/internal/services/healthcare/parse/workspace.go new file mode 100644 index 000000000000..5bacfa4aad96 --- /dev/null +++ b/internal/services/healthcare/parse/workspace.go @@ -0,0 +1,69 @@ +package parse + +// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +type WorkspaceId struct { + SubscriptionId string + ResourceGroup string + Name string +} + +func NewWorkspaceID(subscriptionId, resourceGroup, name string) WorkspaceId { + return WorkspaceId{ + SubscriptionId: subscriptionId, + ResourceGroup: resourceGroup, + Name: name, + } +} + +func (id WorkspaceId) String() string { + segments := []string{ + fmt.Sprintf("Name %q", id.Name), + fmt.Sprintf("Resource Group %q", id.ResourceGroup), + } + segmentsStr := strings.Join(segments, " / ") + return fmt.Sprintf("%s: (%s)", "Workspace", segmentsStr) +} + +func (id WorkspaceId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.HealthcareApis/workspaces/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroup, id.Name) +} + +// WorkspaceID parses a Workspace ID into an WorkspaceId struct +func WorkspaceID(input string) (*WorkspaceId, error) { + id, err := resourceids.ParseAzureResourceID(input) + if err != nil { + return nil, err + } + + resourceId := WorkspaceId{ + SubscriptionId: id.SubscriptionID, + ResourceGroup: id.ResourceGroup, + } + + if resourceId.SubscriptionId == "" { + return nil, fmt.Errorf("ID was missing the 'subscriptions' element") + } + + if resourceId.ResourceGroup == "" { + return nil, fmt.Errorf("ID was missing the 'resourceGroups' element") + } + + if resourceId.Name, err = id.PopSegment("workspaces"); err != nil { + return nil, err + } + + if err := id.ValidateNoEmptySegments(input); err != nil { + return nil, err + } + + return &resourceId, nil +} diff --git a/internal/services/healthcare/parse/workspace_test.go b/internal/services/healthcare/parse/workspace_test.go new file mode 100644 index 000000000000..955a5c56fa12 --- /dev/null +++ b/internal/services/healthcare/parse/workspace_test.go @@ -0,0 +1,112 @@ +package parse + +// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +var _ resourceids.Id = WorkspaceId{} + +func TestWorkspaceIDFormatter(t *testing.T) { + actual := NewWorkspaceID("12345678-1234-9876-4563-123456789012", "group1", "workspace1").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/group1/providers/Microsoft.HealthcareApis/workspaces/workspace1" + if actual != expected { + t.Fatalf("Expected %q but got %q", expected, actual) + } +} + +func TestWorkspaceID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *WorkspaceId + }{ + + { + // empty + Input: "", + Error: true, + }, + + { + // missing SubscriptionId + Input: "/", + Error: true, + }, + + { + // missing value for SubscriptionId + Input: "/subscriptions/", + Error: true, + }, + + { + // missing ResourceGroup + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", + Error: true, + }, + + { + // missing value for ResourceGroup + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", + Error: true, + }, + + { + // missing Name + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/group1/providers/Microsoft.HealthcareApis/", + Error: true, + }, + + { + // missing value for Name + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/group1/providers/Microsoft.HealthcareApis/workspaces/", + Error: true, + }, + + { + // valid + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/group1/providers/Microsoft.HealthcareApis/workspaces/workspace1", + Expected: &WorkspaceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroup: "group1", + Name: "workspace1", + }, + }, + + { + // upper-cased + Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/GROUP1/PROVIDERS/MICROSOFT.HEALTHCAREAPIS/WORKSPACES/WORKSPACE1", + Error: true, + }, + } + + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := WorkspaceID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %s", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + if actual.ResourceGroup != v.Expected.ResourceGroup { + t.Fatalf("Expected %q but got %q for ResourceGroup", v.Expected.ResourceGroup, actual.ResourceGroup) + } + if actual.Name != v.Expected.Name { + t.Fatalf("Expected %q but got %q for Name", v.Expected.Name, actual.Name) + } + } +} diff --git a/internal/services/healthcare/resourceids.go b/internal/services/healthcare/resourceids.go index 1b5375fbea28..b8b2510c7aa4 100644 --- a/internal/services/healthcare/resourceids.go +++ b/internal/services/healthcare/resourceids.go @@ -1,3 +1,5 @@ package healthcare //go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=Service -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/group1/providers/Microsoft.HealthcareApis/services/service1 +//go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=Workspace -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/group1/providers/Microsoft.HealthcareApis/workspaces/workspace1 +//go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=DicomService -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/group1/providers/Microsoft.HealthcareApis/workspaces/workspace1/dicomservices/service1 diff --git a/internal/services/healthcare/validate/dicom_name.go b/internal/services/healthcare/validate/dicom_name.go new file mode 100644 index 000000000000..201db25ff37f --- /dev/null +++ b/internal/services/healthcare/validate/dicom_name.go @@ -0,0 +1,16 @@ +package validate + +import ( + "regexp" + + "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" + "github.com/hashicorp/terraform-provider-azurerm/internal/tf/validation" +) + +// DicomServiceName validates Dicom Service names +func DicomServiceName() pluginsdk.SchemaValidateFunc { + return validation.StringMatch( + regexp.MustCompile(`^[0-9a-zA-Z][-0-9a-zA-Z]{1,22}[0-9a-zA-Z]$`), + `The service name must start with a letter or number. The account name can contain letters, numbers, and dashes. The final character must be a letter or a number. The service name length must be from 3 to 24 characters.`, + ) +} diff --git a/internal/services/healthcare/validate/dicom_service_id.go b/internal/services/healthcare/validate/dicom_service_id.go new file mode 100644 index 000000000000..74ed2ef78449 --- /dev/null +++ b/internal/services/healthcare/validate/dicom_service_id.go @@ -0,0 +1,23 @@ +package validate + +// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten + +import ( + "fmt" + + "github.com/hashicorp/terraform-provider-azurerm/internal/services/healthcare/parse" +) + +func DicomServiceID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := parse.DicomServiceID(v); err != nil { + errors = append(errors, err) + } + + return +} diff --git a/internal/services/healthcare/validate/dicom_service_id_test.go b/internal/services/healthcare/validate/dicom_service_id_test.go new file mode 100644 index 000000000000..606a234bb022 --- /dev/null +++ b/internal/services/healthcare/validate/dicom_service_id_test.go @@ -0,0 +1,88 @@ +package validate + +// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten + +import "testing" + +func TestDicomServiceID(t *testing.T) { + cases := []struct { + Input string + Valid bool + }{ + + { + // empty + Input: "", + Valid: false, + }, + + { + // missing SubscriptionId + Input: "/", + Valid: false, + }, + + { + // missing value for SubscriptionId + Input: "/subscriptions/", + Valid: false, + }, + + { + // missing ResourceGroup + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", + Valid: false, + }, + + { + // missing value for ResourceGroup + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", + Valid: false, + }, + + { + // missing WorkspaceName + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/group1/providers/Microsoft.HealthcareApis/", + Valid: false, + }, + + { + // missing value for WorkspaceName + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/group1/providers/Microsoft.HealthcareApis/workspaces/", + Valid: false, + }, + + { + // missing Name + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/group1/providers/Microsoft.HealthcareApis/workspaces/workspace1/", + Valid: false, + }, + + { + // missing value for Name + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/group1/providers/Microsoft.HealthcareApis/workspaces/workspace1/dicomservices/", + Valid: false, + }, + + { + // valid + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/group1/providers/Microsoft.HealthcareApis/workspaces/workspace1/dicomservices/service1", + Valid: true, + }, + + { + // upper-cased + Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/GROUP1/PROVIDERS/MICROSOFT.HEALTHCAREAPIS/WORKSPACES/WORKSPACE1/DICOMSERVICES/SERVICE1", + Valid: false, + }, + } + for _, tc := range cases { + t.Logf("[DEBUG] Testing Value %s", tc.Input) + _, errors := DicomServiceID(tc.Input, "test") + valid := len(errors) == 0 + + if tc.Valid != valid { + t.Fatalf("Expected %t but got %t", tc.Valid, valid) + } + } +} diff --git a/internal/services/healthcare/validate/workspace_id.go b/internal/services/healthcare/validate/workspace_id.go new file mode 100644 index 000000000000..2a5a61d9ef87 --- /dev/null +++ b/internal/services/healthcare/validate/workspace_id.go @@ -0,0 +1,23 @@ +package validate + +// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten + +import ( + "fmt" + + "github.com/hashicorp/terraform-provider-azurerm/internal/services/healthcare/parse" +) + +func WorkspaceID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := parse.WorkspaceID(v); err != nil { + errors = append(errors, err) + } + + return +} diff --git a/internal/services/healthcare/validate/workspace_id_test.go b/internal/services/healthcare/validate/workspace_id_test.go new file mode 100644 index 000000000000..566e24e629c7 --- /dev/null +++ b/internal/services/healthcare/validate/workspace_id_test.go @@ -0,0 +1,76 @@ +package validate + +// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten + +import "testing" + +func TestWorkspaceID(t *testing.T) { + cases := []struct { + Input string + Valid bool + }{ + + { + // empty + Input: "", + Valid: false, + }, + + { + // missing SubscriptionId + Input: "/", + Valid: false, + }, + + { + // missing value for SubscriptionId + Input: "/subscriptions/", + Valid: false, + }, + + { + // missing ResourceGroup + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/", + Valid: false, + }, + + { + // missing value for ResourceGroup + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/", + Valid: false, + }, + + { + // missing Name + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/group1/providers/Microsoft.HealthcareApis/", + Valid: false, + }, + + { + // missing value for Name + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/group1/providers/Microsoft.HealthcareApis/workspaces/", + Valid: false, + }, + + { + // valid + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/group1/providers/Microsoft.HealthcareApis/workspaces/workspace1", + Valid: true, + }, + + { + // upper-cased + Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/GROUP1/PROVIDERS/MICROSOFT.HEALTHCAREAPIS/WORKSPACES/WORKSPACE1", + Valid: false, + }, + } + for _, tc := range cases { + t.Logf("[DEBUG] Testing Value %s", tc.Input) + _, errors := WorkspaceID(tc.Input, "test") + valid := len(errors) == 0 + + if tc.Valid != valid { + t.Fatalf("Expected %t but got %t", tc.Valid, valid) + } + } +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/healthcareapis/mgmt/2021-11-01/healthcareapis/CHANGELOG.md b/vendor/github.com/Azure/azure-sdk-for-go/services/healthcareapis/mgmt/2021-11-01/healthcareapis/CHANGELOG.md new file mode 100644 index 000000000000..52911e4cc5e4 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/healthcareapis/mgmt/2021-11-01/healthcareapis/CHANGELOG.md @@ -0,0 +1,2 @@ +# Change History + diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/healthcareapis/mgmt/2021-11-01/healthcareapis/_meta.json b/vendor/github.com/Azure/azure-sdk-for-go/services/healthcareapis/mgmt/2021-11-01/healthcareapis/_meta.json new file mode 100644 index 000000000000..bddcbd6c46f3 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/healthcareapis/mgmt/2021-11-01/healthcareapis/_meta.json @@ -0,0 +1,11 @@ +{ + "commit": "58cb0aa2979e64c7335cc26fe45a1854a6d0b7ad", + "readme": "/_/azure-rest-api-specs/specification/healthcareapis/resource-manager/readme.md", + "tag": "package-2021-11", + "use": "@microsoft.azure/autorest.go@2.1.187", + "repository_url": "https://github.com/Azure/azure-rest-api-specs.git", + "autorest_command": "autorest --use=@microsoft.azure/autorest.go@2.1.187 --tag=package-2021-11 --go-sdk-folder=/_/azure-sdk-for-go --go --verbose --use-onever --version=2.0.4421 --go.license-header=MICROSOFT_MIT_NO_VERSION --enum-prefix /_/azure-rest-api-specs/specification/healthcareapis/resource-manager/readme.md", + "additional_properties": { + "additional_options": "--go --verbose --use-onever --version=2.0.4421 --go.license-header=MICROSOFT_MIT_NO_VERSION --enum-prefix" + } +} \ No newline at end of file diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/healthcareapis/mgmt/2021-11-01/healthcareapis/client.go b/vendor/github.com/Azure/azure-sdk-for-go/services/healthcareapis/mgmt/2021-11-01/healthcareapis/client.go new file mode 100644 index 000000000000..9d4d4a46ff86 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/healthcareapis/mgmt/2021-11-01/healthcareapis/client.go @@ -0,0 +1,41 @@ +// Package healthcareapis implements the Azure ARM Healthcareapis service API version 2021-11-01. +// +// Azure Healthcare APIs Client +package healthcareapis + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" +) + +const ( + // DefaultBaseURI is the default URI used for the service Healthcareapis + DefaultBaseURI = "https://management.azure.com" +) + +// BaseClient is the base client for Healthcareapis. +type BaseClient struct { + autorest.Client + BaseURI string + SubscriptionID string +} + +// New creates an instance of the BaseClient client. +func New(subscriptionID string) BaseClient { + return NewWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewWithBaseURI creates an instance of the BaseClient client using a custom endpoint. Use this when interacting with +// an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewWithBaseURI(baseURI string, subscriptionID string) BaseClient { + return BaseClient{ + Client: autorest.NewClientWithUserAgent(UserAgent()), + BaseURI: baseURI, + SubscriptionID: subscriptionID, + } +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/healthcareapis/mgmt/2021-11-01/healthcareapis/dicomservices.go b/vendor/github.com/Azure/azure-sdk-for-go/services/healthcareapis/mgmt/2021-11-01/healthcareapis/dicomservices.go new file mode 100644 index 000000000000..72d80b1477e7 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/healthcareapis/mgmt/2021-11-01/healthcareapis/dicomservices.go @@ -0,0 +1,543 @@ +package healthcareapis + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// DicomServicesClient is the azure Healthcare APIs Client +type DicomServicesClient struct { + BaseClient +} + +// NewDicomServicesClient creates an instance of the DicomServicesClient client. +func NewDicomServicesClient(subscriptionID string) DicomServicesClient { + return NewDicomServicesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewDicomServicesClientWithBaseURI creates an instance of the DicomServicesClient client using a custom endpoint. +// Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewDicomServicesClientWithBaseURI(baseURI string, subscriptionID string) DicomServicesClient { + return DicomServicesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates a DICOM Service resource with the specified parameters. +// Parameters: +// resourceGroupName - the name of the resource group that contains the service instance. +// workspaceName - the name of workspace resource. +// dicomServiceName - the name of DICOM Service resource. +// dicomservice - the parameters for creating or updating a Dicom Service resource. +func (client DicomServicesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, workspaceName string, dicomServiceName string, dicomservice DicomService) (result DicomServicesCreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DicomServicesClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: workspaceName, + Constraints: []validation.Constraint{{Target: "workspaceName", Name: validation.MaxLength, Rule: 24, Chain: nil}, + {Target: "workspaceName", Name: validation.MinLength, Rule: 3, Chain: nil}}}, + {TargetValue: dicomServiceName, + Constraints: []validation.Constraint{{Target: "dicomServiceName", Name: validation.MaxLength, Rule: 24, Chain: nil}, + {Target: "dicomServiceName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil { + return result, validation.NewError("healthcareapis.DicomServicesClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, workspaceName, dicomServiceName, dicomservice) + if err != nil { + err = autorest.NewErrorWithError(err, "healthcareapis.DicomServicesClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "healthcareapis.DicomServicesClient", "CreateOrUpdate", result.Response(), "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client DicomServicesClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, workspaceName string, dicomServiceName string, dicomservice DicomService) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "dicomServiceName": autorest.Encode("path", dicomServiceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "workspaceName": autorest.Encode("path", workspaceName), + } + + const APIVersion = "2021-11-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HealthcareApis/workspaces/{workspaceName}/dicomservices/{dicomServiceName}", pathParameters), + autorest.WithJSON(dicomservice), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client DicomServicesClient) CreateOrUpdateSender(req *http.Request) (future DicomServicesCreateOrUpdateFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client DicomServicesClient) CreateOrUpdateResponder(resp *http.Response) (result DicomService, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes a DICOM Service. +// Parameters: +// resourceGroupName - the name of the resource group that contains the service instance. +// dicomServiceName - the name of DICOM Service resource. +// workspaceName - the name of workspace resource. +func (client DicomServicesClient) Delete(ctx context.Context, resourceGroupName string, dicomServiceName string, workspaceName string) (result DicomServicesDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DicomServicesClient.Delete") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: dicomServiceName, + Constraints: []validation.Constraint{{Target: "dicomServiceName", Name: validation.MaxLength, Rule: 24, Chain: nil}, + {Target: "dicomServiceName", Name: validation.MinLength, Rule: 3, Chain: nil}}}, + {TargetValue: workspaceName, + Constraints: []validation.Constraint{{Target: "workspaceName", Name: validation.MaxLength, Rule: 24, Chain: nil}, + {Target: "workspaceName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil { + return result, validation.NewError("healthcareapis.DicomServicesClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, dicomServiceName, workspaceName) + if err != nil { + err = autorest.NewErrorWithError(err, "healthcareapis.DicomServicesClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "healthcareapis.DicomServicesClient", "Delete", result.Response(), "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client DicomServicesClient) DeletePreparer(ctx context.Context, resourceGroupName string, dicomServiceName string, workspaceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "dicomServiceName": autorest.Encode("path", dicomServiceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "workspaceName": autorest.Encode("path", workspaceName), + } + + const APIVersion = "2021-11-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HealthcareApis/workspaces/{workspaceName}/dicomservices/{dicomServiceName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client DicomServicesClient) DeleteSender(req *http.Request) (future DicomServicesDeleteFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client DicomServicesClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets the properties of the specified DICOM Service. +// Parameters: +// resourceGroupName - the name of the resource group that contains the service instance. +// workspaceName - the name of workspace resource. +// dicomServiceName - the name of DICOM Service resource. +func (client DicomServicesClient) Get(ctx context.Context, resourceGroupName string, workspaceName string, dicomServiceName string) (result DicomService, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DicomServicesClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: workspaceName, + Constraints: []validation.Constraint{{Target: "workspaceName", Name: validation.MaxLength, Rule: 24, Chain: nil}, + {Target: "workspaceName", Name: validation.MinLength, Rule: 3, Chain: nil}}}, + {TargetValue: dicomServiceName, + Constraints: []validation.Constraint{{Target: "dicomServiceName", Name: validation.MaxLength, Rule: 24, Chain: nil}, + {Target: "dicomServiceName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil { + return result, validation.NewError("healthcareapis.DicomServicesClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, workspaceName, dicomServiceName) + if err != nil { + err = autorest.NewErrorWithError(err, "healthcareapis.DicomServicesClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "healthcareapis.DicomServicesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "healthcareapis.DicomServicesClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client DicomServicesClient) GetPreparer(ctx context.Context, resourceGroupName string, workspaceName string, dicomServiceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "dicomServiceName": autorest.Encode("path", dicomServiceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "workspaceName": autorest.Encode("path", workspaceName), + } + + const APIVersion = "2021-11-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HealthcareApis/workspaces/{workspaceName}/dicomservices/{dicomServiceName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client DicomServicesClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client DicomServicesClient) GetResponder(resp *http.Response) (result DicomService, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByWorkspace lists all DICOM Services for the given workspace +// Parameters: +// resourceGroupName - the name of the resource group that contains the service instance. +// workspaceName - the name of workspace resource. +func (client DicomServicesClient) ListByWorkspace(ctx context.Context, resourceGroupName string, workspaceName string) (result DicomServiceCollectionPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DicomServicesClient.ListByWorkspace") + defer func() { + sc := -1 + if result.dsc.Response.Response != nil { + sc = result.dsc.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: workspaceName, + Constraints: []validation.Constraint{{Target: "workspaceName", Name: validation.MaxLength, Rule: 24, Chain: nil}, + {Target: "workspaceName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil { + return result, validation.NewError("healthcareapis.DicomServicesClient", "ListByWorkspace", err.Error()) + } + + result.fn = client.listByWorkspaceNextResults + req, err := client.ListByWorkspacePreparer(ctx, resourceGroupName, workspaceName) + if err != nil { + err = autorest.NewErrorWithError(err, "healthcareapis.DicomServicesClient", "ListByWorkspace", nil, "Failure preparing request") + return + } + + resp, err := client.ListByWorkspaceSender(req) + if err != nil { + result.dsc.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "healthcareapis.DicomServicesClient", "ListByWorkspace", resp, "Failure sending request") + return + } + + result.dsc, err = client.ListByWorkspaceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "healthcareapis.DicomServicesClient", "ListByWorkspace", resp, "Failure responding to request") + return + } + if result.dsc.hasNextLink() && result.dsc.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByWorkspacePreparer prepares the ListByWorkspace request. +func (client DicomServicesClient) ListByWorkspacePreparer(ctx context.Context, resourceGroupName string, workspaceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "workspaceName": autorest.Encode("path", workspaceName), + } + + const APIVersion = "2021-11-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HealthcareApis/workspaces/{workspaceName}/dicomservices", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByWorkspaceSender sends the ListByWorkspace request. The method will close the +// http.Response Body if it receives an error. +func (client DicomServicesClient) ListByWorkspaceSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByWorkspaceResponder handles the response to the ListByWorkspace request. The method always +// closes the http.Response Body. +func (client DicomServicesClient) ListByWorkspaceResponder(resp *http.Response) (result DicomServiceCollection, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByWorkspaceNextResults retrieves the next set of results, if any. +func (client DicomServicesClient) listByWorkspaceNextResults(ctx context.Context, lastResults DicomServiceCollection) (result DicomServiceCollection, err error) { + req, err := lastResults.dicomServiceCollectionPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "healthcareapis.DicomServicesClient", "listByWorkspaceNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByWorkspaceSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "healthcareapis.DicomServicesClient", "listByWorkspaceNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByWorkspaceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "healthcareapis.DicomServicesClient", "listByWorkspaceNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByWorkspaceComplete enumerates all values, automatically crossing page boundaries as required. +func (client DicomServicesClient) ListByWorkspaceComplete(ctx context.Context, resourceGroupName string, workspaceName string) (result DicomServiceCollectionIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DicomServicesClient.ListByWorkspace") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByWorkspace(ctx, resourceGroupName, workspaceName) + return +} + +// Update patch DICOM Service details. +// Parameters: +// resourceGroupName - the name of the resource group that contains the service instance. +// dicomServiceName - the name of DICOM Service resource. +// workspaceName - the name of workspace resource. +// dicomservicePatchResource - the parameters for updating a Dicom Service. +func (client DicomServicesClient) Update(ctx context.Context, resourceGroupName string, dicomServiceName string, workspaceName string, dicomservicePatchResource DicomServicePatchResource) (result DicomServicesUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DicomServicesClient.Update") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: dicomServiceName, + Constraints: []validation.Constraint{{Target: "dicomServiceName", Name: validation.MaxLength, Rule: 24, Chain: nil}, + {Target: "dicomServiceName", Name: validation.MinLength, Rule: 3, Chain: nil}}}, + {TargetValue: workspaceName, + Constraints: []validation.Constraint{{Target: "workspaceName", Name: validation.MaxLength, Rule: 24, Chain: nil}, + {Target: "workspaceName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil { + return result, validation.NewError("healthcareapis.DicomServicesClient", "Update", err.Error()) + } + + req, err := client.UpdatePreparer(ctx, resourceGroupName, dicomServiceName, workspaceName, dicomservicePatchResource) + if err != nil { + err = autorest.NewErrorWithError(err, "healthcareapis.DicomServicesClient", "Update", nil, "Failure preparing request") + return + } + + result, err = client.UpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "healthcareapis.DicomServicesClient", "Update", result.Response(), "Failure sending request") + return + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client DicomServicesClient) UpdatePreparer(ctx context.Context, resourceGroupName string, dicomServiceName string, workspaceName string, dicomservicePatchResource DicomServicePatchResource) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "dicomServiceName": autorest.Encode("path", dicomServiceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "workspaceName": autorest.Encode("path", workspaceName), + } + + const APIVersion = "2021-11-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HealthcareApis/workspaces/{workspaceName}/dicomservices/{dicomServiceName}", pathParameters), + autorest.WithJSON(dicomservicePatchResource), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client DicomServicesClient) UpdateSender(req *http.Request) (future DicomServicesUpdateFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client DicomServicesClient) UpdateResponder(resp *http.Response) (result DicomService, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/healthcareapis/mgmt/2021-11-01/healthcareapis/enums.go b/vendor/github.com/Azure/azure-sdk-for-go/services/healthcareapis/mgmt/2021-11-01/healthcareapis/enums.go new file mode 100644 index 000000000000..2af1c222526a --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/healthcareapis/mgmt/2021-11-01/healthcareapis/enums.go @@ -0,0 +1,279 @@ +package healthcareapis + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +// ActionType enumerates the values for action type. +type ActionType string + +const ( + // ActionTypeInternal ... + ActionTypeInternal ActionType = "Internal" +) + +// PossibleActionTypeValues returns an array of possible values for the ActionType const type. +func PossibleActionTypeValues() []ActionType { + return []ActionType{ActionTypeInternal} +} + +// CreatedByType enumerates the values for created by type. +type CreatedByType string + +const ( + // CreatedByTypeApplication ... + CreatedByTypeApplication CreatedByType = "Application" + // CreatedByTypeKey ... + CreatedByTypeKey CreatedByType = "Key" + // CreatedByTypeManagedIdentity ... + CreatedByTypeManagedIdentity CreatedByType = "ManagedIdentity" + // CreatedByTypeUser ... + CreatedByTypeUser CreatedByType = "User" +) + +// PossibleCreatedByTypeValues returns an array of possible values for the CreatedByType const type. +func PossibleCreatedByTypeValues() []CreatedByType { + return []CreatedByType{CreatedByTypeApplication, CreatedByTypeKey, CreatedByTypeManagedIdentity, CreatedByTypeUser} +} + +// FhirResourceVersionPolicy enumerates the values for fhir resource version policy. +type FhirResourceVersionPolicy string + +const ( + // FhirResourceVersionPolicyNoVersion ... + FhirResourceVersionPolicyNoVersion FhirResourceVersionPolicy = "no-version" + // FhirResourceVersionPolicyVersioned ... + FhirResourceVersionPolicyVersioned FhirResourceVersionPolicy = "versioned" + // FhirResourceVersionPolicyVersionedUpdate ... + FhirResourceVersionPolicyVersionedUpdate FhirResourceVersionPolicy = "versioned-update" +) + +// PossibleFhirResourceVersionPolicyValues returns an array of possible values for the FhirResourceVersionPolicy const type. +func PossibleFhirResourceVersionPolicyValues() []FhirResourceVersionPolicy { + return []FhirResourceVersionPolicy{FhirResourceVersionPolicyNoVersion, FhirResourceVersionPolicyVersioned, FhirResourceVersionPolicyVersionedUpdate} +} + +// FhirServiceKind enumerates the values for fhir service kind. +type FhirServiceKind string + +const ( + // FhirServiceKindFhirR4 ... + FhirServiceKindFhirR4 FhirServiceKind = "fhir-R4" + // FhirServiceKindFhirStu3 ... + FhirServiceKindFhirStu3 FhirServiceKind = "fhir-Stu3" +) + +// PossibleFhirServiceKindValues returns an array of possible values for the FhirServiceKind const type. +func PossibleFhirServiceKindValues() []FhirServiceKind { + return []FhirServiceKind{FhirServiceKindFhirR4, FhirServiceKindFhirStu3} +} + +// IotIdentityResolutionType enumerates the values for iot identity resolution type. +type IotIdentityResolutionType string + +const ( + // IotIdentityResolutionTypeCreate ... + IotIdentityResolutionTypeCreate IotIdentityResolutionType = "Create" + // IotIdentityResolutionTypeLookup ... + IotIdentityResolutionTypeLookup IotIdentityResolutionType = "Lookup" +) + +// PossibleIotIdentityResolutionTypeValues returns an array of possible values for the IotIdentityResolutionType const type. +func PossibleIotIdentityResolutionTypeValues() []IotIdentityResolutionType { + return []IotIdentityResolutionType{IotIdentityResolutionTypeCreate, IotIdentityResolutionTypeLookup} +} + +// Kind enumerates the values for kind. +type Kind string + +const ( + // KindFhir ... + KindFhir Kind = "fhir" + // KindFhirR4 ... + KindFhirR4 Kind = "fhir-R4" + // KindFhirStu3 ... + KindFhirStu3 Kind = "fhir-Stu3" +) + +// PossibleKindValues returns an array of possible values for the Kind const type. +func PossibleKindValues() []Kind { + return []Kind{KindFhir, KindFhirR4, KindFhirStu3} +} + +// ManagedServiceIdentityType enumerates the values for managed service identity type. +type ManagedServiceIdentityType string + +const ( + // ManagedServiceIdentityTypeNone ... + ManagedServiceIdentityTypeNone ManagedServiceIdentityType = "None" + // ManagedServiceIdentityTypeSystemAssigned ... + ManagedServiceIdentityTypeSystemAssigned ManagedServiceIdentityType = "SystemAssigned" +) + +// PossibleManagedServiceIdentityTypeValues returns an array of possible values for the ManagedServiceIdentityType const type. +func PossibleManagedServiceIdentityTypeValues() []ManagedServiceIdentityType { + return []ManagedServiceIdentityType{ManagedServiceIdentityTypeNone, ManagedServiceIdentityTypeSystemAssigned} +} + +// OperationResultStatus enumerates the values for operation result status. +type OperationResultStatus string + +const ( + // OperationResultStatusCanceled ... + OperationResultStatusCanceled OperationResultStatus = "Canceled" + // OperationResultStatusFailed ... + OperationResultStatusFailed OperationResultStatus = "Failed" + // OperationResultStatusRequested ... + OperationResultStatusRequested OperationResultStatus = "Requested" + // OperationResultStatusRunning ... + OperationResultStatusRunning OperationResultStatus = "Running" + // OperationResultStatusSucceeded ... + OperationResultStatusSucceeded OperationResultStatus = "Succeeded" +) + +// PossibleOperationResultStatusValues returns an array of possible values for the OperationResultStatus const type. +func PossibleOperationResultStatusValues() []OperationResultStatus { + return []OperationResultStatus{OperationResultStatusCanceled, OperationResultStatusFailed, OperationResultStatusRequested, OperationResultStatusRunning, OperationResultStatusSucceeded} +} + +// PrivateEndpointConnectionProvisioningState enumerates the values for private endpoint connection +// provisioning state. +type PrivateEndpointConnectionProvisioningState string + +const ( + // PrivateEndpointConnectionProvisioningStateCreating ... + PrivateEndpointConnectionProvisioningStateCreating PrivateEndpointConnectionProvisioningState = "Creating" + // PrivateEndpointConnectionProvisioningStateDeleting ... + PrivateEndpointConnectionProvisioningStateDeleting PrivateEndpointConnectionProvisioningState = "Deleting" + // PrivateEndpointConnectionProvisioningStateFailed ... + PrivateEndpointConnectionProvisioningStateFailed PrivateEndpointConnectionProvisioningState = "Failed" + // PrivateEndpointConnectionProvisioningStateSucceeded ... + PrivateEndpointConnectionProvisioningStateSucceeded PrivateEndpointConnectionProvisioningState = "Succeeded" +) + +// PossiblePrivateEndpointConnectionProvisioningStateValues returns an array of possible values for the PrivateEndpointConnectionProvisioningState const type. +func PossiblePrivateEndpointConnectionProvisioningStateValues() []PrivateEndpointConnectionProvisioningState { + return []PrivateEndpointConnectionProvisioningState{PrivateEndpointConnectionProvisioningStateCreating, PrivateEndpointConnectionProvisioningStateDeleting, PrivateEndpointConnectionProvisioningStateFailed, PrivateEndpointConnectionProvisioningStateSucceeded} +} + +// PrivateEndpointServiceConnectionStatus enumerates the values for private endpoint service connection status. +type PrivateEndpointServiceConnectionStatus string + +const ( + // PrivateEndpointServiceConnectionStatusApproved ... + PrivateEndpointServiceConnectionStatusApproved PrivateEndpointServiceConnectionStatus = "Approved" + // PrivateEndpointServiceConnectionStatusPending ... + PrivateEndpointServiceConnectionStatusPending PrivateEndpointServiceConnectionStatus = "Pending" + // PrivateEndpointServiceConnectionStatusRejected ... + PrivateEndpointServiceConnectionStatusRejected PrivateEndpointServiceConnectionStatus = "Rejected" +) + +// PossiblePrivateEndpointServiceConnectionStatusValues returns an array of possible values for the PrivateEndpointServiceConnectionStatus const type. +func PossiblePrivateEndpointServiceConnectionStatusValues() []PrivateEndpointServiceConnectionStatus { + return []PrivateEndpointServiceConnectionStatus{PrivateEndpointServiceConnectionStatusApproved, PrivateEndpointServiceConnectionStatusPending, PrivateEndpointServiceConnectionStatusRejected} +} + +// ProvisioningState enumerates the values for provisioning state. +type ProvisioningState string + +const ( + // ProvisioningStateAccepted ... + ProvisioningStateAccepted ProvisioningState = "Accepted" + // ProvisioningStateCanceled ... + ProvisioningStateCanceled ProvisioningState = "Canceled" + // ProvisioningStateCreating ... + ProvisioningStateCreating ProvisioningState = "Creating" + // ProvisioningStateDeleting ... + ProvisioningStateDeleting ProvisioningState = "Deleting" + // ProvisioningStateDeprovisioned ... + ProvisioningStateDeprovisioned ProvisioningState = "Deprovisioned" + // ProvisioningStateFailed ... + ProvisioningStateFailed ProvisioningState = "Failed" + // ProvisioningStateMoving ... + ProvisioningStateMoving ProvisioningState = "Moving" + // ProvisioningStateSucceeded ... + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + // ProvisioningStateSuspended ... + ProvisioningStateSuspended ProvisioningState = "Suspended" + // ProvisioningStateSystemMaintenance ... + ProvisioningStateSystemMaintenance ProvisioningState = "SystemMaintenance" + // ProvisioningStateUpdating ... + ProvisioningStateUpdating ProvisioningState = "Updating" + // ProvisioningStateVerifying ... + ProvisioningStateVerifying ProvisioningState = "Verifying" + // ProvisioningStateWarned ... + ProvisioningStateWarned ProvisioningState = "Warned" +) + +// PossibleProvisioningStateValues returns an array of possible values for the ProvisioningState const type. +func PossibleProvisioningStateValues() []ProvisioningState { + return []ProvisioningState{ProvisioningStateAccepted, ProvisioningStateCanceled, ProvisioningStateCreating, ProvisioningStateDeleting, ProvisioningStateDeprovisioned, ProvisioningStateFailed, ProvisioningStateMoving, ProvisioningStateSucceeded, ProvisioningStateSuspended, ProvisioningStateSystemMaintenance, ProvisioningStateUpdating, ProvisioningStateVerifying, ProvisioningStateWarned} +} + +// PublicNetworkAccess enumerates the values for public network access. +type PublicNetworkAccess string + +const ( + // PublicNetworkAccessDisabled ... + PublicNetworkAccessDisabled PublicNetworkAccess = "Disabled" + // PublicNetworkAccessEnabled ... + PublicNetworkAccessEnabled PublicNetworkAccess = "Enabled" +) + +// PossiblePublicNetworkAccessValues returns an array of possible values for the PublicNetworkAccess const type. +func PossiblePublicNetworkAccessValues() []PublicNetworkAccess { + return []PublicNetworkAccess{PublicNetworkAccessDisabled, PublicNetworkAccessEnabled} +} + +// ServiceEventState enumerates the values for service event state. +type ServiceEventState string + +const ( + // ServiceEventStateDisabled ... + ServiceEventStateDisabled ServiceEventState = "Disabled" + // ServiceEventStateEnabled ... + ServiceEventStateEnabled ServiceEventState = "Enabled" + // ServiceEventStateUpdating ... + ServiceEventStateUpdating ServiceEventState = "Updating" +) + +// PossibleServiceEventStateValues returns an array of possible values for the ServiceEventState const type. +func PossibleServiceEventStateValues() []ServiceEventState { + return []ServiceEventState{ServiceEventStateDisabled, ServiceEventStateEnabled, ServiceEventStateUpdating} +} + +// ServiceManagedIdentityType enumerates the values for service managed identity type. +type ServiceManagedIdentityType string + +const ( + // ServiceManagedIdentityTypeNone ... + ServiceManagedIdentityTypeNone ServiceManagedIdentityType = "None" + // ServiceManagedIdentityTypeSystemAssigned ... + ServiceManagedIdentityTypeSystemAssigned ServiceManagedIdentityType = "SystemAssigned" + // ServiceManagedIdentityTypeSystemAssignedUserAssigned ... + ServiceManagedIdentityTypeSystemAssignedUserAssigned ServiceManagedIdentityType = "SystemAssigned,UserAssigned" + // ServiceManagedIdentityTypeUserAssigned ... + ServiceManagedIdentityTypeUserAssigned ServiceManagedIdentityType = "UserAssigned" +) + +// PossibleServiceManagedIdentityTypeValues returns an array of possible values for the ServiceManagedIdentityType const type. +func PossibleServiceManagedIdentityTypeValues() []ServiceManagedIdentityType { + return []ServiceManagedIdentityType{ServiceManagedIdentityTypeNone, ServiceManagedIdentityTypeSystemAssigned, ServiceManagedIdentityTypeSystemAssignedUserAssigned, ServiceManagedIdentityTypeUserAssigned} +} + +// ServiceNameUnavailabilityReason enumerates the values for service name unavailability reason. +type ServiceNameUnavailabilityReason string + +const ( + // ServiceNameUnavailabilityReasonAlreadyExists ... + ServiceNameUnavailabilityReasonAlreadyExists ServiceNameUnavailabilityReason = "AlreadyExists" + // ServiceNameUnavailabilityReasonInvalid ... + ServiceNameUnavailabilityReasonInvalid ServiceNameUnavailabilityReason = "Invalid" +) + +// PossibleServiceNameUnavailabilityReasonValues returns an array of possible values for the ServiceNameUnavailabilityReason const type. +func PossibleServiceNameUnavailabilityReasonValues() []ServiceNameUnavailabilityReason { + return []ServiceNameUnavailabilityReason{ServiceNameUnavailabilityReasonAlreadyExists, ServiceNameUnavailabilityReasonInvalid} +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/healthcareapis/mgmt/2021-11-01/healthcareapis/fhirdestinations.go b/vendor/github.com/Azure/azure-sdk-for-go/services/healthcareapis/mgmt/2021-11-01/healthcareapis/fhirdestinations.go new file mode 100644 index 000000000000..af742b585dc7 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/healthcareapis/mgmt/2021-11-01/healthcareapis/fhirdestinations.go @@ -0,0 +1,167 @@ +package healthcareapis + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// FhirDestinationsClient is the azure Healthcare APIs Client +type FhirDestinationsClient struct { + BaseClient +} + +// NewFhirDestinationsClient creates an instance of the FhirDestinationsClient client. +func NewFhirDestinationsClient(subscriptionID string) FhirDestinationsClient { + return NewFhirDestinationsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewFhirDestinationsClientWithBaseURI creates an instance of the FhirDestinationsClient client using a custom +// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure +// stack). +func NewFhirDestinationsClientWithBaseURI(baseURI string, subscriptionID string) FhirDestinationsClient { + return FhirDestinationsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// ListByIotConnector lists all FHIR destinations for the given IoT Connector +// Parameters: +// resourceGroupName - the name of the resource group that contains the service instance. +// workspaceName - the name of workspace resource. +// iotConnectorName - the name of IoT Connector resource. +func (client FhirDestinationsClient) ListByIotConnector(ctx context.Context, resourceGroupName string, workspaceName string, iotConnectorName string) (result IotFhirDestinationCollectionPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/FhirDestinationsClient.ListByIotConnector") + defer func() { + sc := -1 + if result.ifdc.Response.Response != nil { + sc = result.ifdc.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: workspaceName, + Constraints: []validation.Constraint{{Target: "workspaceName", Name: validation.MaxLength, Rule: 24, Chain: nil}, + {Target: "workspaceName", Name: validation.MinLength, Rule: 3, Chain: nil}}}, + {TargetValue: iotConnectorName, + Constraints: []validation.Constraint{{Target: "iotConnectorName", Name: validation.MaxLength, Rule: 24, Chain: nil}, + {Target: "iotConnectorName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil { + return result, validation.NewError("healthcareapis.FhirDestinationsClient", "ListByIotConnector", err.Error()) + } + + result.fn = client.listByIotConnectorNextResults + req, err := client.ListByIotConnectorPreparer(ctx, resourceGroupName, workspaceName, iotConnectorName) + if err != nil { + err = autorest.NewErrorWithError(err, "healthcareapis.FhirDestinationsClient", "ListByIotConnector", nil, "Failure preparing request") + return + } + + resp, err := client.ListByIotConnectorSender(req) + if err != nil { + result.ifdc.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "healthcareapis.FhirDestinationsClient", "ListByIotConnector", resp, "Failure sending request") + return + } + + result.ifdc, err = client.ListByIotConnectorResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "healthcareapis.FhirDestinationsClient", "ListByIotConnector", resp, "Failure responding to request") + return + } + if result.ifdc.hasNextLink() && result.ifdc.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByIotConnectorPreparer prepares the ListByIotConnector request. +func (client FhirDestinationsClient) ListByIotConnectorPreparer(ctx context.Context, resourceGroupName string, workspaceName string, iotConnectorName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "iotConnectorName": autorest.Encode("path", iotConnectorName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "workspaceName": autorest.Encode("path", workspaceName), + } + + const APIVersion = "2021-11-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HealthcareApis/workspaces/{workspaceName}/iotconnectors/{iotConnectorName}/fhirdestinations", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByIotConnectorSender sends the ListByIotConnector request. The method will close the +// http.Response Body if it receives an error. +func (client FhirDestinationsClient) ListByIotConnectorSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByIotConnectorResponder handles the response to the ListByIotConnector request. The method always +// closes the http.Response Body. +func (client FhirDestinationsClient) ListByIotConnectorResponder(resp *http.Response) (result IotFhirDestinationCollection, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByIotConnectorNextResults retrieves the next set of results, if any. +func (client FhirDestinationsClient) listByIotConnectorNextResults(ctx context.Context, lastResults IotFhirDestinationCollection) (result IotFhirDestinationCollection, err error) { + req, err := lastResults.iotFhirDestinationCollectionPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "healthcareapis.FhirDestinationsClient", "listByIotConnectorNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByIotConnectorSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "healthcareapis.FhirDestinationsClient", "listByIotConnectorNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByIotConnectorResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "healthcareapis.FhirDestinationsClient", "listByIotConnectorNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByIotConnectorComplete enumerates all values, automatically crossing page boundaries as required. +func (client FhirDestinationsClient) ListByIotConnectorComplete(ctx context.Context, resourceGroupName string, workspaceName string, iotConnectorName string) (result IotFhirDestinationCollectionIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/FhirDestinationsClient.ListByIotConnector") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByIotConnector(ctx, resourceGroupName, workspaceName, iotConnectorName) + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/healthcareapis/mgmt/2021-11-01/healthcareapis/fhirservices.go b/vendor/github.com/Azure/azure-sdk-for-go/services/healthcareapis/mgmt/2021-11-01/healthcareapis/fhirservices.go new file mode 100644 index 000000000000..ac6d54cb95f8 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/healthcareapis/mgmt/2021-11-01/healthcareapis/fhirservices.go @@ -0,0 +1,552 @@ +package healthcareapis + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// FhirServicesClient is the azure Healthcare APIs Client +type FhirServicesClient struct { + BaseClient +} + +// NewFhirServicesClient creates an instance of the FhirServicesClient client. +func NewFhirServicesClient(subscriptionID string) FhirServicesClient { + return NewFhirServicesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewFhirServicesClientWithBaseURI creates an instance of the FhirServicesClient client using a custom endpoint. Use +// this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewFhirServicesClientWithBaseURI(baseURI string, subscriptionID string) FhirServicesClient { + return FhirServicesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates a FHIR Service resource with the specified parameters. +// Parameters: +// resourceGroupName - the name of the resource group that contains the service instance. +// workspaceName - the name of workspace resource. +// fhirServiceName - the name of FHIR Service resource. +// fhirservice - the parameters for creating or updating a Fhir Service resource. +func (client FhirServicesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, workspaceName string, fhirServiceName string, fhirservice FhirService) (result FhirServicesCreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/FhirServicesClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: workspaceName, + Constraints: []validation.Constraint{{Target: "workspaceName", Name: validation.MaxLength, Rule: 24, Chain: nil}, + {Target: "workspaceName", Name: validation.MinLength, Rule: 3, Chain: nil}}}, + {TargetValue: fhirServiceName, + Constraints: []validation.Constraint{{Target: "fhirServiceName", Name: validation.MaxLength, Rule: 24, Chain: nil}, + {Target: "fhirServiceName", Name: validation.MinLength, Rule: 3, Chain: nil}}}, + {TargetValue: fhirservice, + Constraints: []validation.Constraint{{Target: "fhirservice.FhirServiceProperties", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "fhirservice.FhirServiceProperties.CorsConfiguration", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "fhirservice.FhirServiceProperties.CorsConfiguration.MaxAge", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "fhirservice.FhirServiceProperties.CorsConfiguration.MaxAge", Name: validation.InclusiveMaximum, Rule: int64(99999), Chain: nil}, + {Target: "fhirservice.FhirServiceProperties.CorsConfiguration.MaxAge", Name: validation.InclusiveMinimum, Rule: int64(0), Chain: nil}, + }}, + }}, + }}}}}); err != nil { + return result, validation.NewError("healthcareapis.FhirServicesClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, workspaceName, fhirServiceName, fhirservice) + if err != nil { + err = autorest.NewErrorWithError(err, "healthcareapis.FhirServicesClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "healthcareapis.FhirServicesClient", "CreateOrUpdate", result.Response(), "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client FhirServicesClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, workspaceName string, fhirServiceName string, fhirservice FhirService) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "fhirServiceName": autorest.Encode("path", fhirServiceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "workspaceName": autorest.Encode("path", workspaceName), + } + + const APIVersion = "2021-11-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HealthcareApis/workspaces/{workspaceName}/fhirservices/{fhirServiceName}", pathParameters), + autorest.WithJSON(fhirservice), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client FhirServicesClient) CreateOrUpdateSender(req *http.Request) (future FhirServicesCreateOrUpdateFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client FhirServicesClient) CreateOrUpdateResponder(resp *http.Response) (result FhirService, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes a FHIR Service. +// Parameters: +// resourceGroupName - the name of the resource group that contains the service instance. +// fhirServiceName - the name of FHIR Service resource. +// workspaceName - the name of workspace resource. +func (client FhirServicesClient) Delete(ctx context.Context, resourceGroupName string, fhirServiceName string, workspaceName string) (result FhirServicesDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/FhirServicesClient.Delete") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: fhirServiceName, + Constraints: []validation.Constraint{{Target: "fhirServiceName", Name: validation.MaxLength, Rule: 24, Chain: nil}, + {Target: "fhirServiceName", Name: validation.MinLength, Rule: 3, Chain: nil}}}, + {TargetValue: workspaceName, + Constraints: []validation.Constraint{{Target: "workspaceName", Name: validation.MaxLength, Rule: 24, Chain: nil}, + {Target: "workspaceName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil { + return result, validation.NewError("healthcareapis.FhirServicesClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, fhirServiceName, workspaceName) + if err != nil { + err = autorest.NewErrorWithError(err, "healthcareapis.FhirServicesClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "healthcareapis.FhirServicesClient", "Delete", result.Response(), "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client FhirServicesClient) DeletePreparer(ctx context.Context, resourceGroupName string, fhirServiceName string, workspaceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "fhirServiceName": autorest.Encode("path", fhirServiceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "workspaceName": autorest.Encode("path", workspaceName), + } + + const APIVersion = "2021-11-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HealthcareApis/workspaces/{workspaceName}/fhirservices/{fhirServiceName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client FhirServicesClient) DeleteSender(req *http.Request) (future FhirServicesDeleteFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client FhirServicesClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets the properties of the specified FHIR Service. +// Parameters: +// resourceGroupName - the name of the resource group that contains the service instance. +// workspaceName - the name of workspace resource. +// fhirServiceName - the name of FHIR Service resource. +func (client FhirServicesClient) Get(ctx context.Context, resourceGroupName string, workspaceName string, fhirServiceName string) (result FhirService, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/FhirServicesClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: workspaceName, + Constraints: []validation.Constraint{{Target: "workspaceName", Name: validation.MaxLength, Rule: 24, Chain: nil}, + {Target: "workspaceName", Name: validation.MinLength, Rule: 3, Chain: nil}}}, + {TargetValue: fhirServiceName, + Constraints: []validation.Constraint{{Target: "fhirServiceName", Name: validation.MaxLength, Rule: 24, Chain: nil}, + {Target: "fhirServiceName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil { + return result, validation.NewError("healthcareapis.FhirServicesClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, workspaceName, fhirServiceName) + if err != nil { + err = autorest.NewErrorWithError(err, "healthcareapis.FhirServicesClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "healthcareapis.FhirServicesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "healthcareapis.FhirServicesClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client FhirServicesClient) GetPreparer(ctx context.Context, resourceGroupName string, workspaceName string, fhirServiceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "fhirServiceName": autorest.Encode("path", fhirServiceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "workspaceName": autorest.Encode("path", workspaceName), + } + + const APIVersion = "2021-11-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HealthcareApis/workspaces/{workspaceName}/fhirservices/{fhirServiceName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client FhirServicesClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client FhirServicesClient) GetResponder(resp *http.Response) (result FhirService, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByWorkspace lists all FHIR Services for the given workspace +// Parameters: +// resourceGroupName - the name of the resource group that contains the service instance. +// workspaceName - the name of workspace resource. +func (client FhirServicesClient) ListByWorkspace(ctx context.Context, resourceGroupName string, workspaceName string) (result FhirServiceCollectionPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/FhirServicesClient.ListByWorkspace") + defer func() { + sc := -1 + if result.fsc.Response.Response != nil { + sc = result.fsc.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: workspaceName, + Constraints: []validation.Constraint{{Target: "workspaceName", Name: validation.MaxLength, Rule: 24, Chain: nil}, + {Target: "workspaceName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil { + return result, validation.NewError("healthcareapis.FhirServicesClient", "ListByWorkspace", err.Error()) + } + + result.fn = client.listByWorkspaceNextResults + req, err := client.ListByWorkspacePreparer(ctx, resourceGroupName, workspaceName) + if err != nil { + err = autorest.NewErrorWithError(err, "healthcareapis.FhirServicesClient", "ListByWorkspace", nil, "Failure preparing request") + return + } + + resp, err := client.ListByWorkspaceSender(req) + if err != nil { + result.fsc.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "healthcareapis.FhirServicesClient", "ListByWorkspace", resp, "Failure sending request") + return + } + + result.fsc, err = client.ListByWorkspaceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "healthcareapis.FhirServicesClient", "ListByWorkspace", resp, "Failure responding to request") + return + } + if result.fsc.hasNextLink() && result.fsc.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByWorkspacePreparer prepares the ListByWorkspace request. +func (client FhirServicesClient) ListByWorkspacePreparer(ctx context.Context, resourceGroupName string, workspaceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "workspaceName": autorest.Encode("path", workspaceName), + } + + const APIVersion = "2021-11-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HealthcareApis/workspaces/{workspaceName}/fhirservices", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByWorkspaceSender sends the ListByWorkspace request. The method will close the +// http.Response Body if it receives an error. +func (client FhirServicesClient) ListByWorkspaceSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByWorkspaceResponder handles the response to the ListByWorkspace request. The method always +// closes the http.Response Body. +func (client FhirServicesClient) ListByWorkspaceResponder(resp *http.Response) (result FhirServiceCollection, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByWorkspaceNextResults retrieves the next set of results, if any. +func (client FhirServicesClient) listByWorkspaceNextResults(ctx context.Context, lastResults FhirServiceCollection) (result FhirServiceCollection, err error) { + req, err := lastResults.fhirServiceCollectionPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "healthcareapis.FhirServicesClient", "listByWorkspaceNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByWorkspaceSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "healthcareapis.FhirServicesClient", "listByWorkspaceNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByWorkspaceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "healthcareapis.FhirServicesClient", "listByWorkspaceNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByWorkspaceComplete enumerates all values, automatically crossing page boundaries as required. +func (client FhirServicesClient) ListByWorkspaceComplete(ctx context.Context, resourceGroupName string, workspaceName string) (result FhirServiceCollectionIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/FhirServicesClient.ListByWorkspace") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByWorkspace(ctx, resourceGroupName, workspaceName) + return +} + +// Update patch FHIR Service details. +// Parameters: +// resourceGroupName - the name of the resource group that contains the service instance. +// fhirServiceName - the name of FHIR Service resource. +// workspaceName - the name of workspace resource. +// fhirservicePatchResource - the parameters for updating a Fhir Service. +func (client FhirServicesClient) Update(ctx context.Context, resourceGroupName string, fhirServiceName string, workspaceName string, fhirservicePatchResource FhirServicePatchResource) (result FhirServicesUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/FhirServicesClient.Update") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: fhirServiceName, + Constraints: []validation.Constraint{{Target: "fhirServiceName", Name: validation.MaxLength, Rule: 24, Chain: nil}, + {Target: "fhirServiceName", Name: validation.MinLength, Rule: 3, Chain: nil}}}, + {TargetValue: workspaceName, + Constraints: []validation.Constraint{{Target: "workspaceName", Name: validation.MaxLength, Rule: 24, Chain: nil}, + {Target: "workspaceName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil { + return result, validation.NewError("healthcareapis.FhirServicesClient", "Update", err.Error()) + } + + req, err := client.UpdatePreparer(ctx, resourceGroupName, fhirServiceName, workspaceName, fhirservicePatchResource) + if err != nil { + err = autorest.NewErrorWithError(err, "healthcareapis.FhirServicesClient", "Update", nil, "Failure preparing request") + return + } + + result, err = client.UpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "healthcareapis.FhirServicesClient", "Update", result.Response(), "Failure sending request") + return + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client FhirServicesClient) UpdatePreparer(ctx context.Context, resourceGroupName string, fhirServiceName string, workspaceName string, fhirservicePatchResource FhirServicePatchResource) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "fhirServiceName": autorest.Encode("path", fhirServiceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "workspaceName": autorest.Encode("path", workspaceName), + } + + const APIVersion = "2021-11-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HealthcareApis/workspaces/{workspaceName}/fhirservices/{fhirServiceName}", pathParameters), + autorest.WithJSON(fhirservicePatchResource), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client FhirServicesClient) UpdateSender(req *http.Request) (future FhirServicesUpdateFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client FhirServicesClient) UpdateResponder(resp *http.Response) (result FhirService, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/healthcareapis/mgmt/2021-11-01/healthcareapis/iotconnectorfhirdestination.go b/vendor/github.com/Azure/azure-sdk-for-go/services/healthcareapis/mgmt/2021-11-01/healthcareapis/iotconnectorfhirdestination.go new file mode 100644 index 000000000000..691cd9fc48aa --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/healthcareapis/mgmt/2021-11-01/healthcareapis/iotconnectorfhirdestination.go @@ -0,0 +1,337 @@ +package healthcareapis + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// IotConnectorFhirDestinationClient is the azure Healthcare APIs Client +type IotConnectorFhirDestinationClient struct { + BaseClient +} + +// NewIotConnectorFhirDestinationClient creates an instance of the IotConnectorFhirDestinationClient client. +func NewIotConnectorFhirDestinationClient(subscriptionID string) IotConnectorFhirDestinationClient { + return NewIotConnectorFhirDestinationClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewIotConnectorFhirDestinationClientWithBaseURI creates an instance of the IotConnectorFhirDestinationClient client +// using a custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign +// clouds, Azure stack). +func NewIotConnectorFhirDestinationClientWithBaseURI(baseURI string, subscriptionID string) IotConnectorFhirDestinationClient { + return IotConnectorFhirDestinationClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates an IoT Connector FHIR destination resource with the specified parameters. +// Parameters: +// resourceGroupName - the name of the resource group that contains the service instance. +// workspaceName - the name of workspace resource. +// iotConnectorName - the name of IoT Connector resource. +// fhirDestinationName - the name of IoT Connector FHIR destination resource. +// iotFhirDestination - the parameters for creating or updating an IoT Connector FHIR destination resource. +func (client IotConnectorFhirDestinationClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, workspaceName string, iotConnectorName string, fhirDestinationName string, iotFhirDestination IotFhirDestination) (result IotConnectorFhirDestinationCreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/IotConnectorFhirDestinationClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: workspaceName, + Constraints: []validation.Constraint{{Target: "workspaceName", Name: validation.MaxLength, Rule: 24, Chain: nil}, + {Target: "workspaceName", Name: validation.MinLength, Rule: 3, Chain: nil}}}, + {TargetValue: iotConnectorName, + Constraints: []validation.Constraint{{Target: "iotConnectorName", Name: validation.MaxLength, Rule: 24, Chain: nil}, + {Target: "iotConnectorName", Name: validation.MinLength, Rule: 3, Chain: nil}}}, + {TargetValue: fhirDestinationName, + Constraints: []validation.Constraint{{Target: "fhirDestinationName", Name: validation.MaxLength, Rule: 24, Chain: nil}, + {Target: "fhirDestinationName", Name: validation.MinLength, Rule: 3, Chain: nil}}}, + {TargetValue: iotFhirDestination, + Constraints: []validation.Constraint{{Target: "iotFhirDestination.IotFhirDestinationProperties", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "iotFhirDestination.IotFhirDestinationProperties.FhirServiceResourceID", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "iotFhirDestination.IotFhirDestinationProperties.FhirMapping", Name: validation.Null, Rule: true, Chain: nil}, + }}}}}); err != nil { + return result, validation.NewError("healthcareapis.IotConnectorFhirDestinationClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, workspaceName, iotConnectorName, fhirDestinationName, iotFhirDestination) + if err != nil { + err = autorest.NewErrorWithError(err, "healthcareapis.IotConnectorFhirDestinationClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "healthcareapis.IotConnectorFhirDestinationClient", "CreateOrUpdate", result.Response(), "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client IotConnectorFhirDestinationClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, workspaceName string, iotConnectorName string, fhirDestinationName string, iotFhirDestination IotFhirDestination) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "fhirDestinationName": autorest.Encode("path", fhirDestinationName), + "iotConnectorName": autorest.Encode("path", iotConnectorName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "workspaceName": autorest.Encode("path", workspaceName), + } + + const APIVersion = "2021-11-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HealthcareApis/workspaces/{workspaceName}/iotconnectors/{iotConnectorName}/fhirdestinations/{fhirDestinationName}", pathParameters), + autorest.WithJSON(iotFhirDestination), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client IotConnectorFhirDestinationClient) CreateOrUpdateSender(req *http.Request) (future IotConnectorFhirDestinationCreateOrUpdateFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client IotConnectorFhirDestinationClient) CreateOrUpdateResponder(resp *http.Response) (result IotFhirDestination, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes an IoT Connector FHIR destination. +// Parameters: +// resourceGroupName - the name of the resource group that contains the service instance. +// workspaceName - the name of workspace resource. +// iotConnectorName - the name of IoT Connector resource. +// fhirDestinationName - the name of IoT Connector FHIR destination resource. +func (client IotConnectorFhirDestinationClient) Delete(ctx context.Context, resourceGroupName string, workspaceName string, iotConnectorName string, fhirDestinationName string) (result IotConnectorFhirDestinationDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/IotConnectorFhirDestinationClient.Delete") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: workspaceName, + Constraints: []validation.Constraint{{Target: "workspaceName", Name: validation.MaxLength, Rule: 24, Chain: nil}, + {Target: "workspaceName", Name: validation.MinLength, Rule: 3, Chain: nil}}}, + {TargetValue: iotConnectorName, + Constraints: []validation.Constraint{{Target: "iotConnectorName", Name: validation.MaxLength, Rule: 24, Chain: nil}, + {Target: "iotConnectorName", Name: validation.MinLength, Rule: 3, Chain: nil}}}, + {TargetValue: fhirDestinationName, + Constraints: []validation.Constraint{{Target: "fhirDestinationName", Name: validation.MaxLength, Rule: 24, Chain: nil}, + {Target: "fhirDestinationName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil { + return result, validation.NewError("healthcareapis.IotConnectorFhirDestinationClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, workspaceName, iotConnectorName, fhirDestinationName) + if err != nil { + err = autorest.NewErrorWithError(err, "healthcareapis.IotConnectorFhirDestinationClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "healthcareapis.IotConnectorFhirDestinationClient", "Delete", result.Response(), "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client IotConnectorFhirDestinationClient) DeletePreparer(ctx context.Context, resourceGroupName string, workspaceName string, iotConnectorName string, fhirDestinationName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "fhirDestinationName": autorest.Encode("path", fhirDestinationName), + "iotConnectorName": autorest.Encode("path", iotConnectorName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "workspaceName": autorest.Encode("path", workspaceName), + } + + const APIVersion = "2021-11-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HealthcareApis/workspaces/{workspaceName}/iotconnectors/{iotConnectorName}/fhirdestinations/{fhirDestinationName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client IotConnectorFhirDestinationClient) DeleteSender(req *http.Request) (future IotConnectorFhirDestinationDeleteFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client IotConnectorFhirDestinationClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets the properties of the specified Iot Connector FHIR destination. +// Parameters: +// resourceGroupName - the name of the resource group that contains the service instance. +// workspaceName - the name of workspace resource. +// iotConnectorName - the name of IoT Connector resource. +// fhirDestinationName - the name of IoT Connector FHIR destination resource. +func (client IotConnectorFhirDestinationClient) Get(ctx context.Context, resourceGroupName string, workspaceName string, iotConnectorName string, fhirDestinationName string) (result IotFhirDestination, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/IotConnectorFhirDestinationClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: workspaceName, + Constraints: []validation.Constraint{{Target: "workspaceName", Name: validation.MaxLength, Rule: 24, Chain: nil}, + {Target: "workspaceName", Name: validation.MinLength, Rule: 3, Chain: nil}}}, + {TargetValue: iotConnectorName, + Constraints: []validation.Constraint{{Target: "iotConnectorName", Name: validation.MaxLength, Rule: 24, Chain: nil}, + {Target: "iotConnectorName", Name: validation.MinLength, Rule: 3, Chain: nil}}}, + {TargetValue: fhirDestinationName, + Constraints: []validation.Constraint{{Target: "fhirDestinationName", Name: validation.MaxLength, Rule: 24, Chain: nil}, + {Target: "fhirDestinationName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil { + return result, validation.NewError("healthcareapis.IotConnectorFhirDestinationClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, workspaceName, iotConnectorName, fhirDestinationName) + if err != nil { + err = autorest.NewErrorWithError(err, "healthcareapis.IotConnectorFhirDestinationClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "healthcareapis.IotConnectorFhirDestinationClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "healthcareapis.IotConnectorFhirDestinationClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client IotConnectorFhirDestinationClient) GetPreparer(ctx context.Context, resourceGroupName string, workspaceName string, iotConnectorName string, fhirDestinationName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "fhirDestinationName": autorest.Encode("path", fhirDestinationName), + "iotConnectorName": autorest.Encode("path", iotConnectorName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "workspaceName": autorest.Encode("path", workspaceName), + } + + const APIVersion = "2021-11-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HealthcareApis/workspaces/{workspaceName}/iotconnectors/{iotConnectorName}/fhirdestinations/{fhirDestinationName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client IotConnectorFhirDestinationClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client IotConnectorFhirDestinationClient) GetResponder(resp *http.Response) (result IotFhirDestination, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/healthcareapis/mgmt/2021-11-01/healthcareapis/iotconnectors.go b/vendor/github.com/Azure/azure-sdk-for-go/services/healthcareapis/mgmt/2021-11-01/healthcareapis/iotconnectors.go new file mode 100644 index 000000000000..600d75a96e4b --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/healthcareapis/mgmt/2021-11-01/healthcareapis/iotconnectors.go @@ -0,0 +1,543 @@ +package healthcareapis + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// IotConnectorsClient is the azure Healthcare APIs Client +type IotConnectorsClient struct { + BaseClient +} + +// NewIotConnectorsClient creates an instance of the IotConnectorsClient client. +func NewIotConnectorsClient(subscriptionID string) IotConnectorsClient { + return NewIotConnectorsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewIotConnectorsClientWithBaseURI creates an instance of the IotConnectorsClient client using a custom endpoint. +// Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewIotConnectorsClientWithBaseURI(baseURI string, subscriptionID string) IotConnectorsClient { + return IotConnectorsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates an IoT Connector resource with the specified parameters. +// Parameters: +// resourceGroupName - the name of the resource group that contains the service instance. +// workspaceName - the name of workspace resource. +// iotConnectorName - the name of IoT Connector resource. +// iotConnector - the parameters for creating or updating an IoT Connectors resource. +func (client IotConnectorsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, workspaceName string, iotConnectorName string, iotConnector IotConnector) (result IotConnectorsCreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/IotConnectorsClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: workspaceName, + Constraints: []validation.Constraint{{Target: "workspaceName", Name: validation.MaxLength, Rule: 24, Chain: nil}, + {Target: "workspaceName", Name: validation.MinLength, Rule: 3, Chain: nil}}}, + {TargetValue: iotConnectorName, + Constraints: []validation.Constraint{{Target: "iotConnectorName", Name: validation.MaxLength, Rule: 24, Chain: nil}, + {Target: "iotConnectorName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil { + return result, validation.NewError("healthcareapis.IotConnectorsClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, workspaceName, iotConnectorName, iotConnector) + if err != nil { + err = autorest.NewErrorWithError(err, "healthcareapis.IotConnectorsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "healthcareapis.IotConnectorsClient", "CreateOrUpdate", result.Response(), "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client IotConnectorsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, workspaceName string, iotConnectorName string, iotConnector IotConnector) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "iotConnectorName": autorest.Encode("path", iotConnectorName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "workspaceName": autorest.Encode("path", workspaceName), + } + + const APIVersion = "2021-11-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HealthcareApis/workspaces/{workspaceName}/iotconnectors/{iotConnectorName}", pathParameters), + autorest.WithJSON(iotConnector), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client IotConnectorsClient) CreateOrUpdateSender(req *http.Request) (future IotConnectorsCreateOrUpdateFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client IotConnectorsClient) CreateOrUpdateResponder(resp *http.Response) (result IotConnector, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes an IoT Connector. +// Parameters: +// resourceGroupName - the name of the resource group that contains the service instance. +// iotConnectorName - the name of IoT Connector resource. +// workspaceName - the name of workspace resource. +func (client IotConnectorsClient) Delete(ctx context.Context, resourceGroupName string, iotConnectorName string, workspaceName string) (result IotConnectorsDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/IotConnectorsClient.Delete") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: iotConnectorName, + Constraints: []validation.Constraint{{Target: "iotConnectorName", Name: validation.MaxLength, Rule: 24, Chain: nil}, + {Target: "iotConnectorName", Name: validation.MinLength, Rule: 3, Chain: nil}}}, + {TargetValue: workspaceName, + Constraints: []validation.Constraint{{Target: "workspaceName", Name: validation.MaxLength, Rule: 24, Chain: nil}, + {Target: "workspaceName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil { + return result, validation.NewError("healthcareapis.IotConnectorsClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, iotConnectorName, workspaceName) + if err != nil { + err = autorest.NewErrorWithError(err, "healthcareapis.IotConnectorsClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "healthcareapis.IotConnectorsClient", "Delete", result.Response(), "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client IotConnectorsClient) DeletePreparer(ctx context.Context, resourceGroupName string, iotConnectorName string, workspaceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "iotConnectorName": autorest.Encode("path", iotConnectorName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "workspaceName": autorest.Encode("path", workspaceName), + } + + const APIVersion = "2021-11-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HealthcareApis/workspaces/{workspaceName}/iotconnectors/{iotConnectorName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client IotConnectorsClient) DeleteSender(req *http.Request) (future IotConnectorsDeleteFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client IotConnectorsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets the properties of the specified IoT Connector. +// Parameters: +// resourceGroupName - the name of the resource group that contains the service instance. +// workspaceName - the name of workspace resource. +// iotConnectorName - the name of IoT Connector resource. +func (client IotConnectorsClient) Get(ctx context.Context, resourceGroupName string, workspaceName string, iotConnectorName string) (result IotConnector, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/IotConnectorsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: workspaceName, + Constraints: []validation.Constraint{{Target: "workspaceName", Name: validation.MaxLength, Rule: 24, Chain: nil}, + {Target: "workspaceName", Name: validation.MinLength, Rule: 3, Chain: nil}}}, + {TargetValue: iotConnectorName, + Constraints: []validation.Constraint{{Target: "iotConnectorName", Name: validation.MaxLength, Rule: 24, Chain: nil}, + {Target: "iotConnectorName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil { + return result, validation.NewError("healthcareapis.IotConnectorsClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, workspaceName, iotConnectorName) + if err != nil { + err = autorest.NewErrorWithError(err, "healthcareapis.IotConnectorsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "healthcareapis.IotConnectorsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "healthcareapis.IotConnectorsClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client IotConnectorsClient) GetPreparer(ctx context.Context, resourceGroupName string, workspaceName string, iotConnectorName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "iotConnectorName": autorest.Encode("path", iotConnectorName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "workspaceName": autorest.Encode("path", workspaceName), + } + + const APIVersion = "2021-11-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HealthcareApis/workspaces/{workspaceName}/iotconnectors/{iotConnectorName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client IotConnectorsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client IotConnectorsClient) GetResponder(resp *http.Response) (result IotConnector, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByWorkspace lists all IoT Connectors for the given workspace +// Parameters: +// resourceGroupName - the name of the resource group that contains the service instance. +// workspaceName - the name of workspace resource. +func (client IotConnectorsClient) ListByWorkspace(ctx context.Context, resourceGroupName string, workspaceName string) (result IotConnectorCollectionPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/IotConnectorsClient.ListByWorkspace") + defer func() { + sc := -1 + if result.icc.Response.Response != nil { + sc = result.icc.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: workspaceName, + Constraints: []validation.Constraint{{Target: "workspaceName", Name: validation.MaxLength, Rule: 24, Chain: nil}, + {Target: "workspaceName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil { + return result, validation.NewError("healthcareapis.IotConnectorsClient", "ListByWorkspace", err.Error()) + } + + result.fn = client.listByWorkspaceNextResults + req, err := client.ListByWorkspacePreparer(ctx, resourceGroupName, workspaceName) + if err != nil { + err = autorest.NewErrorWithError(err, "healthcareapis.IotConnectorsClient", "ListByWorkspace", nil, "Failure preparing request") + return + } + + resp, err := client.ListByWorkspaceSender(req) + if err != nil { + result.icc.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "healthcareapis.IotConnectorsClient", "ListByWorkspace", resp, "Failure sending request") + return + } + + result.icc, err = client.ListByWorkspaceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "healthcareapis.IotConnectorsClient", "ListByWorkspace", resp, "Failure responding to request") + return + } + if result.icc.hasNextLink() && result.icc.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByWorkspacePreparer prepares the ListByWorkspace request. +func (client IotConnectorsClient) ListByWorkspacePreparer(ctx context.Context, resourceGroupName string, workspaceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "workspaceName": autorest.Encode("path", workspaceName), + } + + const APIVersion = "2021-11-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HealthcareApis/workspaces/{workspaceName}/iotconnectors", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByWorkspaceSender sends the ListByWorkspace request. The method will close the +// http.Response Body if it receives an error. +func (client IotConnectorsClient) ListByWorkspaceSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByWorkspaceResponder handles the response to the ListByWorkspace request. The method always +// closes the http.Response Body. +func (client IotConnectorsClient) ListByWorkspaceResponder(resp *http.Response) (result IotConnectorCollection, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByWorkspaceNextResults retrieves the next set of results, if any. +func (client IotConnectorsClient) listByWorkspaceNextResults(ctx context.Context, lastResults IotConnectorCollection) (result IotConnectorCollection, err error) { + req, err := lastResults.iotConnectorCollectionPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "healthcareapis.IotConnectorsClient", "listByWorkspaceNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByWorkspaceSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "healthcareapis.IotConnectorsClient", "listByWorkspaceNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByWorkspaceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "healthcareapis.IotConnectorsClient", "listByWorkspaceNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByWorkspaceComplete enumerates all values, automatically crossing page boundaries as required. +func (client IotConnectorsClient) ListByWorkspaceComplete(ctx context.Context, resourceGroupName string, workspaceName string) (result IotConnectorCollectionIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/IotConnectorsClient.ListByWorkspace") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByWorkspace(ctx, resourceGroupName, workspaceName) + return +} + +// Update patch an IoT Connector. +// Parameters: +// resourceGroupName - the name of the resource group that contains the service instance. +// iotConnectorName - the name of IoT Connector resource. +// workspaceName - the name of workspace resource. +// iotConnectorPatchResource - the parameters for updating an IoT Connector. +func (client IotConnectorsClient) Update(ctx context.Context, resourceGroupName string, iotConnectorName string, workspaceName string, iotConnectorPatchResource IotConnectorPatchResource) (result IotConnectorsUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/IotConnectorsClient.Update") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: iotConnectorName, + Constraints: []validation.Constraint{{Target: "iotConnectorName", Name: validation.MaxLength, Rule: 24, Chain: nil}, + {Target: "iotConnectorName", Name: validation.MinLength, Rule: 3, Chain: nil}}}, + {TargetValue: workspaceName, + Constraints: []validation.Constraint{{Target: "workspaceName", Name: validation.MaxLength, Rule: 24, Chain: nil}, + {Target: "workspaceName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil { + return result, validation.NewError("healthcareapis.IotConnectorsClient", "Update", err.Error()) + } + + req, err := client.UpdatePreparer(ctx, resourceGroupName, iotConnectorName, workspaceName, iotConnectorPatchResource) + if err != nil { + err = autorest.NewErrorWithError(err, "healthcareapis.IotConnectorsClient", "Update", nil, "Failure preparing request") + return + } + + result, err = client.UpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "healthcareapis.IotConnectorsClient", "Update", result.Response(), "Failure sending request") + return + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client IotConnectorsClient) UpdatePreparer(ctx context.Context, resourceGroupName string, iotConnectorName string, workspaceName string, iotConnectorPatchResource IotConnectorPatchResource) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "iotConnectorName": autorest.Encode("path", iotConnectorName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "workspaceName": autorest.Encode("path", workspaceName), + } + + const APIVersion = "2021-11-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HealthcareApis/workspaces/{workspaceName}/iotconnectors/{iotConnectorName}", pathParameters), + autorest.WithJSON(iotConnectorPatchResource), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client IotConnectorsClient) UpdateSender(req *http.Request) (future IotConnectorsUpdateFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client IotConnectorsClient) UpdateResponder(resp *http.Response) (result IotConnector, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/healthcareapis/mgmt/2021-11-01/healthcareapis/models.go b/vendor/github.com/Azure/azure-sdk-for-go/services/healthcareapis/mgmt/2021-11-01/healthcareapis/models.go new file mode 100644 index 000000000000..2c4bd196969b --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/healthcareapis/mgmt/2021-11-01/healthcareapis/models.go @@ -0,0 +1,3810 @@ +package healthcareapis + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "encoding/json" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/date" + "github.com/Azure/go-autorest/autorest/to" + "github.com/Azure/go-autorest/tracing" + "github.com/gofrs/uuid" + "net/http" +) + +// The package's fully qualified name. +const fqdn = "github.com/Azure/azure-sdk-for-go/services/healthcareapis/mgmt/2021-11-01/healthcareapis" + +// AzureEntityResource the resource model definition for an Azure Resource Manager resource with an etag. +type AzureEntityResource struct { + // Etag - READ-ONLY; Resource Etag. + Etag *string `json:"etag,omitempty"` + // ID - READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the resource + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for AzureEntityResource. +func (aer AzureEntityResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// CheckNameAvailabilityParameters input values. +type CheckNameAvailabilityParameters struct { + // Name - The name of the service instance to check. + Name *string `json:"name,omitempty"` + // Type - The fully qualified resource type which includes provider namespace. + Type *string `json:"type,omitempty"` +} + +// DicomService the description of Dicom Service +type DicomService struct { + autorest.Response `json:"-"` + // Tags - Resource tags. + Tags map[string]*string `json:"tags"` + // Location - The resource location. + Location *string `json:"location,omitempty"` + // Identity - Setting indicating whether the service has a managed identity associated with it. + Identity *ServiceManagedIdentityIdentity `json:"identity,omitempty"` + // DicomServiceProperties - Dicom Service configuration. + *DicomServiceProperties `json:"properties,omitempty"` + // SystemData - Metadata pertaining to creation and last modification of the resource. + SystemData *SystemData `json:"systemData,omitempty"` +} + +// MarshalJSON is the custom marshaler for DicomService. +func (ds DicomService) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ds.Tags != nil { + objectMap["tags"] = ds.Tags + } + if ds.Location != nil { + objectMap["location"] = ds.Location + } + if ds.Identity != nil { + objectMap["identity"] = ds.Identity + } + if ds.DicomServiceProperties != nil { + objectMap["properties"] = ds.DicomServiceProperties + } + if ds.SystemData != nil { + objectMap["systemData"] = ds.SystemData + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for DicomService struct. +func (ds *DicomService) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + ds.Tags = tags + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + ds.Location = &location + } + case "identity": + if v != nil { + var identity ServiceManagedIdentityIdentity + err = json.Unmarshal(*v, &identity) + if err != nil { + return err + } + ds.Identity = &identity + } + case "properties": + if v != nil { + var dicomServiceProperties DicomServiceProperties + err = json.Unmarshal(*v, &dicomServiceProperties) + if err != nil { + return err + } + ds.DicomServiceProperties = &dicomServiceProperties + } + case "systemData": + if v != nil { + var systemData SystemData + err = json.Unmarshal(*v, &systemData) + if err != nil { + return err + } + ds.SystemData = &systemData + } + } + } + + return nil +} + +// DicomServiceAuthenticationConfiguration authentication configuration information +type DicomServiceAuthenticationConfiguration struct { + // Authority - READ-ONLY; The authority url for the service + Authority *string `json:"authority,omitempty"` + // Audiences - READ-ONLY; The audiences for the service + Audiences *[]string `json:"audiences,omitempty"` +} + +// MarshalJSON is the custom marshaler for DicomServiceAuthenticationConfiguration. +func (dsac DicomServiceAuthenticationConfiguration) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// DicomServiceCollection the collection of Dicom Services. +type DicomServiceCollection struct { + autorest.Response `json:"-"` + // NextLink - The link used to get the next page of Dicom Services. + NextLink *string `json:"nextLink,omitempty"` + // Value - The list of Dicom Services. + Value *[]DicomService `json:"value,omitempty"` +} + +// DicomServiceCollectionIterator provides access to a complete listing of DicomService values. +type DicomServiceCollectionIterator struct { + i int + page DicomServiceCollectionPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *DicomServiceCollectionIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DicomServiceCollectionIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *DicomServiceCollectionIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter DicomServiceCollectionIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter DicomServiceCollectionIterator) Response() DicomServiceCollection { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter DicomServiceCollectionIterator) Value() DicomService { + if !iter.page.NotDone() { + return DicomService{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the DicomServiceCollectionIterator type. +func NewDicomServiceCollectionIterator(page DicomServiceCollectionPage) DicomServiceCollectionIterator { + return DicomServiceCollectionIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (dsc DicomServiceCollection) IsEmpty() bool { + return dsc.Value == nil || len(*dsc.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (dsc DicomServiceCollection) hasNextLink() bool { + return dsc.NextLink != nil && len(*dsc.NextLink) != 0 +} + +// dicomServiceCollectionPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (dsc DicomServiceCollection) dicomServiceCollectionPreparer(ctx context.Context) (*http.Request, error) { + if !dsc.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(dsc.NextLink))) +} + +// DicomServiceCollectionPage contains a page of DicomService values. +type DicomServiceCollectionPage struct { + fn func(context.Context, DicomServiceCollection) (DicomServiceCollection, error) + dsc DicomServiceCollection +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *DicomServiceCollectionPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DicomServiceCollectionPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.dsc) + if err != nil { + return err + } + page.dsc = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *DicomServiceCollectionPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page DicomServiceCollectionPage) NotDone() bool { + return !page.dsc.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page DicomServiceCollectionPage) Response() DicomServiceCollection { + return page.dsc +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page DicomServiceCollectionPage) Values() []DicomService { + if page.dsc.IsEmpty() { + return nil + } + return *page.dsc.Value +} + +// Creates a new instance of the DicomServiceCollectionPage type. +func NewDicomServiceCollectionPage(cur DicomServiceCollection, getNextPage func(context.Context, DicomServiceCollection) (DicomServiceCollection, error)) DicomServiceCollectionPage { + return DicomServiceCollectionPage{ + fn: getNextPage, + dsc: cur, + } +} + +// DicomServicePatchResource dicom Service patch properties +type DicomServicePatchResource struct { + // Tags - Resource tags. + Tags map[string]*string `json:"tags"` + // Identity - Setting indicating whether the service has a managed identity associated with it. + Identity *ServiceManagedIdentityIdentity `json:"identity,omitempty"` +} + +// MarshalJSON is the custom marshaler for DicomServicePatchResource. +func (dspr DicomServicePatchResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if dspr.Tags != nil { + objectMap["tags"] = dspr.Tags + } + if dspr.Identity != nil { + objectMap["identity"] = dspr.Identity + } + return json.Marshal(objectMap) +} + +// DicomServiceProperties dicom Service properties. +type DicomServiceProperties struct { + // ProvisioningState - The provisioning state. Possible values include: 'ProvisioningStateDeleting', 'ProvisioningStateSucceeded', 'ProvisioningStateCreating', 'ProvisioningStateAccepted', 'ProvisioningStateVerifying', 'ProvisioningStateUpdating', 'ProvisioningStateFailed', 'ProvisioningStateCanceled', 'ProvisioningStateDeprovisioned', 'ProvisioningStateMoving', 'ProvisioningStateSuspended', 'ProvisioningStateWarned', 'ProvisioningStateSystemMaintenance' + ProvisioningState ProvisioningState `json:"provisioningState,omitempty"` + // AuthenticationConfiguration - Dicom Service authentication configuration. + AuthenticationConfiguration *DicomServiceAuthenticationConfiguration `json:"authenticationConfiguration,omitempty"` + // ServiceURL - READ-ONLY; The url of the Dicom Services. + ServiceURL *string `json:"serviceUrl,omitempty"` + // PrivateEndpointConnections - READ-ONLY; The list of private endpoint connections that are set up for this resource. + PrivateEndpointConnections *[]PrivateEndpointConnection `json:"privateEndpointConnections,omitempty"` + // PublicNetworkAccess - Control permission for data plane traffic coming from public networks while private endpoint is enabled. Possible values include: 'PublicNetworkAccessEnabled', 'PublicNetworkAccessDisabled' + PublicNetworkAccess PublicNetworkAccess `json:"publicNetworkAccess,omitempty"` +} + +// MarshalJSON is the custom marshaler for DicomServiceProperties. +func (dsp DicomServiceProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if dsp.ProvisioningState != "" { + objectMap["provisioningState"] = dsp.ProvisioningState + } + if dsp.AuthenticationConfiguration != nil { + objectMap["authenticationConfiguration"] = dsp.AuthenticationConfiguration + } + if dsp.PublicNetworkAccess != "" { + objectMap["publicNetworkAccess"] = dsp.PublicNetworkAccess + } + return json.Marshal(objectMap) +} + +// DicomServicesCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type DicomServicesCreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(DicomServicesClient) (DicomService, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *DicomServicesCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for DicomServicesCreateOrUpdateFuture.Result. +func (future *DicomServicesCreateOrUpdateFuture) result(client DicomServicesClient) (ds DicomService, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "healthcareapis.DicomServicesCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ds.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("healthcareapis.DicomServicesCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if ds.Response.Response, err = future.GetResult(sender); err == nil && ds.Response.Response.StatusCode != http.StatusNoContent { + ds, err = client.CreateOrUpdateResponder(ds.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "healthcareapis.DicomServicesCreateOrUpdateFuture", "Result", ds.Response.Response, "Failure responding to request") + } + } + return +} + +// DicomServicesDeleteFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type DicomServicesDeleteFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(DicomServicesClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *DicomServicesDeleteFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for DicomServicesDeleteFuture.Result. +func (future *DicomServicesDeleteFuture) result(client DicomServicesClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "healthcareapis.DicomServicesDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("healthcareapis.DicomServicesDeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// DicomServicesUpdateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type DicomServicesUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(DicomServicesClient) (DicomService, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *DicomServicesUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for DicomServicesUpdateFuture.Result. +func (future *DicomServicesUpdateFuture) result(client DicomServicesClient) (ds DicomService, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "healthcareapis.DicomServicesUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ds.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("healthcareapis.DicomServicesUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if ds.Response.Response, err = future.GetResult(sender); err == nil && ds.Response.Response.StatusCode != http.StatusNoContent { + ds, err = client.UpdateResponder(ds.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "healthcareapis.DicomServicesUpdateFuture", "Result", ds.Response.Response, "Failure responding to request") + } + } + return +} + +// Error error details. +type Error struct { + // Error - Error details + Error *ErrorDetailsInternal `json:"error,omitempty"` +} + +// ErrorDetails error details. +type ErrorDetails struct { + // Error - Error details + Error *ErrorDetailsInternal `json:"error,omitempty"` +} + +// ErrorDetailsInternal error details. +type ErrorDetailsInternal struct { + // Code - READ-ONLY; The error code. + Code *string `json:"code,omitempty"` + // Message - READ-ONLY; The error message. + Message *string `json:"message,omitempty"` + // Target - READ-ONLY; The target of the particular error. + Target *string `json:"target,omitempty"` +} + +// MarshalJSON is the custom marshaler for ErrorDetailsInternal. +func (edi ErrorDetailsInternal) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// FhirService the description of Fhir Service +type FhirService struct { + autorest.Response `json:"-"` + // Tags - Resource tags. + Tags map[string]*string `json:"tags"` + // Location - The resource location. + Location *string `json:"location,omitempty"` + // Identity - Setting indicating whether the service has a managed identity associated with it. + Identity *ServiceManagedIdentityIdentity `json:"identity,omitempty"` + // Kind - The kind of the service. Possible values include: 'FhirServiceKindFhirStu3', 'FhirServiceKindFhirR4' + Kind FhirServiceKind `json:"kind,omitempty"` + // FhirServiceProperties - Fhir Service configuration. + *FhirServiceProperties `json:"properties,omitempty"` + // SystemData - Metadata pertaining to creation and last modification of the resource. + SystemData *SystemData `json:"systemData,omitempty"` +} + +// MarshalJSON is the custom marshaler for FhirService. +func (fs FhirService) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if fs.Tags != nil { + objectMap["tags"] = fs.Tags + } + if fs.Location != nil { + objectMap["location"] = fs.Location + } + if fs.Identity != nil { + objectMap["identity"] = fs.Identity + } + if fs.Kind != "" { + objectMap["kind"] = fs.Kind + } + if fs.FhirServiceProperties != nil { + objectMap["properties"] = fs.FhirServiceProperties + } + if fs.SystemData != nil { + objectMap["systemData"] = fs.SystemData + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for FhirService struct. +func (fs *FhirService) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + fs.Tags = tags + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + fs.Location = &location + } + case "identity": + if v != nil { + var identity ServiceManagedIdentityIdentity + err = json.Unmarshal(*v, &identity) + if err != nil { + return err + } + fs.Identity = &identity + } + case "kind": + if v != nil { + var kind FhirServiceKind + err = json.Unmarshal(*v, &kind) + if err != nil { + return err + } + fs.Kind = kind + } + case "properties": + if v != nil { + var fhirServiceProperties FhirServiceProperties + err = json.Unmarshal(*v, &fhirServiceProperties) + if err != nil { + return err + } + fs.FhirServiceProperties = &fhirServiceProperties + } + case "systemData": + if v != nil { + var systemData SystemData + err = json.Unmarshal(*v, &systemData) + if err != nil { + return err + } + fs.SystemData = &systemData + } + } + } + + return nil +} + +// FhirServiceAccessPolicyEntry an access policy entry. +type FhirServiceAccessPolicyEntry struct { + // ObjectID - An Azure AD object ID (User or Apps) that is allowed access to the FHIR service. + ObjectID *string `json:"objectId,omitempty"` +} + +// FhirServiceAcrConfiguration azure container registry configuration information +type FhirServiceAcrConfiguration struct { + // LoginServers - The list of the Azure container registry login servers. + LoginServers *[]string `json:"loginServers,omitempty"` + // OciArtifacts - The list of Open Container Initiative (OCI) artifacts. + OciArtifacts *[]ServiceOciArtifactEntry `json:"ociArtifacts,omitempty"` +} + +// FhirServiceAuthenticationConfiguration authentication configuration information +type FhirServiceAuthenticationConfiguration struct { + // Authority - The authority url for the service + Authority *string `json:"authority,omitempty"` + // Audience - The audience url for the service + Audience *string `json:"audience,omitempty"` + // SmartProxyEnabled - If the SMART on FHIR proxy is enabled + SmartProxyEnabled *bool `json:"smartProxyEnabled,omitempty"` +} + +// FhirServiceCollection a collection of Fhir services. +type FhirServiceCollection struct { + autorest.Response `json:"-"` + // NextLink - The link used to get the next page of Fhir Services. + NextLink *string `json:"nextLink,omitempty"` + // Value - The list of Fhir Services. + Value *[]FhirService `json:"value,omitempty"` +} + +// FhirServiceCollectionIterator provides access to a complete listing of FhirService values. +type FhirServiceCollectionIterator struct { + i int + page FhirServiceCollectionPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *FhirServiceCollectionIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/FhirServiceCollectionIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *FhirServiceCollectionIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter FhirServiceCollectionIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter FhirServiceCollectionIterator) Response() FhirServiceCollection { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter FhirServiceCollectionIterator) Value() FhirService { + if !iter.page.NotDone() { + return FhirService{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the FhirServiceCollectionIterator type. +func NewFhirServiceCollectionIterator(page FhirServiceCollectionPage) FhirServiceCollectionIterator { + return FhirServiceCollectionIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (fsc FhirServiceCollection) IsEmpty() bool { + return fsc.Value == nil || len(*fsc.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (fsc FhirServiceCollection) hasNextLink() bool { + return fsc.NextLink != nil && len(*fsc.NextLink) != 0 +} + +// fhirServiceCollectionPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (fsc FhirServiceCollection) fhirServiceCollectionPreparer(ctx context.Context) (*http.Request, error) { + if !fsc.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(fsc.NextLink))) +} + +// FhirServiceCollectionPage contains a page of FhirService values. +type FhirServiceCollectionPage struct { + fn func(context.Context, FhirServiceCollection) (FhirServiceCollection, error) + fsc FhirServiceCollection +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *FhirServiceCollectionPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/FhirServiceCollectionPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.fsc) + if err != nil { + return err + } + page.fsc = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *FhirServiceCollectionPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page FhirServiceCollectionPage) NotDone() bool { + return !page.fsc.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page FhirServiceCollectionPage) Response() FhirServiceCollection { + return page.fsc +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page FhirServiceCollectionPage) Values() []FhirService { + if page.fsc.IsEmpty() { + return nil + } + return *page.fsc.Value +} + +// Creates a new instance of the FhirServiceCollectionPage type. +func NewFhirServiceCollectionPage(cur FhirServiceCollection, getNextPage func(context.Context, FhirServiceCollection) (FhirServiceCollection, error)) FhirServiceCollectionPage { + return FhirServiceCollectionPage{ + fn: getNextPage, + fsc: cur, + } +} + +// FhirServiceCorsConfiguration the settings for the CORS configuration of the service instance. +type FhirServiceCorsConfiguration struct { + // Origins - The origins to be allowed via CORS. + Origins *[]string `json:"origins,omitempty"` + // Headers - The headers to be allowed via CORS. + Headers *[]string `json:"headers,omitempty"` + // Methods - The methods to be allowed via CORS. + Methods *[]string `json:"methods,omitempty"` + // MaxAge - The max age to be allowed via CORS. + MaxAge *int32 `json:"maxAge,omitempty"` + // AllowCredentials - If credentials are allowed via CORS. + AllowCredentials *bool `json:"allowCredentials,omitempty"` +} + +// FhirServiceExportConfiguration export operation configuration information +type FhirServiceExportConfiguration struct { + // StorageAccountName - The name of the default export storage account. + StorageAccountName *string `json:"storageAccountName,omitempty"` +} + +// FhirServicePatchResource fhirService patch properties +type FhirServicePatchResource struct { + // Tags - Resource tags. + Tags map[string]*string `json:"tags"` + // Identity - Setting indicating whether the service has a managed identity associated with it. + Identity *ServiceManagedIdentityIdentity `json:"identity,omitempty"` +} + +// MarshalJSON is the custom marshaler for FhirServicePatchResource. +func (fspr FhirServicePatchResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if fspr.Tags != nil { + objectMap["tags"] = fspr.Tags + } + if fspr.Identity != nil { + objectMap["identity"] = fspr.Identity + } + return json.Marshal(objectMap) +} + +// FhirServiceProperties fhir Service properties. +type FhirServiceProperties struct { + // ProvisioningState - The provisioning state. Possible values include: 'ProvisioningStateDeleting', 'ProvisioningStateSucceeded', 'ProvisioningStateCreating', 'ProvisioningStateAccepted', 'ProvisioningStateVerifying', 'ProvisioningStateUpdating', 'ProvisioningStateFailed', 'ProvisioningStateCanceled', 'ProvisioningStateDeprovisioned', 'ProvisioningStateMoving', 'ProvisioningStateSuspended', 'ProvisioningStateWarned', 'ProvisioningStateSystemMaintenance' + ProvisioningState ProvisioningState `json:"provisioningState,omitempty"` + // AccessPolicies - Fhir Service access policies. + AccessPolicies *[]FhirServiceAccessPolicyEntry `json:"accessPolicies,omitempty"` + // AcrConfiguration - Fhir Service Azure container registry configuration. + AcrConfiguration *FhirServiceAcrConfiguration `json:"acrConfiguration,omitempty"` + // AuthenticationConfiguration - Fhir Service authentication configuration. + AuthenticationConfiguration *FhirServiceAuthenticationConfiguration `json:"authenticationConfiguration,omitempty"` + // CorsConfiguration - Fhir Service Cors configuration. + CorsConfiguration *FhirServiceCorsConfiguration `json:"corsConfiguration,omitempty"` + // ExportConfiguration - Fhir Service export configuration. + ExportConfiguration *FhirServiceExportConfiguration `json:"exportConfiguration,omitempty"` + // PrivateEndpointConnections - READ-ONLY; The list of private endpoint connections that are set up for this resource. + PrivateEndpointConnections *[]PrivateEndpointConnection `json:"privateEndpointConnections,omitempty"` + // PublicNetworkAccess - Control permission for data plane traffic coming from public networks while private endpoint is enabled. Possible values include: 'PublicNetworkAccessEnabled', 'PublicNetworkAccessDisabled' + PublicNetworkAccess PublicNetworkAccess `json:"publicNetworkAccess,omitempty"` + // EventState - Fhir Service event support status. Possible values include: 'ServiceEventStateDisabled', 'ServiceEventStateEnabled', 'ServiceEventStateUpdating' + EventState ServiceEventState `json:"eventState,omitempty"` + // ResourceVersionPolicyConfiguration - Determines tracking of history for resources. + ResourceVersionPolicyConfiguration *ResourceVersionPolicyConfiguration `json:"resourceVersionPolicyConfiguration,omitempty"` +} + +// MarshalJSON is the custom marshaler for FhirServiceProperties. +func (fsp FhirServiceProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if fsp.ProvisioningState != "" { + objectMap["provisioningState"] = fsp.ProvisioningState + } + if fsp.AccessPolicies != nil { + objectMap["accessPolicies"] = fsp.AccessPolicies + } + if fsp.AcrConfiguration != nil { + objectMap["acrConfiguration"] = fsp.AcrConfiguration + } + if fsp.AuthenticationConfiguration != nil { + objectMap["authenticationConfiguration"] = fsp.AuthenticationConfiguration + } + if fsp.CorsConfiguration != nil { + objectMap["corsConfiguration"] = fsp.CorsConfiguration + } + if fsp.ExportConfiguration != nil { + objectMap["exportConfiguration"] = fsp.ExportConfiguration + } + if fsp.PublicNetworkAccess != "" { + objectMap["publicNetworkAccess"] = fsp.PublicNetworkAccess + } + if fsp.EventState != "" { + objectMap["eventState"] = fsp.EventState + } + if fsp.ResourceVersionPolicyConfiguration != nil { + objectMap["resourceVersionPolicyConfiguration"] = fsp.ResourceVersionPolicyConfiguration + } + return json.Marshal(objectMap) +} + +// FhirServicesCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type FhirServicesCreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(FhirServicesClient) (FhirService, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *FhirServicesCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for FhirServicesCreateOrUpdateFuture.Result. +func (future *FhirServicesCreateOrUpdateFuture) result(client FhirServicesClient) (fs FhirService, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "healthcareapis.FhirServicesCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + fs.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("healthcareapis.FhirServicesCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if fs.Response.Response, err = future.GetResult(sender); err == nil && fs.Response.Response.StatusCode != http.StatusNoContent { + fs, err = client.CreateOrUpdateResponder(fs.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "healthcareapis.FhirServicesCreateOrUpdateFuture", "Result", fs.Response.Response, "Failure responding to request") + } + } + return +} + +// FhirServicesDeleteFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type FhirServicesDeleteFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(FhirServicesClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *FhirServicesDeleteFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for FhirServicesDeleteFuture.Result. +func (future *FhirServicesDeleteFuture) result(client FhirServicesClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "healthcareapis.FhirServicesDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("healthcareapis.FhirServicesDeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// FhirServicesUpdateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type FhirServicesUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(FhirServicesClient) (FhirService, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *FhirServicesUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for FhirServicesUpdateFuture.Result. +func (future *FhirServicesUpdateFuture) result(client FhirServicesClient) (fs FhirService, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "healthcareapis.FhirServicesUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + fs.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("healthcareapis.FhirServicesUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if fs.Response.Response, err = future.GetResult(sender); err == nil && fs.Response.Response.StatusCode != http.StatusNoContent { + fs, err = client.UpdateResponder(fs.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "healthcareapis.FhirServicesUpdateFuture", "Result", fs.Response.Response, "Failure responding to request") + } + } + return +} + +// IotConnector ioT Connector definition. +type IotConnector struct { + autorest.Response `json:"-"` + // Tags - Resource tags. + Tags map[string]*string `json:"tags"` + // Location - The resource location. + Location *string `json:"location,omitempty"` + // Identity - Setting indicating whether the service has a managed identity associated with it. + Identity *ServiceManagedIdentityIdentity `json:"identity,omitempty"` + // IotConnectorProperties - IoT Connector configuration. + *IotConnectorProperties `json:"properties,omitempty"` + // SystemData - Metadata pertaining to creation and last modification of the resource. + SystemData *SystemData `json:"systemData,omitempty"` +} + +// MarshalJSON is the custom marshaler for IotConnector. +func (ic IotConnector) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ic.Tags != nil { + objectMap["tags"] = ic.Tags + } + if ic.Location != nil { + objectMap["location"] = ic.Location + } + if ic.Identity != nil { + objectMap["identity"] = ic.Identity + } + if ic.IotConnectorProperties != nil { + objectMap["properties"] = ic.IotConnectorProperties + } + if ic.SystemData != nil { + objectMap["systemData"] = ic.SystemData + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for IotConnector struct. +func (ic *IotConnector) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + ic.Tags = tags + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + ic.Location = &location + } + case "identity": + if v != nil { + var identity ServiceManagedIdentityIdentity + err = json.Unmarshal(*v, &identity) + if err != nil { + return err + } + ic.Identity = &identity + } + case "properties": + if v != nil { + var iotConnectorProperties IotConnectorProperties + err = json.Unmarshal(*v, &iotConnectorProperties) + if err != nil { + return err + } + ic.IotConnectorProperties = &iotConnectorProperties + } + case "systemData": + if v != nil { + var systemData SystemData + err = json.Unmarshal(*v, &systemData) + if err != nil { + return err + } + ic.SystemData = &systemData + } + } + } + + return nil +} + +// IotConnectorCollection a collection of IoT Connectors. +type IotConnectorCollection struct { + autorest.Response `json:"-"` + // NextLink - The link used to get the next page of IoT Connectors. + NextLink *string `json:"nextLink,omitempty"` + // Value - The list of IoT Connectors. + Value *[]IotConnector `json:"value,omitempty"` +} + +// IotConnectorCollectionIterator provides access to a complete listing of IotConnector values. +type IotConnectorCollectionIterator struct { + i int + page IotConnectorCollectionPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *IotConnectorCollectionIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/IotConnectorCollectionIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *IotConnectorCollectionIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter IotConnectorCollectionIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter IotConnectorCollectionIterator) Response() IotConnectorCollection { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter IotConnectorCollectionIterator) Value() IotConnector { + if !iter.page.NotDone() { + return IotConnector{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the IotConnectorCollectionIterator type. +func NewIotConnectorCollectionIterator(page IotConnectorCollectionPage) IotConnectorCollectionIterator { + return IotConnectorCollectionIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (icc IotConnectorCollection) IsEmpty() bool { + return icc.Value == nil || len(*icc.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (icc IotConnectorCollection) hasNextLink() bool { + return icc.NextLink != nil && len(*icc.NextLink) != 0 +} + +// iotConnectorCollectionPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (icc IotConnectorCollection) iotConnectorCollectionPreparer(ctx context.Context) (*http.Request, error) { + if !icc.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(icc.NextLink))) +} + +// IotConnectorCollectionPage contains a page of IotConnector values. +type IotConnectorCollectionPage struct { + fn func(context.Context, IotConnectorCollection) (IotConnectorCollection, error) + icc IotConnectorCollection +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *IotConnectorCollectionPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/IotConnectorCollectionPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.icc) + if err != nil { + return err + } + page.icc = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *IotConnectorCollectionPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page IotConnectorCollectionPage) NotDone() bool { + return !page.icc.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page IotConnectorCollectionPage) Response() IotConnectorCollection { + return page.icc +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page IotConnectorCollectionPage) Values() []IotConnector { + if page.icc.IsEmpty() { + return nil + } + return *page.icc.Value +} + +// Creates a new instance of the IotConnectorCollectionPage type. +func NewIotConnectorCollectionPage(cur IotConnectorCollection, getNextPage func(context.Context, IotConnectorCollection) (IotConnectorCollection, error)) IotConnectorCollectionPage { + return IotConnectorCollectionPage{ + fn: getNextPage, + icc: cur, + } +} + +// IotConnectorFhirDestinationCreateOrUpdateFuture an abstraction for monitoring and retrieving the results +// of a long-running operation. +type IotConnectorFhirDestinationCreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(IotConnectorFhirDestinationClient) (IotFhirDestination, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *IotConnectorFhirDestinationCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for IotConnectorFhirDestinationCreateOrUpdateFuture.Result. +func (future *IotConnectorFhirDestinationCreateOrUpdateFuture) result(client IotConnectorFhirDestinationClient) (ifd IotFhirDestination, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "healthcareapis.IotConnectorFhirDestinationCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ifd.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("healthcareapis.IotConnectorFhirDestinationCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if ifd.Response.Response, err = future.GetResult(sender); err == nil && ifd.Response.Response.StatusCode != http.StatusNoContent { + ifd, err = client.CreateOrUpdateResponder(ifd.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "healthcareapis.IotConnectorFhirDestinationCreateOrUpdateFuture", "Result", ifd.Response.Response, "Failure responding to request") + } + } + return +} + +// IotConnectorFhirDestinationDeleteFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type IotConnectorFhirDestinationDeleteFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(IotConnectorFhirDestinationClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *IotConnectorFhirDestinationDeleteFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for IotConnectorFhirDestinationDeleteFuture.Result. +func (future *IotConnectorFhirDestinationDeleteFuture) result(client IotConnectorFhirDestinationClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "healthcareapis.IotConnectorFhirDestinationDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("healthcareapis.IotConnectorFhirDestinationDeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// IotConnectorPatchResource iot Connector patch properties +type IotConnectorPatchResource struct { + // Tags - Resource tags. + Tags map[string]*string `json:"tags"` + // Identity - Setting indicating whether the service has a managed identity associated with it. + Identity *ServiceManagedIdentityIdentity `json:"identity,omitempty"` +} + +// MarshalJSON is the custom marshaler for IotConnectorPatchResource. +func (icpr IotConnectorPatchResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if icpr.Tags != nil { + objectMap["tags"] = icpr.Tags + } + if icpr.Identity != nil { + objectMap["identity"] = icpr.Identity + } + return json.Marshal(objectMap) +} + +// IotConnectorProperties ioT Connector properties. +type IotConnectorProperties struct { + // ProvisioningState - The provisioning state. Possible values include: 'ProvisioningStateDeleting', 'ProvisioningStateSucceeded', 'ProvisioningStateCreating', 'ProvisioningStateAccepted', 'ProvisioningStateVerifying', 'ProvisioningStateUpdating', 'ProvisioningStateFailed', 'ProvisioningStateCanceled', 'ProvisioningStateDeprovisioned', 'ProvisioningStateMoving', 'ProvisioningStateSuspended', 'ProvisioningStateWarned', 'ProvisioningStateSystemMaintenance' + ProvisioningState ProvisioningState `json:"provisioningState,omitempty"` + // IngestionEndpointConfiguration - Source configuration. + IngestionEndpointConfiguration *IotEventHubIngestionEndpointConfiguration `json:"ingestionEndpointConfiguration,omitempty"` + // DeviceMapping - Device Mappings. + DeviceMapping *IotMappingProperties `json:"deviceMapping,omitempty"` +} + +// IotConnectorsCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type IotConnectorsCreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(IotConnectorsClient) (IotConnector, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *IotConnectorsCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for IotConnectorsCreateOrUpdateFuture.Result. +func (future *IotConnectorsCreateOrUpdateFuture) result(client IotConnectorsClient) (ic IotConnector, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "healthcareapis.IotConnectorsCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ic.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("healthcareapis.IotConnectorsCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if ic.Response.Response, err = future.GetResult(sender); err == nil && ic.Response.Response.StatusCode != http.StatusNoContent { + ic, err = client.CreateOrUpdateResponder(ic.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "healthcareapis.IotConnectorsCreateOrUpdateFuture", "Result", ic.Response.Response, "Failure responding to request") + } + } + return +} + +// IotConnectorsDeleteFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type IotConnectorsDeleteFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(IotConnectorsClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *IotConnectorsDeleteFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for IotConnectorsDeleteFuture.Result. +func (future *IotConnectorsDeleteFuture) result(client IotConnectorsClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "healthcareapis.IotConnectorsDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("healthcareapis.IotConnectorsDeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// IotConnectorsUpdateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type IotConnectorsUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(IotConnectorsClient) (IotConnector, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *IotConnectorsUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for IotConnectorsUpdateFuture.Result. +func (future *IotConnectorsUpdateFuture) result(client IotConnectorsClient) (ic IotConnector, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "healthcareapis.IotConnectorsUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ic.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("healthcareapis.IotConnectorsUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if ic.Response.Response, err = future.GetResult(sender); err == nil && ic.Response.Response.StatusCode != http.StatusNoContent { + ic, err = client.UpdateResponder(ic.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "healthcareapis.IotConnectorsUpdateFuture", "Result", ic.Response.Response, "Failure responding to request") + } + } + return +} + +// IotDestinationProperties common IoT Connector destination properties. +type IotDestinationProperties struct { + // ProvisioningState - The provisioning state. Possible values include: 'ProvisioningStateDeleting', 'ProvisioningStateSucceeded', 'ProvisioningStateCreating', 'ProvisioningStateAccepted', 'ProvisioningStateVerifying', 'ProvisioningStateUpdating', 'ProvisioningStateFailed', 'ProvisioningStateCanceled', 'ProvisioningStateDeprovisioned', 'ProvisioningStateMoving', 'ProvisioningStateSuspended', 'ProvisioningStateWarned', 'ProvisioningStateSystemMaintenance' + ProvisioningState ProvisioningState `json:"provisioningState,omitempty"` +} + +// IotEventHubIngestionEndpointConfiguration event Hub ingestion endpoint configuration +type IotEventHubIngestionEndpointConfiguration struct { + // EventHubName - Event Hub name to connect to. + EventHubName *string `json:"eventHubName,omitempty"` + // ConsumerGroup - Consumer group of the event hub to connected to. + ConsumerGroup *string `json:"consumerGroup,omitempty"` + // FullyQualifiedEventHubNamespace - Fully qualified namespace of the Event Hub to connect to. + FullyQualifiedEventHubNamespace *string `json:"fullyQualifiedEventHubNamespace,omitempty"` +} + +// IotFhirDestination ioT Connector FHIR destination definition. +type IotFhirDestination struct { + autorest.Response `json:"-"` + // IotFhirDestinationProperties - IoT FHIR Destination settings. + *IotFhirDestinationProperties `json:"properties,omitempty"` + // SystemData - Metadata pertaining to creation and last modification of the resource. + SystemData *SystemData `json:"systemData,omitempty"` + // Location - The resource location. + Location *string `json:"location,omitempty"` + // ID - READ-ONLY; The resource identifier. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The resource type. + Type *string `json:"type,omitempty"` + // Etag - An etag associated with the resource, used for optimistic concurrency when editing it. + Etag *string `json:"etag,omitempty"` +} + +// MarshalJSON is the custom marshaler for IotFhirDestination. +func (ifd IotFhirDestination) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ifd.IotFhirDestinationProperties != nil { + objectMap["properties"] = ifd.IotFhirDestinationProperties + } + if ifd.SystemData != nil { + objectMap["systemData"] = ifd.SystemData + } + if ifd.Location != nil { + objectMap["location"] = ifd.Location + } + if ifd.Etag != nil { + objectMap["etag"] = ifd.Etag + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for IotFhirDestination struct. +func (ifd *IotFhirDestination) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var iotFhirDestinationProperties IotFhirDestinationProperties + err = json.Unmarshal(*v, &iotFhirDestinationProperties) + if err != nil { + return err + } + ifd.IotFhirDestinationProperties = &iotFhirDestinationProperties + } + case "systemData": + if v != nil { + var systemData SystemData + err = json.Unmarshal(*v, &systemData) + if err != nil { + return err + } + ifd.SystemData = &systemData + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + ifd.Location = &location + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + ifd.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + ifd.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + ifd.Type = &typeVar + } + case "etag": + if v != nil { + var etag string + err = json.Unmarshal(*v, &etag) + if err != nil { + return err + } + ifd.Etag = &etag + } + } + } + + return nil +} + +// IotFhirDestinationCollection a collection of IoT Connector FHIR destinations. +type IotFhirDestinationCollection struct { + autorest.Response `json:"-"` + // NextLink - The link used to get the next page of IoT FHIR destinations. + NextLink *string `json:"nextLink,omitempty"` + // Value - The list of IoT Connector FHIR destinations. + Value *[]IotFhirDestination `json:"value,omitempty"` +} + +// IotFhirDestinationCollectionIterator provides access to a complete listing of IotFhirDestination values. +type IotFhirDestinationCollectionIterator struct { + i int + page IotFhirDestinationCollectionPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *IotFhirDestinationCollectionIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/IotFhirDestinationCollectionIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *IotFhirDestinationCollectionIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter IotFhirDestinationCollectionIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter IotFhirDestinationCollectionIterator) Response() IotFhirDestinationCollection { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter IotFhirDestinationCollectionIterator) Value() IotFhirDestination { + if !iter.page.NotDone() { + return IotFhirDestination{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the IotFhirDestinationCollectionIterator type. +func NewIotFhirDestinationCollectionIterator(page IotFhirDestinationCollectionPage) IotFhirDestinationCollectionIterator { + return IotFhirDestinationCollectionIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (ifdc IotFhirDestinationCollection) IsEmpty() bool { + return ifdc.Value == nil || len(*ifdc.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (ifdc IotFhirDestinationCollection) hasNextLink() bool { + return ifdc.NextLink != nil && len(*ifdc.NextLink) != 0 +} + +// iotFhirDestinationCollectionPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (ifdc IotFhirDestinationCollection) iotFhirDestinationCollectionPreparer(ctx context.Context) (*http.Request, error) { + if !ifdc.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(ifdc.NextLink))) +} + +// IotFhirDestinationCollectionPage contains a page of IotFhirDestination values. +type IotFhirDestinationCollectionPage struct { + fn func(context.Context, IotFhirDestinationCollection) (IotFhirDestinationCollection, error) + ifdc IotFhirDestinationCollection +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *IotFhirDestinationCollectionPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/IotFhirDestinationCollectionPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.ifdc) + if err != nil { + return err + } + page.ifdc = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *IotFhirDestinationCollectionPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page IotFhirDestinationCollectionPage) NotDone() bool { + return !page.ifdc.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page IotFhirDestinationCollectionPage) Response() IotFhirDestinationCollection { + return page.ifdc +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page IotFhirDestinationCollectionPage) Values() []IotFhirDestination { + if page.ifdc.IsEmpty() { + return nil + } + return *page.ifdc.Value +} + +// Creates a new instance of the IotFhirDestinationCollectionPage type. +func NewIotFhirDestinationCollectionPage(cur IotFhirDestinationCollection, getNextPage func(context.Context, IotFhirDestinationCollection) (IotFhirDestinationCollection, error)) IotFhirDestinationCollectionPage { + return IotFhirDestinationCollectionPage{ + fn: getNextPage, + ifdc: cur, + } +} + +// IotFhirDestinationProperties ioT Connector destination properties for an Azure FHIR service. +type IotFhirDestinationProperties struct { + // ResourceIdentityResolutionType - Determines how resource identity is resolved on the destination. Possible values include: 'IotIdentityResolutionTypeCreate', 'IotIdentityResolutionTypeLookup' + ResourceIdentityResolutionType IotIdentityResolutionType `json:"resourceIdentityResolutionType,omitempty"` + // FhirServiceResourceID - Fully qualified resource id of the FHIR service to connect to. + FhirServiceResourceID *string `json:"fhirServiceResourceId,omitempty"` + // FhirMapping - FHIR Mappings + FhirMapping *IotMappingProperties `json:"fhirMapping,omitempty"` + // ProvisioningState - The provisioning state. Possible values include: 'ProvisioningStateDeleting', 'ProvisioningStateSucceeded', 'ProvisioningStateCreating', 'ProvisioningStateAccepted', 'ProvisioningStateVerifying', 'ProvisioningStateUpdating', 'ProvisioningStateFailed', 'ProvisioningStateCanceled', 'ProvisioningStateDeprovisioned', 'ProvisioningStateMoving', 'ProvisioningStateSuspended', 'ProvisioningStateWarned', 'ProvisioningStateSystemMaintenance' + ProvisioningState ProvisioningState `json:"provisioningState,omitempty"` +} + +// IotMappingProperties the mapping content. +type IotMappingProperties struct { + // Content - The mapping. + Content interface{} `json:"content,omitempty"` +} + +// ListOperations available operations of the service +type ListOperations struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; Collection of available operation details + Value *[]OperationDetail `json:"value,omitempty"` + // NextLink - URL client should use to fetch the next page (per server side paging). + // It's null for now, added for future use. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for ListOperations. +func (lo ListOperations) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if lo.NextLink != nil { + objectMap["nextLink"] = lo.NextLink + } + return json.Marshal(objectMap) +} + +// ListOperationsIterator provides access to a complete listing of OperationDetail values. +type ListOperationsIterator struct { + i int + page ListOperationsPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *ListOperationsIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ListOperationsIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *ListOperationsIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter ListOperationsIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter ListOperationsIterator) Response() ListOperations { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter ListOperationsIterator) Value() OperationDetail { + if !iter.page.NotDone() { + return OperationDetail{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the ListOperationsIterator type. +func NewListOperationsIterator(page ListOperationsPage) ListOperationsIterator { + return ListOperationsIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (lo ListOperations) IsEmpty() bool { + return lo.Value == nil || len(*lo.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (lo ListOperations) hasNextLink() bool { + return lo.NextLink != nil && len(*lo.NextLink) != 0 +} + +// listOperationsPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (lo ListOperations) listOperationsPreparer(ctx context.Context) (*http.Request, error) { + if !lo.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(lo.NextLink))) +} + +// ListOperationsPage contains a page of OperationDetail values. +type ListOperationsPage struct { + fn func(context.Context, ListOperations) (ListOperations, error) + lo ListOperations +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *ListOperationsPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ListOperationsPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.lo) + if err != nil { + return err + } + page.lo = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *ListOperationsPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page ListOperationsPage) NotDone() bool { + return !page.lo.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page ListOperationsPage) Response() ListOperations { + return page.lo +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page ListOperationsPage) Values() []OperationDetail { + if page.lo.IsEmpty() { + return nil + } + return *page.lo.Value +} + +// Creates a new instance of the ListOperationsPage type. +func NewListOperationsPage(cur ListOperations, getNextPage func(context.Context, ListOperations) (ListOperations, error)) ListOperationsPage { + return ListOperationsPage{ + fn: getNextPage, + lo: cur, + } +} + +// LocationBasedResource the common properties for any location based resource, tracked or proxy. +type LocationBasedResource struct { + // Location - The resource location. + Location *string `json:"location,omitempty"` + // ID - READ-ONLY; The resource identifier. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The resource type. + Type *string `json:"type,omitempty"` + // Etag - An etag associated with the resource, used for optimistic concurrency when editing it. + Etag *string `json:"etag,omitempty"` +} + +// MarshalJSON is the custom marshaler for LocationBasedResource. +func (lbr LocationBasedResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if lbr.Location != nil { + objectMap["location"] = lbr.Location + } + if lbr.Etag != nil { + objectMap["etag"] = lbr.Etag + } + return json.Marshal(objectMap) +} + +// LogSpecification specifications of the Log for Azure Monitoring +type LogSpecification struct { + // Name - Name of the log + Name *string `json:"name,omitempty"` + // DisplayName - Localized friendly display name of the log + DisplayName *string `json:"displayName,omitempty"` + // BlobDuration - Blob duration of the log + BlobDuration *string `json:"blobDuration,omitempty"` +} + +// MetricDimension specifications of the Dimension of metrics +type MetricDimension struct { + // Name - Name of the dimension + Name *string `json:"name,omitempty"` + // DisplayName - Localized friendly display name of the dimension + DisplayName *string `json:"displayName,omitempty"` + // ToBeExportedForShoebox - Whether this dimension should be included for the Shoebox export scenario + ToBeExportedForShoebox *bool `json:"toBeExportedForShoebox,omitempty"` +} + +// MetricSpecification specifications of the Metrics for Azure Monitoring +type MetricSpecification struct { + // Name - Name of the metric + Name *string `json:"name,omitempty"` + // DisplayName - Localized friendly display name of the metric + DisplayName *string `json:"displayName,omitempty"` + // DisplayDescription - Localized friendly description of the metric + DisplayDescription *string `json:"displayDescription,omitempty"` + // Unit - Unit that makes sense for the metric + Unit *string `json:"unit,omitempty"` + // Category - Name of the metric category that the metric belongs to. A metric can only belong to a single category. + Category *string `json:"category,omitempty"` + // AggregationType - Only provide one value for this field. Valid values: Average, Minimum, Maximum, Total, Count. + AggregationType *string `json:"aggregationType,omitempty"` + // SupportedAggregationTypes - Supported aggregation types + SupportedAggregationTypes *[]string `json:"supportedAggregationTypes,omitempty"` + // SupportedTimeGrainTypes - Supported time grain types + SupportedTimeGrainTypes *[]string `json:"supportedTimeGrainTypes,omitempty"` + // FillGapWithZero - Optional. If set to true, then zero will be returned for time duration where no metric is emitted/published. + FillGapWithZero *bool `json:"fillGapWithZero,omitempty"` + // Dimensions - Dimensions of the metric + Dimensions *[]MetricDimension `json:"dimensions,omitempty"` + // SourceMdmNamespace - Name of the MDM namespace. Optional. + SourceMdmNamespace *string `json:"sourceMdmNamespace,omitempty"` +} + +// OperationDetail service REST API operation. +type OperationDetail struct { + // Name - READ-ONLY; Name of the operation + Name *string `json:"name,omitempty"` + // IsDataAction - READ-ONLY; Whether the operation applies to data-plane. This is "true" for data-plane operations and "false" for ARM/control-plane operations. + IsDataAction *bool `json:"isDataAction,omitempty"` + // Display - Display of the operation + Display *OperationDisplay `json:"display,omitempty"` + // Origin - READ-ONLY; Default value is 'user,system'. + Origin *string `json:"origin,omitempty"` + // ActionType - READ-ONLY; Enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. Possible values include: 'ActionTypeInternal' + ActionType ActionType `json:"actionType,omitempty"` + // Properties - Properties of the operation + Properties *OperationProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for OperationDetail. +func (od OperationDetail) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if od.Display != nil { + objectMap["display"] = od.Display + } + if od.Properties != nil { + objectMap["properties"] = od.Properties + } + return json.Marshal(objectMap) +} + +// OperationDisplay the object that represents the operation. +type OperationDisplay struct { + // Provider - READ-ONLY; Service provider: Microsoft.HealthcareApis + Provider *string `json:"provider,omitempty"` + // Resource - READ-ONLY; Resource Type: Services + Resource *string `json:"resource,omitempty"` + // Operation - READ-ONLY; Name of the operation + Operation *string `json:"operation,omitempty"` + // Description - READ-ONLY; Friendly description for the operation, + Description *string `json:"description,omitempty"` +} + +// MarshalJSON is the custom marshaler for OperationDisplay. +func (od OperationDisplay) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// OperationProperties extra Operation properties +type OperationProperties struct { + // ServiceSpecification - Service specifications of the operation + ServiceSpecification *ServiceSpecification `json:"serviceSpecification,omitempty"` +} + +// OperationResultsDescription the properties indicating the operation result of an operation on a service. +type OperationResultsDescription struct { + autorest.Response `json:"-"` + // ID - READ-ONLY; The ID of the operation returned. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the operation result. + Name *string `json:"name,omitempty"` + // Status - READ-ONLY; The status of the operation being performed. Possible values include: 'OperationResultStatusCanceled', 'OperationResultStatusSucceeded', 'OperationResultStatusFailed', 'OperationResultStatusRequested', 'OperationResultStatusRunning' + Status OperationResultStatus `json:"status,omitempty"` + // StartTime - READ-ONLY; The time that the operation was started. + StartTime *string `json:"startTime,omitempty"` + // EndTime - READ-ONLY; The time that the operation finished. + EndTime *string `json:"endTime,omitempty"` + // Properties - Additional properties of the operation result. + Properties interface{} `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for OperationResultsDescription. +func (ord OperationResultsDescription) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ord.Properties != nil { + objectMap["properties"] = ord.Properties + } + return json.Marshal(objectMap) +} + +// PrivateEndpoint the Private Endpoint resource. +type PrivateEndpoint struct { + // ID - READ-ONLY; The ARM identifier for Private Endpoint + ID *string `json:"id,omitempty"` +} + +// MarshalJSON is the custom marshaler for PrivateEndpoint. +func (peVar PrivateEndpoint) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// PrivateEndpointConnection the Private Endpoint Connection resource. +type PrivateEndpointConnection struct { + // PrivateEndpointConnectionProperties - Resource properties. + *PrivateEndpointConnectionProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the resource + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for PrivateEndpointConnection. +func (pec PrivateEndpointConnection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if pec.PrivateEndpointConnectionProperties != nil { + objectMap["properties"] = pec.PrivateEndpointConnectionProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for PrivateEndpointConnection struct. +func (pec *PrivateEndpointConnection) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var privateEndpointConnectionProperties PrivateEndpointConnectionProperties + err = json.Unmarshal(*v, &privateEndpointConnectionProperties) + if err != nil { + return err + } + pec.PrivateEndpointConnectionProperties = &privateEndpointConnectionProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + pec.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + pec.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + pec.Type = &typeVar + } + } + } + + return nil +} + +// PrivateEndpointConnectionDescription the Private Endpoint Connection resource. +type PrivateEndpointConnectionDescription struct { + autorest.Response `json:"-"` + // SystemData - Metadata pertaining to creation and last modification of the resource. + SystemData *SystemData `json:"systemData,omitempty"` + // PrivateEndpointConnectionProperties - Resource properties. + *PrivateEndpointConnectionProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the resource + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for PrivateEndpointConnectionDescription. +func (pecd PrivateEndpointConnectionDescription) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if pecd.SystemData != nil { + objectMap["systemData"] = pecd.SystemData + } + if pecd.PrivateEndpointConnectionProperties != nil { + objectMap["properties"] = pecd.PrivateEndpointConnectionProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for PrivateEndpointConnectionDescription struct. +func (pecd *PrivateEndpointConnectionDescription) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "systemData": + if v != nil { + var systemData SystemData + err = json.Unmarshal(*v, &systemData) + if err != nil { + return err + } + pecd.SystemData = &systemData + } + case "properties": + if v != nil { + var privateEndpointConnectionProperties PrivateEndpointConnectionProperties + err = json.Unmarshal(*v, &privateEndpointConnectionProperties) + if err != nil { + return err + } + pecd.PrivateEndpointConnectionProperties = &privateEndpointConnectionProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + pecd.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + pecd.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + pecd.Type = &typeVar + } + } + } + + return nil +} + +// PrivateEndpointConnectionListResult list of private endpoint connection associated with the specified +// storage account +type PrivateEndpointConnectionListResult struct { + // Value - Array of private endpoint connections + Value *[]PrivateEndpointConnection `json:"value,omitempty"` +} + +// PrivateEndpointConnectionListResultDescription list of private endpoint connection associated with the +// specified storage account +type PrivateEndpointConnectionListResultDescription struct { + autorest.Response `json:"-"` + // Value - Array of private endpoint connections + Value *[]PrivateEndpointConnectionDescription `json:"value,omitempty"` +} + +// PrivateEndpointConnectionProperties properties of the PrivateEndpointConnectProperties. +type PrivateEndpointConnectionProperties struct { + // PrivateEndpoint - The resource of private end point. + PrivateEndpoint *PrivateEndpoint `json:"privateEndpoint,omitempty"` + // PrivateLinkServiceConnectionState - A collection of information about the state of the connection between service consumer and provider. + PrivateLinkServiceConnectionState *PrivateLinkServiceConnectionState `json:"privateLinkServiceConnectionState,omitempty"` + // ProvisioningState - The provisioning state of the private endpoint connection resource. Possible values include: 'PrivateEndpointConnectionProvisioningStateSucceeded', 'PrivateEndpointConnectionProvisioningStateCreating', 'PrivateEndpointConnectionProvisioningStateDeleting', 'PrivateEndpointConnectionProvisioningStateFailed' + ProvisioningState PrivateEndpointConnectionProvisioningState `json:"provisioningState,omitempty"` +} + +// PrivateEndpointConnectionsCreateOrUpdateFuture an abstraction for monitoring and retrieving the results +// of a long-running operation. +type PrivateEndpointConnectionsCreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(PrivateEndpointConnectionsClient) (PrivateEndpointConnectionDescription, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *PrivateEndpointConnectionsCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for PrivateEndpointConnectionsCreateOrUpdateFuture.Result. +func (future *PrivateEndpointConnectionsCreateOrUpdateFuture) result(client PrivateEndpointConnectionsClient) (pecd PrivateEndpointConnectionDescription, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "healthcareapis.PrivateEndpointConnectionsCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + pecd.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("healthcareapis.PrivateEndpointConnectionsCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if pecd.Response.Response, err = future.GetResult(sender); err == nil && pecd.Response.Response.StatusCode != http.StatusNoContent { + pecd, err = client.CreateOrUpdateResponder(pecd.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "healthcareapis.PrivateEndpointConnectionsCreateOrUpdateFuture", "Result", pecd.Response.Response, "Failure responding to request") + } + } + return +} + +// PrivateEndpointConnectionsDeleteFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type PrivateEndpointConnectionsDeleteFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(PrivateEndpointConnectionsClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *PrivateEndpointConnectionsDeleteFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for PrivateEndpointConnectionsDeleteFuture.Result. +func (future *PrivateEndpointConnectionsDeleteFuture) result(client PrivateEndpointConnectionsClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "healthcareapis.PrivateEndpointConnectionsDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("healthcareapis.PrivateEndpointConnectionsDeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// PrivateLinkResource a private link resource +type PrivateLinkResource struct { + // PrivateLinkResourceProperties - Resource properties. + *PrivateLinkResourceProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the resource + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for PrivateLinkResource. +func (plr PrivateLinkResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if plr.PrivateLinkResourceProperties != nil { + objectMap["properties"] = plr.PrivateLinkResourceProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for PrivateLinkResource struct. +func (plr *PrivateLinkResource) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var privateLinkResourceProperties PrivateLinkResourceProperties + err = json.Unmarshal(*v, &privateLinkResourceProperties) + if err != nil { + return err + } + plr.PrivateLinkResourceProperties = &privateLinkResourceProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + plr.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + plr.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + plr.Type = &typeVar + } + } + } + + return nil +} + +// PrivateLinkResourceDescription the Private Endpoint Connection resource. +type PrivateLinkResourceDescription struct { + autorest.Response `json:"-"` + // SystemData - Metadata pertaining to creation and last modification of the resource. + SystemData *SystemData `json:"systemData,omitempty"` + // PrivateLinkResourceProperties - Resource properties. + *PrivateLinkResourceProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the resource + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for PrivateLinkResourceDescription. +func (plrd PrivateLinkResourceDescription) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if plrd.SystemData != nil { + objectMap["systemData"] = plrd.SystemData + } + if plrd.PrivateLinkResourceProperties != nil { + objectMap["properties"] = plrd.PrivateLinkResourceProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for PrivateLinkResourceDescription struct. +func (plrd *PrivateLinkResourceDescription) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "systemData": + if v != nil { + var systemData SystemData + err = json.Unmarshal(*v, &systemData) + if err != nil { + return err + } + plrd.SystemData = &systemData + } + case "properties": + if v != nil { + var privateLinkResourceProperties PrivateLinkResourceProperties + err = json.Unmarshal(*v, &privateLinkResourceProperties) + if err != nil { + return err + } + plrd.PrivateLinkResourceProperties = &privateLinkResourceProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + plrd.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + plrd.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + plrd.Type = &typeVar + } + } + } + + return nil +} + +// PrivateLinkResourceListResultDescription a list of private link resources +type PrivateLinkResourceListResultDescription struct { + autorest.Response `json:"-"` + // Value - Array of private link resources + Value *[]PrivateLinkResourceDescription `json:"value,omitempty"` +} + +// PrivateLinkResourceProperties properties of a private link resource. +type PrivateLinkResourceProperties struct { + // GroupID - READ-ONLY; The private link resource group id. + GroupID *string `json:"groupId,omitempty"` + // RequiredMembers - READ-ONLY; The private link resource required member names. + RequiredMembers *[]string `json:"requiredMembers,omitempty"` + // RequiredZoneNames - The private link resource Private link DNS zone name. + RequiredZoneNames *[]string `json:"requiredZoneNames,omitempty"` +} + +// MarshalJSON is the custom marshaler for PrivateLinkResourceProperties. +func (plrp PrivateLinkResourceProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if plrp.RequiredZoneNames != nil { + objectMap["requiredZoneNames"] = plrp.RequiredZoneNames + } + return json.Marshal(objectMap) +} + +// PrivateLinkServiceConnectionState a collection of information about the state of the connection between +// service consumer and provider. +type PrivateLinkServiceConnectionState struct { + // Status - Indicates whether the connection has been Approved/Rejected/Removed by the owner of the service. Possible values include: 'PrivateEndpointServiceConnectionStatusPending', 'PrivateEndpointServiceConnectionStatusApproved', 'PrivateEndpointServiceConnectionStatusRejected' + Status PrivateEndpointServiceConnectionStatus `json:"status,omitempty"` + // Description - The reason for approval/rejection of the connection. + Description *string `json:"description,omitempty"` + // ActionsRequired - A message indicating if changes on the service provider require any updates on the consumer. + ActionsRequired *string `json:"actionsRequired,omitempty"` +} + +// ProxyResource the resource model definition for a Azure Resource Manager proxy resource. It will not +// have tags and a location +type ProxyResource struct { + // ID - READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the resource + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ProxyResource. +func (pr ProxyResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// Resource common fields that are returned in the response for all Azure Resource Manager resources +type Resource struct { + // ID - READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the resource + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for Resource. +func (r Resource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ResourceCore the common properties for any resource, tracked or proxy. +type ResourceCore struct { + // ID - READ-ONLY; The resource identifier. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The resource type. + Type *string `json:"type,omitempty"` + // Etag - An etag associated with the resource, used for optimistic concurrency when editing it. + Etag *string `json:"etag,omitempty"` +} + +// MarshalJSON is the custom marshaler for ResourceCore. +func (rc ResourceCore) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if rc.Etag != nil { + objectMap["etag"] = rc.Etag + } + return json.Marshal(objectMap) +} + +// ResourceTags list of key value pairs that describe the resource. This will overwrite the existing tags. +type ResourceTags struct { + // Tags - Resource tags. + Tags map[string]*string `json:"tags"` +} + +// MarshalJSON is the custom marshaler for ResourceTags. +func (rt ResourceTags) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if rt.Tags != nil { + objectMap["tags"] = rt.Tags + } + return json.Marshal(objectMap) +} + +// ResourceVersionPolicyConfiguration the settings for history tracking for FHIR resources. +type ResourceVersionPolicyConfiguration struct { + // Default - The default value for tracking history across all resources. Possible values include: 'FhirResourceVersionPolicyNoVersion', 'FhirResourceVersionPolicyVersioned', 'FhirResourceVersionPolicyVersionedUpdate' + Default FhirResourceVersionPolicy `json:"default,omitempty"` + // ResourceTypeOverrides - A list of FHIR Resources and their version policy overrides. + ResourceTypeOverrides map[string]*FhirResourceVersionPolicy `json:"resourceTypeOverrides"` +} + +// MarshalJSON is the custom marshaler for ResourceVersionPolicyConfiguration. +func (rvpc ResourceVersionPolicyConfiguration) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if rvpc.Default != "" { + objectMap["default"] = rvpc.Default + } + if rvpc.ResourceTypeOverrides != nil { + objectMap["resourceTypeOverrides"] = rvpc.ResourceTypeOverrides + } + return json.Marshal(objectMap) +} + +// ServiceAccessPolicyEntry an access policy entry. +type ServiceAccessPolicyEntry struct { + // ObjectID - An Azure AD object ID (User or Apps) that is allowed access to the FHIR service. + ObjectID *string `json:"objectId,omitempty"` +} + +// ServiceAcrConfigurationInfo azure container registry configuration information +type ServiceAcrConfigurationInfo struct { + // LoginServers - The list of the ACR login servers. + LoginServers *[]string `json:"loginServers,omitempty"` + // OciArtifacts - The list of Open Container Initiative (OCI) artifacts. + OciArtifacts *[]ServiceOciArtifactEntry `json:"ociArtifacts,omitempty"` +} + +// ServiceAuthenticationConfigurationInfo authentication configuration information +type ServiceAuthenticationConfigurationInfo struct { + // Authority - The authority url for the service + Authority *string `json:"authority,omitempty"` + // Audience - The audience url for the service + Audience *string `json:"audience,omitempty"` + // SmartProxyEnabled - If the SMART on FHIR proxy is enabled + SmartProxyEnabled *bool `json:"smartProxyEnabled,omitempty"` +} + +// ServiceCorsConfigurationInfo the settings for the CORS configuration of the service instance. +type ServiceCorsConfigurationInfo struct { + // Origins - The origins to be allowed via CORS. + Origins *[]string `json:"origins,omitempty"` + // Headers - The headers to be allowed via CORS. + Headers *[]string `json:"headers,omitempty"` + // Methods - The methods to be allowed via CORS. + Methods *[]string `json:"methods,omitempty"` + // MaxAge - The max age to be allowed via CORS. + MaxAge *int32 `json:"maxAge,omitempty"` + // AllowCredentials - If credentials are allowed via CORS. + AllowCredentials *bool `json:"allowCredentials,omitempty"` +} + +// ServiceCosmosDbConfigurationInfo the settings for the Cosmos DB database backing the service. +type ServiceCosmosDbConfigurationInfo struct { + // OfferThroughput - The provisioned throughput for the backing database. + OfferThroughput *int32 `json:"offerThroughput,omitempty"` + // KeyVaultKeyURI - The URI of the customer-managed key for the backing database. + KeyVaultKeyURI *string `json:"keyVaultKeyUri,omitempty"` +} + +// ServiceExportConfigurationInfo export operation configuration information +type ServiceExportConfigurationInfo struct { + // StorageAccountName - The name of the default export storage account. + StorageAccountName *string `json:"storageAccountName,omitempty"` +} + +// ServiceManagedIdentity managed service identity (system assigned and/or user assigned identities) +type ServiceManagedIdentity struct { + // Identity - Setting indicating whether the service has a managed identity associated with it. + Identity *ServiceManagedIdentityIdentity `json:"identity,omitempty"` +} + +// ServiceManagedIdentityIdentity setting indicating whether the service has a managed identity associated +// with it. +type ServiceManagedIdentityIdentity struct { + // Type - Type of identity being specified, currently SystemAssigned and None are allowed. Possible values include: 'ServiceManagedIdentityTypeNone', 'ServiceManagedIdentityTypeSystemAssigned', 'ServiceManagedIdentityTypeUserAssigned', 'ServiceManagedIdentityTypeSystemAssignedUserAssigned' + Type ServiceManagedIdentityType `json:"type,omitempty"` + // PrincipalID - READ-ONLY; The service principal ID of the system assigned identity. This property will only be provided for a system assigned identity. + PrincipalID *uuid.UUID `json:"principalId,omitempty"` + // TenantID - READ-ONLY; The tenant ID of the system assigned identity. This property will only be provided for a system assigned identity. + TenantID *uuid.UUID `json:"tenantId,omitempty"` + UserAssignedIdentities map[string]*UserAssignedIdentity `json:"userAssignedIdentities"` +} + +// MarshalJSON is the custom marshaler for ServiceManagedIdentityIdentity. +func (smi ServiceManagedIdentityIdentity) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if smi.Type != "" { + objectMap["type"] = smi.Type + } + if smi.UserAssignedIdentities != nil { + objectMap["userAssignedIdentities"] = smi.UserAssignedIdentities + } + return json.Marshal(objectMap) +} + +// ServiceOciArtifactEntry an Open Container Initiative (OCI) artifact. +type ServiceOciArtifactEntry struct { + // LoginServer - The Azure Container Registry login server. + LoginServer *string `json:"loginServer,omitempty"` + // ImageName - The artifact name. + ImageName *string `json:"imageName,omitempty"` + // Digest - The artifact digest. + Digest *string `json:"digest,omitempty"` +} + +// ServicesCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type ServicesCreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ServicesClient) (ServicesDescription, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ServicesCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for ServicesCreateOrUpdateFuture.Result. +func (future *ServicesCreateOrUpdateFuture) result(client ServicesClient) (sd ServicesDescription, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "healthcareapis.ServicesCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + sd.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("healthcareapis.ServicesCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if sd.Response.Response, err = future.GetResult(sender); err == nil && sd.Response.Response.StatusCode != http.StatusNoContent { + sd, err = client.CreateOrUpdateResponder(sd.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "healthcareapis.ServicesCreateOrUpdateFuture", "Result", sd.Response.Response, "Failure responding to request") + } + } + return +} + +// ServicesDeleteFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type ServicesDeleteFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ServicesClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ServicesDeleteFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for ServicesDeleteFuture.Result. +func (future *ServicesDeleteFuture) result(client ServicesClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "healthcareapis.ServicesDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("healthcareapis.ServicesDeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// ServicesDescription the description of the service. +type ServicesDescription struct { + autorest.Response `json:"-"` + // Properties - The common properties of a service. + Properties *ServicesProperties `json:"properties,omitempty"` + // SystemData - Metadata pertaining to creation and last modification of the resource. + SystemData *SystemData `json:"systemData,omitempty"` + // ID - READ-ONLY; The resource identifier. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The resource type. + Type *string `json:"type,omitempty"` + // Kind - The kind of the service. Possible values include: 'KindFhir', 'KindFhirStu3', 'KindFhirR4' + Kind Kind `json:"kind,omitempty"` + // Location - The resource location. + Location *string `json:"location,omitempty"` + // Tags - The resource tags. + Tags map[string]*string `json:"tags"` + // Etag - An etag associated with the resource, used for optimistic concurrency when editing it. + Etag *string `json:"etag,omitempty"` + // Identity - Setting indicating whether the service has a managed identity associated with it. + Identity *ServicesResourceIdentity `json:"identity,omitempty"` +} + +// MarshalJSON is the custom marshaler for ServicesDescription. +func (sd ServicesDescription) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if sd.Properties != nil { + objectMap["properties"] = sd.Properties + } + if sd.SystemData != nil { + objectMap["systemData"] = sd.SystemData + } + if sd.Kind != "" { + objectMap["kind"] = sd.Kind + } + if sd.Location != nil { + objectMap["location"] = sd.Location + } + if sd.Tags != nil { + objectMap["tags"] = sd.Tags + } + if sd.Etag != nil { + objectMap["etag"] = sd.Etag + } + if sd.Identity != nil { + objectMap["identity"] = sd.Identity + } + return json.Marshal(objectMap) +} + +// ServicesDescriptionListResult a list of service description objects with a next link. +type ServicesDescriptionListResult struct { + autorest.Response `json:"-"` + // NextLink - The link used to get the next page of service description objects. + NextLink *string `json:"nextLink,omitempty"` + // Value - A list of service description objects. + Value *[]ServicesDescription `json:"value,omitempty"` +} + +// ServicesDescriptionListResultIterator provides access to a complete listing of ServicesDescription +// values. +type ServicesDescriptionListResultIterator struct { + i int + page ServicesDescriptionListResultPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *ServicesDescriptionListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServicesDescriptionListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *ServicesDescriptionListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter ServicesDescriptionListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter ServicesDescriptionListResultIterator) Response() ServicesDescriptionListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter ServicesDescriptionListResultIterator) Value() ServicesDescription { + if !iter.page.NotDone() { + return ServicesDescription{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the ServicesDescriptionListResultIterator type. +func NewServicesDescriptionListResultIterator(page ServicesDescriptionListResultPage) ServicesDescriptionListResultIterator { + return ServicesDescriptionListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (sdlr ServicesDescriptionListResult) IsEmpty() bool { + return sdlr.Value == nil || len(*sdlr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (sdlr ServicesDescriptionListResult) hasNextLink() bool { + return sdlr.NextLink != nil && len(*sdlr.NextLink) != 0 +} + +// servicesDescriptionListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (sdlr ServicesDescriptionListResult) servicesDescriptionListResultPreparer(ctx context.Context) (*http.Request, error) { + if !sdlr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(sdlr.NextLink))) +} + +// ServicesDescriptionListResultPage contains a page of ServicesDescription values. +type ServicesDescriptionListResultPage struct { + fn func(context.Context, ServicesDescriptionListResult) (ServicesDescriptionListResult, error) + sdlr ServicesDescriptionListResult +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *ServicesDescriptionListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServicesDescriptionListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.sdlr) + if err != nil { + return err + } + page.sdlr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *ServicesDescriptionListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page ServicesDescriptionListResultPage) NotDone() bool { + return !page.sdlr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page ServicesDescriptionListResultPage) Response() ServicesDescriptionListResult { + return page.sdlr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page ServicesDescriptionListResultPage) Values() []ServicesDescription { + if page.sdlr.IsEmpty() { + return nil + } + return *page.sdlr.Value +} + +// Creates a new instance of the ServicesDescriptionListResultPage type. +func NewServicesDescriptionListResultPage(cur ServicesDescriptionListResult, getNextPage func(context.Context, ServicesDescriptionListResult) (ServicesDescriptionListResult, error)) ServicesDescriptionListResultPage { + return ServicesDescriptionListResultPage{ + fn: getNextPage, + sdlr: cur, + } +} + +// ServicesNameAvailabilityInfo the properties indicating whether a given service name is available. +type ServicesNameAvailabilityInfo struct { + autorest.Response `json:"-"` + // NameAvailable - READ-ONLY; The value which indicates whether the provided name is available. + NameAvailable *bool `json:"nameAvailable,omitempty"` + // Reason - READ-ONLY; The reason for unavailability. Possible values include: 'ServiceNameUnavailabilityReasonInvalid', 'ServiceNameUnavailabilityReasonAlreadyExists' + Reason ServiceNameUnavailabilityReason `json:"reason,omitempty"` + // Message - The detailed reason message. + Message *string `json:"message,omitempty"` +} + +// MarshalJSON is the custom marshaler for ServicesNameAvailabilityInfo. +func (snai ServicesNameAvailabilityInfo) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if snai.Message != nil { + objectMap["message"] = snai.Message + } + return json.Marshal(objectMap) +} + +// ServicesPatchDescription the description of the service. +type ServicesPatchDescription struct { + // Tags - Instance tags + Tags map[string]*string `json:"tags"` + // ServicesPropertiesUpdateParameters - The properties for updating a service instance. + *ServicesPropertiesUpdateParameters `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for ServicesPatchDescription. +func (spd ServicesPatchDescription) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if spd.Tags != nil { + objectMap["tags"] = spd.Tags + } + if spd.ServicesPropertiesUpdateParameters != nil { + objectMap["properties"] = spd.ServicesPropertiesUpdateParameters + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ServicesPatchDescription struct. +func (spd *ServicesPatchDescription) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + spd.Tags = tags + } + case "properties": + if v != nil { + var servicesPropertiesUpdateParameters ServicesPropertiesUpdateParameters + err = json.Unmarshal(*v, &servicesPropertiesUpdateParameters) + if err != nil { + return err + } + spd.ServicesPropertiesUpdateParameters = &servicesPropertiesUpdateParameters + } + } + } + + return nil +} + +// ServiceSpecification service specification payload +type ServiceSpecification struct { + // LogSpecifications - Specifications of the Log for Azure Monitoring + LogSpecifications *[]LogSpecification `json:"logSpecifications,omitempty"` + // MetricSpecifications - Specifications of the Metrics for Azure Monitoring + MetricSpecifications *[]MetricSpecification `json:"metricSpecifications,omitempty"` +} + +// ServicesProperties the properties of a service instance. +type ServicesProperties struct { + // ProvisioningState - The provisioning state. Possible values include: 'ProvisioningStateDeleting', 'ProvisioningStateSucceeded', 'ProvisioningStateCreating', 'ProvisioningStateAccepted', 'ProvisioningStateVerifying', 'ProvisioningStateUpdating', 'ProvisioningStateFailed', 'ProvisioningStateCanceled', 'ProvisioningStateDeprovisioned', 'ProvisioningStateMoving', 'ProvisioningStateSuspended', 'ProvisioningStateWarned', 'ProvisioningStateSystemMaintenance' + ProvisioningState ProvisioningState `json:"provisioningState,omitempty"` + // AccessPolicies - The access policies of the service instance. + AccessPolicies *[]ServiceAccessPolicyEntry `json:"accessPolicies,omitempty"` + // CosmosDbConfiguration - The settings for the Cosmos DB database backing the service. + CosmosDbConfiguration *ServiceCosmosDbConfigurationInfo `json:"cosmosDbConfiguration,omitempty"` + // AuthenticationConfiguration - The authentication configuration for the service instance. + AuthenticationConfiguration *ServiceAuthenticationConfigurationInfo `json:"authenticationConfiguration,omitempty"` + // CorsConfiguration - The settings for the CORS configuration of the service instance. + CorsConfiguration *ServiceCorsConfigurationInfo `json:"corsConfiguration,omitempty"` + // ExportConfiguration - The settings for the export operation of the service instance. + ExportConfiguration *ServiceExportConfigurationInfo `json:"exportConfiguration,omitempty"` + // PrivateEndpointConnections - The list of private endpoint connections that are set up for this resource. + PrivateEndpointConnections *[]PrivateEndpointConnection `json:"privateEndpointConnections,omitempty"` + // PublicNetworkAccess - Control permission for data plane traffic coming from public networks while private endpoint is enabled. Possible values include: 'PublicNetworkAccessEnabled', 'PublicNetworkAccessDisabled' + PublicNetworkAccess PublicNetworkAccess `json:"publicNetworkAccess,omitempty"` + // AcrConfiguration - The azure container registry settings used for convert data operation of the service instance. + AcrConfiguration *ServiceAcrConfigurationInfo `json:"acrConfiguration,omitempty"` +} + +// ServicesPropertiesUpdateParameters the properties for updating a service instance. +type ServicesPropertiesUpdateParameters struct { + // PublicNetworkAccess - Control permission for data plane traffic coming from public networks while private endpoint is enabled. Possible values include: 'PublicNetworkAccessEnabled', 'PublicNetworkAccessDisabled' + PublicNetworkAccess PublicNetworkAccess `json:"publicNetworkAccess,omitempty"` +} + +// ServicesResource the common properties of a service. +type ServicesResource struct { + // ID - READ-ONLY; The resource identifier. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The resource type. + Type *string `json:"type,omitempty"` + // Kind - The kind of the service. Possible values include: 'KindFhir', 'KindFhirStu3', 'KindFhirR4' + Kind Kind `json:"kind,omitempty"` + // Location - The resource location. + Location *string `json:"location,omitempty"` + // Tags - The resource tags. + Tags map[string]*string `json:"tags"` + // Etag - An etag associated with the resource, used for optimistic concurrency when editing it. + Etag *string `json:"etag,omitempty"` + // Identity - Setting indicating whether the service has a managed identity associated with it. + Identity *ServicesResourceIdentity `json:"identity,omitempty"` +} + +// MarshalJSON is the custom marshaler for ServicesResource. +func (sr ServicesResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if sr.Kind != "" { + objectMap["kind"] = sr.Kind + } + if sr.Location != nil { + objectMap["location"] = sr.Location + } + if sr.Tags != nil { + objectMap["tags"] = sr.Tags + } + if sr.Etag != nil { + objectMap["etag"] = sr.Etag + } + if sr.Identity != nil { + objectMap["identity"] = sr.Identity + } + return json.Marshal(objectMap) +} + +// ServicesResourceIdentity setting indicating whether the service has a managed identity associated with +// it. +type ServicesResourceIdentity struct { + // PrincipalID - READ-ONLY; The principal ID of the resource identity. + PrincipalID *string `json:"principalId,omitempty"` + // TenantID - READ-ONLY; The tenant ID of the resource. + TenantID *string `json:"tenantId,omitempty"` + // Type - Type of identity being specified, currently SystemAssigned and None are allowed. Possible values include: 'ManagedServiceIdentityTypeSystemAssigned', 'ManagedServiceIdentityTypeNone' + Type ManagedServiceIdentityType `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for ServicesResourceIdentity. +func (sr ServicesResourceIdentity) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if sr.Type != "" { + objectMap["type"] = sr.Type + } + return json.Marshal(objectMap) +} + +// ServicesUpdateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type ServicesUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(ServicesClient) (ServicesDescription, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *ServicesUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for ServicesUpdateFuture.Result. +func (future *ServicesUpdateFuture) result(client ServicesClient) (sd ServicesDescription, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "healthcareapis.ServicesUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + sd.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("healthcareapis.ServicesUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if sd.Response.Response, err = future.GetResult(sender); err == nil && sd.Response.Response.StatusCode != http.StatusNoContent { + sd, err = client.UpdateResponder(sd.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "healthcareapis.ServicesUpdateFuture", "Result", sd.Response.Response, "Failure responding to request") + } + } + return +} + +// SystemData metadata pertaining to creation and last modification of the resource. +type SystemData struct { + // CreatedBy - The identity that created the resource. + CreatedBy *string `json:"createdBy,omitempty"` + // CreatedByType - The type of identity that created the resource. Possible values include: 'CreatedByTypeUser', 'CreatedByTypeApplication', 'CreatedByTypeManagedIdentity', 'CreatedByTypeKey' + CreatedByType CreatedByType `json:"createdByType,omitempty"` + // CreatedAt - The timestamp of resource creation (UTC). + CreatedAt *date.Time `json:"createdAt,omitempty"` + // LastModifiedBy - The identity that last modified the resource. + LastModifiedBy *string `json:"lastModifiedBy,omitempty"` + // LastModifiedByType - The type of identity that last modified the resource. Possible values include: 'CreatedByTypeUser', 'CreatedByTypeApplication', 'CreatedByTypeManagedIdentity', 'CreatedByTypeKey' + LastModifiedByType CreatedByType `json:"lastModifiedByType,omitempty"` + // LastModifiedAt - The timestamp of resource last modification (UTC) + LastModifiedAt *date.Time `json:"lastModifiedAt,omitempty"` +} + +// TaggedResource the common properties of tracked resources in the service. +type TaggedResource struct { + // Tags - Resource tags. + Tags map[string]*string `json:"tags"` + // Location - The resource location. + Location *string `json:"location,omitempty"` +} + +// MarshalJSON is the custom marshaler for TaggedResource. +func (tr TaggedResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if tr.Tags != nil { + objectMap["tags"] = tr.Tags + } + if tr.Location != nil { + objectMap["location"] = tr.Location + } + return json.Marshal(objectMap) +} + +// TrackedResource the resource model definition for an Azure Resource Manager tracked top level resource +// which has 'tags' and a 'location' +type TrackedResource struct { + // Tags - Resource tags. + Tags map[string]*string `json:"tags"` + // Location - The geo-location where the resource lives + Location *string `json:"location,omitempty"` + // ID - READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the resource + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for TrackedResource. +func (tr TrackedResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if tr.Tags != nil { + objectMap["tags"] = tr.Tags + } + if tr.Location != nil { + objectMap["location"] = tr.Location + } + return json.Marshal(objectMap) +} + +// UserAssignedIdentity user assigned identity properties +type UserAssignedIdentity struct { + // PrincipalID - READ-ONLY; The principal ID of the assigned identity. + PrincipalID *uuid.UUID `json:"principalId,omitempty"` + // ClientID - READ-ONLY; The client ID of the assigned identity. + ClientID *uuid.UUID `json:"clientId,omitempty"` +} + +// MarshalJSON is the custom marshaler for UserAssignedIdentity. +func (uai UserAssignedIdentity) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// Workspace workspace resource. +type Workspace struct { + autorest.Response `json:"-"` + // Properties - Workspaces resource specific properties. + Properties *WorkspaceProperties `json:"properties,omitempty"` + // SystemData - Metadata pertaining to creation and last modification of the resource. + SystemData *SystemData `json:"systemData,omitempty"` + // Tags - Resource tags. + Tags map[string]*string `json:"tags"` + // Location - The resource location. + Location *string `json:"location,omitempty"` +} + +// MarshalJSON is the custom marshaler for Workspace. +func (w Workspace) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if w.Properties != nil { + objectMap["properties"] = w.Properties + } + if w.SystemData != nil { + objectMap["systemData"] = w.SystemData + } + if w.Tags != nil { + objectMap["tags"] = w.Tags + } + if w.Location != nil { + objectMap["location"] = w.Location + } + return json.Marshal(objectMap) +} + +// WorkspaceList collection of workspace object with a next link +type WorkspaceList struct { + autorest.Response `json:"-"` + // NextLink - The link used to get the next page. + NextLink *string `json:"nextLink,omitempty"` + // Value - Collection of resources. + Value *[]Workspace `json:"value,omitempty"` +} + +// WorkspaceListIterator provides access to a complete listing of Workspace values. +type WorkspaceListIterator struct { + i int + page WorkspaceListPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *WorkspaceListIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/WorkspaceListIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *WorkspaceListIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter WorkspaceListIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter WorkspaceListIterator) Response() WorkspaceList { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter WorkspaceListIterator) Value() Workspace { + if !iter.page.NotDone() { + return Workspace{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the WorkspaceListIterator type. +func NewWorkspaceListIterator(page WorkspaceListPage) WorkspaceListIterator { + return WorkspaceListIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (wl WorkspaceList) IsEmpty() bool { + return wl.Value == nil || len(*wl.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (wl WorkspaceList) hasNextLink() bool { + return wl.NextLink != nil && len(*wl.NextLink) != 0 +} + +// workspaceListPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (wl WorkspaceList) workspaceListPreparer(ctx context.Context) (*http.Request, error) { + if !wl.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(wl.NextLink))) +} + +// WorkspaceListPage contains a page of Workspace values. +type WorkspaceListPage struct { + fn func(context.Context, WorkspaceList) (WorkspaceList, error) + wl WorkspaceList +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *WorkspaceListPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/WorkspaceListPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.wl) + if err != nil { + return err + } + page.wl = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *WorkspaceListPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page WorkspaceListPage) NotDone() bool { + return !page.wl.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page WorkspaceListPage) Response() WorkspaceList { + return page.wl +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page WorkspaceListPage) Values() []Workspace { + if page.wl.IsEmpty() { + return nil + } + return *page.wl.Value +} + +// Creates a new instance of the WorkspaceListPage type. +func NewWorkspaceListPage(cur WorkspaceList, getNextPage func(context.Context, WorkspaceList) (WorkspaceList, error)) WorkspaceListPage { + return WorkspaceListPage{ + fn: getNextPage, + wl: cur, + } +} + +// WorkspacePatchResource workspace patch properties +type WorkspacePatchResource struct { + // Tags - Resource tags. + Tags map[string]*string `json:"tags"` +} + +// MarshalJSON is the custom marshaler for WorkspacePatchResource. +func (wpr WorkspacePatchResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if wpr.Tags != nil { + objectMap["tags"] = wpr.Tags + } + return json.Marshal(objectMap) +} + +// WorkspacePrivateEndpointConnectionsCreateOrUpdateFuture an abstraction for monitoring and retrieving the +// results of a long-running operation. +type WorkspacePrivateEndpointConnectionsCreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(WorkspacePrivateEndpointConnectionsClient) (PrivateEndpointConnectionDescription, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *WorkspacePrivateEndpointConnectionsCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for WorkspacePrivateEndpointConnectionsCreateOrUpdateFuture.Result. +func (future *WorkspacePrivateEndpointConnectionsCreateOrUpdateFuture) result(client WorkspacePrivateEndpointConnectionsClient) (pecd PrivateEndpointConnectionDescription, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "healthcareapis.WorkspacePrivateEndpointConnectionsCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + pecd.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("healthcareapis.WorkspacePrivateEndpointConnectionsCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if pecd.Response.Response, err = future.GetResult(sender); err == nil && pecd.Response.Response.StatusCode != http.StatusNoContent { + pecd, err = client.CreateOrUpdateResponder(pecd.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "healthcareapis.WorkspacePrivateEndpointConnectionsCreateOrUpdateFuture", "Result", pecd.Response.Response, "Failure responding to request") + } + } + return +} + +// WorkspacePrivateEndpointConnectionsDeleteFuture an abstraction for monitoring and retrieving the results +// of a long-running operation. +type WorkspacePrivateEndpointConnectionsDeleteFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(WorkspacePrivateEndpointConnectionsClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *WorkspacePrivateEndpointConnectionsDeleteFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for WorkspacePrivateEndpointConnectionsDeleteFuture.Result. +func (future *WorkspacePrivateEndpointConnectionsDeleteFuture) result(client WorkspacePrivateEndpointConnectionsClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "healthcareapis.WorkspacePrivateEndpointConnectionsDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("healthcareapis.WorkspacePrivateEndpointConnectionsDeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// WorkspaceProperties workspaces resource specific properties. +type WorkspaceProperties struct { + // ProvisioningState - The provisioning state. Possible values include: 'ProvisioningStateDeleting', 'ProvisioningStateSucceeded', 'ProvisioningStateCreating', 'ProvisioningStateAccepted', 'ProvisioningStateVerifying', 'ProvisioningStateUpdating', 'ProvisioningStateFailed', 'ProvisioningStateCanceled', 'ProvisioningStateDeprovisioned', 'ProvisioningStateMoving', 'ProvisioningStateSuspended', 'ProvisioningStateWarned', 'ProvisioningStateSystemMaintenance' + ProvisioningState ProvisioningState `json:"provisioningState,omitempty"` + // PrivateEndpointConnections - READ-ONLY; The list of private endpoint connections that are set up for this resource. + PrivateEndpointConnections *[]PrivateEndpointConnection `json:"privateEndpointConnections,omitempty"` + // PublicNetworkAccess - Control permission for data plane traffic coming from public networks while private endpoint is enabled. Possible values include: 'PublicNetworkAccessEnabled', 'PublicNetworkAccessDisabled' + PublicNetworkAccess PublicNetworkAccess `json:"publicNetworkAccess,omitempty"` +} + +// MarshalJSON is the custom marshaler for WorkspaceProperties. +func (w WorkspaceProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if w.ProvisioningState != "" { + objectMap["provisioningState"] = w.ProvisioningState + } + if w.PublicNetworkAccess != "" { + objectMap["publicNetworkAccess"] = w.PublicNetworkAccess + } + return json.Marshal(objectMap) +} + +// WorkspacesCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type WorkspacesCreateOrUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(WorkspacesClient) (Workspace, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *WorkspacesCreateOrUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for WorkspacesCreateOrUpdateFuture.Result. +func (future *WorkspacesCreateOrUpdateFuture) result(client WorkspacesClient) (w Workspace, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "healthcareapis.WorkspacesCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + w.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("healthcareapis.WorkspacesCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if w.Response.Response, err = future.GetResult(sender); err == nil && w.Response.Response.StatusCode != http.StatusNoContent { + w, err = client.CreateOrUpdateResponder(w.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "healthcareapis.WorkspacesCreateOrUpdateFuture", "Result", w.Response.Response, "Failure responding to request") + } + } + return +} + +// WorkspacesDeleteFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type WorkspacesDeleteFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(WorkspacesClient) (autorest.Response, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *WorkspacesDeleteFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for WorkspacesDeleteFuture.Result. +func (future *WorkspacesDeleteFuture) result(client WorkspacesClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "healthcareapis.WorkspacesDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + ar.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("healthcareapis.WorkspacesDeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// WorkspacesUpdateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type WorkspacesUpdateFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(WorkspacesClient) (Workspace, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *WorkspacesUpdateFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for WorkspacesUpdateFuture.Result. +func (future *WorkspacesUpdateFuture) result(client WorkspacesClient) (w Workspace, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "healthcareapis.WorkspacesUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + w.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("healthcareapis.WorkspacesUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if w.Response.Response, err = future.GetResult(sender); err == nil && w.Response.Response.StatusCode != http.StatusNoContent { + w, err = client.UpdateResponder(w.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "healthcareapis.WorkspacesUpdateFuture", "Result", w.Response.Response, "Failure responding to request") + } + } + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/healthcareapis/mgmt/2021-11-01/healthcareapis/operationresults.go b/vendor/github.com/Azure/azure-sdk-for-go/services/healthcareapis/mgmt/2021-11-01/healthcareapis/operationresults.go new file mode 100644 index 000000000000..28ade5c2b075 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/healthcareapis/mgmt/2021-11-01/healthcareapis/operationresults.go @@ -0,0 +1,108 @@ +package healthcareapis + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// OperationResultsClient is the azure Healthcare APIs Client +type OperationResultsClient struct { + BaseClient +} + +// NewOperationResultsClient creates an instance of the OperationResultsClient client. +func NewOperationResultsClient(subscriptionID string) OperationResultsClient { + return NewOperationResultsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewOperationResultsClientWithBaseURI creates an instance of the OperationResultsClient client using a custom +// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure +// stack). +func NewOperationResultsClientWithBaseURI(baseURI string, subscriptionID string) OperationResultsClient { + return OperationResultsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Get get the operation result for a long running operation. +// Parameters: +// locationName - the location of the operation. +// operationResultID - the ID of the operation result to get. +func (client OperationResultsClient) Get(ctx context.Context, locationName string, operationResultID string) (result OperationResultsDescription, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationResultsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, locationName, operationResultID) + if err != nil { + err = autorest.NewErrorWithError(err, "healthcareapis.OperationResultsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "healthcareapis.OperationResultsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "healthcareapis.OperationResultsClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client OperationResultsClient) GetPreparer(ctx context.Context, locationName string, operationResultID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "locationName": autorest.Encode("path", locationName), + "operationResultId": autorest.Encode("path", operationResultID), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-11-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.HealthcareApis/locations/{locationName}/operationresults/{operationResultId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client OperationResultsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client OperationResultsClient) GetResponder(resp *http.Response) (result OperationResultsDescription, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/healthcareapis/mgmt/2021-11-01/healthcareapis/operations.go b/vendor/github.com/Azure/azure-sdk-for-go/services/healthcareapis/mgmt/2021-11-01/healthcareapis/operations.go new file mode 100644 index 000000000000..50a4c1d972f4 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/healthcareapis/mgmt/2021-11-01/healthcareapis/operations.go @@ -0,0 +1,140 @@ +package healthcareapis + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// OperationsClient is the azure Healthcare APIs Client +type OperationsClient struct { + BaseClient +} + +// NewOperationsClient creates an instance of the OperationsClient client. +func NewOperationsClient(subscriptionID string) OperationsClient { + return NewOperationsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewOperationsClientWithBaseURI creates an instance of the OperationsClient client using a custom endpoint. Use this +// when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewOperationsClientWithBaseURI(baseURI string, subscriptionID string) OperationsClient { + return OperationsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// List lists all of the available operations supported by Microsoft Healthcare resource provider. +func (client OperationsClient) List(ctx context.Context) (result ListOperationsPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationsClient.List") + defer func() { + sc := -1 + if result.lo.Response.Response != nil { + sc = result.lo.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "healthcareapis.OperationsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.lo.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "healthcareapis.OperationsClient", "List", resp, "Failure sending request") + return + } + + result.lo, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "healthcareapis.OperationsClient", "List", resp, "Failure responding to request") + return + } + if result.lo.hasNextLink() && result.lo.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListPreparer prepares the List request. +func (client OperationsClient) ListPreparer(ctx context.Context) (*http.Request, error) { + const APIVersion = "2021-11-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPath("/providers/Microsoft.HealthcareApis/operations"), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client OperationsClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client OperationsClient) ListResponder(resp *http.Response) (result ListOperations, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client OperationsClient) listNextResults(ctx context.Context, lastResults ListOperations) (result ListOperations, err error) { + req, err := lastResults.listOperationsPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "healthcareapis.OperationsClient", "listNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "healthcareapis.OperationsClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "healthcareapis.OperationsClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client OperationsClient) ListComplete(ctx context.Context) (result ListOperationsIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationsClient.List") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.List(ctx) + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/healthcareapis/mgmt/2021-11-01/healthcareapis/privateendpointconnections.go b/vendor/github.com/Azure/azure-sdk-for-go/services/healthcareapis/mgmt/2021-11-01/healthcareapis/privateendpointconnections.go new file mode 100644 index 000000000000..f3a5894a99a1 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/healthcareapis/mgmt/2021-11-01/healthcareapis/privateendpointconnections.go @@ -0,0 +1,401 @@ +package healthcareapis + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// PrivateEndpointConnectionsClient is the azure Healthcare APIs Client +type PrivateEndpointConnectionsClient struct { + BaseClient +} + +// NewPrivateEndpointConnectionsClient creates an instance of the PrivateEndpointConnectionsClient client. +func NewPrivateEndpointConnectionsClient(subscriptionID string) PrivateEndpointConnectionsClient { + return NewPrivateEndpointConnectionsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewPrivateEndpointConnectionsClientWithBaseURI creates an instance of the PrivateEndpointConnectionsClient client +// using a custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign +// clouds, Azure stack). +func NewPrivateEndpointConnectionsClientWithBaseURI(baseURI string, subscriptionID string) PrivateEndpointConnectionsClient { + return PrivateEndpointConnectionsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate update the state of the specified private endpoint connection associated with the service. +// Parameters: +// resourceGroupName - the name of the resource group that contains the service instance. +// resourceName - the name of the service instance. +// privateEndpointConnectionName - the name of the private endpoint connection associated with the Azure +// resource +// properties - the private endpoint connection properties. +func (client PrivateEndpointConnectionsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, resourceName string, privateEndpointConnectionName string, properties PrivateEndpointConnection) (result PrivateEndpointConnectionsCreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateEndpointConnectionsClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: resourceName, + Constraints: []validation.Constraint{{Target: "resourceName", Name: validation.MaxLength, Rule: 24, Chain: nil}, + {Target: "resourceName", Name: validation.MinLength, Rule: 3, Chain: nil}}}, + {TargetValue: properties, + Constraints: []validation.Constraint{{Target: "properties.PrivateEndpointConnectionProperties", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "properties.PrivateEndpointConnectionProperties.PrivateLinkServiceConnectionState", Name: validation.Null, Rule: true, Chain: nil}}}}}}); err != nil { + return result, validation.NewError("healthcareapis.PrivateEndpointConnectionsClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, resourceName, privateEndpointConnectionName, properties) + if err != nil { + err = autorest.NewErrorWithError(err, "healthcareapis.PrivateEndpointConnectionsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "healthcareapis.PrivateEndpointConnectionsClient", "CreateOrUpdate", result.Response(), "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client PrivateEndpointConnectionsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, resourceName string, privateEndpointConnectionName string, properties PrivateEndpointConnection) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "privateEndpointConnectionName": autorest.Encode("path", privateEndpointConnectionName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-11-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HealthcareApis/services/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}", pathParameters), + autorest.WithJSON(properties), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client PrivateEndpointConnectionsClient) CreateOrUpdateSender(req *http.Request) (future PrivateEndpointConnectionsCreateOrUpdateFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client PrivateEndpointConnectionsClient) CreateOrUpdateResponder(resp *http.Response) (result PrivateEndpointConnectionDescription, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes a private endpoint connection. +// Parameters: +// resourceGroupName - the name of the resource group that contains the service instance. +// resourceName - the name of the service instance. +// privateEndpointConnectionName - the name of the private endpoint connection associated with the Azure +// resource +func (client PrivateEndpointConnectionsClient) Delete(ctx context.Context, resourceGroupName string, resourceName string, privateEndpointConnectionName string) (result PrivateEndpointConnectionsDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateEndpointConnectionsClient.Delete") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: resourceName, + Constraints: []validation.Constraint{{Target: "resourceName", Name: validation.MaxLength, Rule: 24, Chain: nil}, + {Target: "resourceName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil { + return result, validation.NewError("healthcareapis.PrivateEndpointConnectionsClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, resourceName, privateEndpointConnectionName) + if err != nil { + err = autorest.NewErrorWithError(err, "healthcareapis.PrivateEndpointConnectionsClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "healthcareapis.PrivateEndpointConnectionsClient", "Delete", result.Response(), "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client PrivateEndpointConnectionsClient) DeletePreparer(ctx context.Context, resourceGroupName string, resourceName string, privateEndpointConnectionName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "privateEndpointConnectionName": autorest.Encode("path", privateEndpointConnectionName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-11-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HealthcareApis/services/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client PrivateEndpointConnectionsClient) DeleteSender(req *http.Request) (future PrivateEndpointConnectionsDeleteFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client PrivateEndpointConnectionsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets the specified private endpoint connection associated with the service. +// Parameters: +// resourceGroupName - the name of the resource group that contains the service instance. +// resourceName - the name of the service instance. +// privateEndpointConnectionName - the name of the private endpoint connection associated with the Azure +// resource +func (client PrivateEndpointConnectionsClient) Get(ctx context.Context, resourceGroupName string, resourceName string, privateEndpointConnectionName string) (result PrivateEndpointConnectionDescription, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateEndpointConnectionsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: resourceName, + Constraints: []validation.Constraint{{Target: "resourceName", Name: validation.MaxLength, Rule: 24, Chain: nil}, + {Target: "resourceName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil { + return result, validation.NewError("healthcareapis.PrivateEndpointConnectionsClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, resourceName, privateEndpointConnectionName) + if err != nil { + err = autorest.NewErrorWithError(err, "healthcareapis.PrivateEndpointConnectionsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "healthcareapis.PrivateEndpointConnectionsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "healthcareapis.PrivateEndpointConnectionsClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client PrivateEndpointConnectionsClient) GetPreparer(ctx context.Context, resourceGroupName string, resourceName string, privateEndpointConnectionName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "privateEndpointConnectionName": autorest.Encode("path", privateEndpointConnectionName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-11-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HealthcareApis/services/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client PrivateEndpointConnectionsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client PrivateEndpointConnectionsClient) GetResponder(resp *http.Response) (result PrivateEndpointConnectionDescription, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByService lists all private endpoint connections for a service. +// Parameters: +// resourceGroupName - the name of the resource group that contains the service instance. +// resourceName - the name of the service instance. +func (client PrivateEndpointConnectionsClient) ListByService(ctx context.Context, resourceGroupName string, resourceName string) (result PrivateEndpointConnectionListResultDescription, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateEndpointConnectionsClient.ListByService") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: resourceName, + Constraints: []validation.Constraint{{Target: "resourceName", Name: validation.MaxLength, Rule: 24, Chain: nil}, + {Target: "resourceName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil { + return result, validation.NewError("healthcareapis.PrivateEndpointConnectionsClient", "ListByService", err.Error()) + } + + req, err := client.ListByServicePreparer(ctx, resourceGroupName, resourceName) + if err != nil { + err = autorest.NewErrorWithError(err, "healthcareapis.PrivateEndpointConnectionsClient", "ListByService", nil, "Failure preparing request") + return + } + + resp, err := client.ListByServiceSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "healthcareapis.PrivateEndpointConnectionsClient", "ListByService", resp, "Failure sending request") + return + } + + result, err = client.ListByServiceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "healthcareapis.PrivateEndpointConnectionsClient", "ListByService", resp, "Failure responding to request") + return + } + + return +} + +// ListByServicePreparer prepares the ListByService request. +func (client PrivateEndpointConnectionsClient) ListByServicePreparer(ctx context.Context, resourceGroupName string, resourceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-11-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HealthcareApis/services/{resourceName}/privateEndpointConnections", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByServiceSender sends the ListByService request. The method will close the +// http.Response Body if it receives an error. +func (client PrivateEndpointConnectionsClient) ListByServiceSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServiceResponder handles the response to the ListByService request. The method always +// closes the http.Response Body. +func (client PrivateEndpointConnectionsClient) ListByServiceResponder(resp *http.Response) (result PrivateEndpointConnectionListResultDescription, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/healthcareapis/mgmt/2021-11-01/healthcareapis/privatelinkresources.go b/vendor/github.com/Azure/azure-sdk-for-go/services/healthcareapis/mgmt/2021-11-01/healthcareapis/privatelinkresources.go new file mode 100644 index 000000000000..3b80ba00c812 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/healthcareapis/mgmt/2021-11-01/healthcareapis/privatelinkresources.go @@ -0,0 +1,209 @@ +package healthcareapis + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// PrivateLinkResourcesClient is the azure Healthcare APIs Client +type PrivateLinkResourcesClient struct { + BaseClient +} + +// NewPrivateLinkResourcesClient creates an instance of the PrivateLinkResourcesClient client. +func NewPrivateLinkResourcesClient(subscriptionID string) PrivateLinkResourcesClient { + return NewPrivateLinkResourcesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewPrivateLinkResourcesClientWithBaseURI creates an instance of the PrivateLinkResourcesClient client using a custom +// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure +// stack). +func NewPrivateLinkResourcesClientWithBaseURI(baseURI string, subscriptionID string) PrivateLinkResourcesClient { + return PrivateLinkResourcesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Get gets a private link resource that need to be created for a service. +// Parameters: +// resourceGroupName - the name of the resource group that contains the service instance. +// resourceName - the name of the service instance. +// groupName - the name of the private link resource group. +func (client PrivateLinkResourcesClient) Get(ctx context.Context, resourceGroupName string, resourceName string, groupName string) (result PrivateLinkResourceDescription, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateLinkResourcesClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: resourceName, + Constraints: []validation.Constraint{{Target: "resourceName", Name: validation.MaxLength, Rule: 24, Chain: nil}, + {Target: "resourceName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil { + return result, validation.NewError("healthcareapis.PrivateLinkResourcesClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, resourceName, groupName) + if err != nil { + err = autorest.NewErrorWithError(err, "healthcareapis.PrivateLinkResourcesClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "healthcareapis.PrivateLinkResourcesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "healthcareapis.PrivateLinkResourcesClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client PrivateLinkResourcesClient) GetPreparer(ctx context.Context, resourceGroupName string, resourceName string, groupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "groupName": autorest.Encode("path", groupName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-11-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HealthcareApis/services/{resourceName}/privateLinkResources/{groupName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client PrivateLinkResourcesClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client PrivateLinkResourcesClient) GetResponder(resp *http.Response) (result PrivateLinkResourceDescription, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByService gets the private link resources that need to be created for a service. +// Parameters: +// resourceGroupName - the name of the resource group that contains the service instance. +// resourceName - the name of the service instance. +func (client PrivateLinkResourcesClient) ListByService(ctx context.Context, resourceGroupName string, resourceName string) (result PrivateLinkResourceListResultDescription, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateLinkResourcesClient.ListByService") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: resourceName, + Constraints: []validation.Constraint{{Target: "resourceName", Name: validation.MaxLength, Rule: 24, Chain: nil}, + {Target: "resourceName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil { + return result, validation.NewError("healthcareapis.PrivateLinkResourcesClient", "ListByService", err.Error()) + } + + req, err := client.ListByServicePreparer(ctx, resourceGroupName, resourceName) + if err != nil { + err = autorest.NewErrorWithError(err, "healthcareapis.PrivateLinkResourcesClient", "ListByService", nil, "Failure preparing request") + return + } + + resp, err := client.ListByServiceSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "healthcareapis.PrivateLinkResourcesClient", "ListByService", resp, "Failure sending request") + return + } + + result, err = client.ListByServiceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "healthcareapis.PrivateLinkResourcesClient", "ListByService", resp, "Failure responding to request") + return + } + + return +} + +// ListByServicePreparer prepares the ListByService request. +func (client PrivateLinkResourcesClient) ListByServicePreparer(ctx context.Context, resourceGroupName string, resourceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-11-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HealthcareApis/services/{resourceName}/privateLinkResources", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByServiceSender sends the ListByService request. The method will close the +// http.Response Body if it receives an error. +func (client PrivateLinkResourcesClient) ListByServiceSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByServiceResponder handles the response to the ListByService request. The method always +// closes the http.Response Body. +func (client PrivateLinkResourcesClient) ListByServiceResponder(resp *http.Response) (result PrivateLinkResourceListResultDescription, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/healthcareapis/mgmt/2021-11-01/healthcareapis/services.go b/vendor/github.com/Azure/azure-sdk-for-go/services/healthcareapis/mgmt/2021-11-01/healthcareapis/services.go new file mode 100644 index 000000000000..736803fe6ed3 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/healthcareapis/mgmt/2021-11-01/healthcareapis/services.go @@ -0,0 +1,729 @@ +package healthcareapis + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// ServicesClient is the azure Healthcare APIs Client +type ServicesClient struct { + BaseClient +} + +// NewServicesClient creates an instance of the ServicesClient client. +func NewServicesClient(subscriptionID string) ServicesClient { + return NewServicesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewServicesClientWithBaseURI creates an instance of the ServicesClient client using a custom endpoint. Use this +// when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewServicesClientWithBaseURI(baseURI string, subscriptionID string) ServicesClient { + return ServicesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CheckNameAvailability check if a service instance name is available. +// Parameters: +// checkNameAvailabilityInputs - set the name parameter in the CheckNameAvailabilityParameters structure to the +// name of the service instance to check. +func (client ServicesClient) CheckNameAvailability(ctx context.Context, checkNameAvailabilityInputs CheckNameAvailabilityParameters) (result ServicesNameAvailabilityInfo, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServicesClient.CheckNameAvailability") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: checkNameAvailabilityInputs, + Constraints: []validation.Constraint{{Target: "checkNameAvailabilityInputs.Name", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "checkNameAvailabilityInputs.Type", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { + return result, validation.NewError("healthcareapis.ServicesClient", "CheckNameAvailability", err.Error()) + } + + req, err := client.CheckNameAvailabilityPreparer(ctx, checkNameAvailabilityInputs) + if err != nil { + err = autorest.NewErrorWithError(err, "healthcareapis.ServicesClient", "CheckNameAvailability", nil, "Failure preparing request") + return + } + + resp, err := client.CheckNameAvailabilitySender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "healthcareapis.ServicesClient", "CheckNameAvailability", resp, "Failure sending request") + return + } + + result, err = client.CheckNameAvailabilityResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "healthcareapis.ServicesClient", "CheckNameAvailability", resp, "Failure responding to request") + return + } + + return +} + +// CheckNameAvailabilityPreparer prepares the CheckNameAvailability request. +func (client ServicesClient) CheckNameAvailabilityPreparer(ctx context.Context, checkNameAvailabilityInputs CheckNameAvailabilityParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-11-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.HealthcareApis/checkNameAvailability", pathParameters), + autorest.WithJSON(checkNameAvailabilityInputs), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CheckNameAvailabilitySender sends the CheckNameAvailability request. The method will close the +// http.Response Body if it receives an error. +func (client ServicesClient) CheckNameAvailabilitySender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CheckNameAvailabilityResponder handles the response to the CheckNameAvailability request. The method always +// closes the http.Response Body. +func (client ServicesClient) CheckNameAvailabilityResponder(resp *http.Response) (result ServicesNameAvailabilityInfo, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// CreateOrUpdate create or update the metadata of a service instance. +// Parameters: +// resourceGroupName - the name of the resource group that contains the service instance. +// resourceName - the name of the service instance. +// serviceDescription - the service instance metadata. +func (client ServicesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, resourceName string, serviceDescription ServicesDescription) (result ServicesCreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServicesClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: resourceName, + Constraints: []validation.Constraint{{Target: "resourceName", Name: validation.MaxLength, Rule: 24, Chain: nil}, + {Target: "resourceName", Name: validation.MinLength, Rule: 3, Chain: nil}}}, + {TargetValue: serviceDescription, + Constraints: []validation.Constraint{{Target: "serviceDescription.Properties", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "serviceDescription.Properties.CosmosDbConfiguration", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "serviceDescription.Properties.CosmosDbConfiguration.OfferThroughput", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "serviceDescription.Properties.CosmosDbConfiguration.OfferThroughput", Name: validation.InclusiveMaximum, Rule: int64(10000), Chain: nil}, + {Target: "serviceDescription.Properties.CosmosDbConfiguration.OfferThroughput", Name: validation.InclusiveMinimum, Rule: int64(400), Chain: nil}, + }}, + }}, + {Target: "serviceDescription.Properties.CorsConfiguration", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "serviceDescription.Properties.CorsConfiguration.MaxAge", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "serviceDescription.Properties.CorsConfiguration.MaxAge", Name: validation.InclusiveMaximum, Rule: int64(99999), Chain: nil}, + {Target: "serviceDescription.Properties.CorsConfiguration.MaxAge", Name: validation.InclusiveMinimum, Rule: int64(0), Chain: nil}, + }}, + }}, + }}}}}); err != nil { + return result, validation.NewError("healthcareapis.ServicesClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, resourceName, serviceDescription) + if err != nil { + err = autorest.NewErrorWithError(err, "healthcareapis.ServicesClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "healthcareapis.ServicesClient", "CreateOrUpdate", result.Response(), "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client ServicesClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, resourceName string, serviceDescription ServicesDescription) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-11-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HealthcareApis/services/{resourceName}", pathParameters), + autorest.WithJSON(serviceDescription), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client ServicesClient) CreateOrUpdateSender(req *http.Request) (future ServicesCreateOrUpdateFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client ServicesClient) CreateOrUpdateResponder(resp *http.Response) (result ServicesDescription, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete delete a service instance. +// Parameters: +// resourceGroupName - the name of the resource group that contains the service instance. +// resourceName - the name of the service instance. +func (client ServicesClient) Delete(ctx context.Context, resourceGroupName string, resourceName string) (result ServicesDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServicesClient.Delete") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: resourceName, + Constraints: []validation.Constraint{{Target: "resourceName", Name: validation.MaxLength, Rule: 24, Chain: nil}, + {Target: "resourceName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil { + return result, validation.NewError("healthcareapis.ServicesClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, resourceName) + if err != nil { + err = autorest.NewErrorWithError(err, "healthcareapis.ServicesClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "healthcareapis.ServicesClient", "Delete", result.Response(), "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client ServicesClient) DeletePreparer(ctx context.Context, resourceGroupName string, resourceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-11-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HealthcareApis/services/{resourceName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client ServicesClient) DeleteSender(req *http.Request) (future ServicesDeleteFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client ServicesClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get get the metadata of a service instance. +// Parameters: +// resourceGroupName - the name of the resource group that contains the service instance. +// resourceName - the name of the service instance. +func (client ServicesClient) Get(ctx context.Context, resourceGroupName string, resourceName string) (result ServicesDescription, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServicesClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: resourceName, + Constraints: []validation.Constraint{{Target: "resourceName", Name: validation.MaxLength, Rule: 24, Chain: nil}, + {Target: "resourceName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil { + return result, validation.NewError("healthcareapis.ServicesClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, resourceName) + if err != nil { + err = autorest.NewErrorWithError(err, "healthcareapis.ServicesClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "healthcareapis.ServicesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "healthcareapis.ServicesClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client ServicesClient) GetPreparer(ctx context.Context, resourceGroupName string, resourceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-11-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HealthcareApis/services/{resourceName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client ServicesClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ServicesClient) GetResponder(resp *http.Response) (result ServicesDescription, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List get all the service instances in a subscription. +func (client ServicesClient) List(ctx context.Context) (result ServicesDescriptionListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServicesClient.List") + defer func() { + sc := -1 + if result.sdlr.Response.Response != nil { + sc = result.sdlr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "healthcareapis.ServicesClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.sdlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "healthcareapis.ServicesClient", "List", resp, "Failure sending request") + return + } + + result.sdlr, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "healthcareapis.ServicesClient", "List", resp, "Failure responding to request") + return + } + if result.sdlr.hasNextLink() && result.sdlr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListPreparer prepares the List request. +func (client ServicesClient) ListPreparer(ctx context.Context) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-11-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.HealthcareApis/services", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client ServicesClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client ServicesClient) ListResponder(resp *http.Response) (result ServicesDescriptionListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client ServicesClient) listNextResults(ctx context.Context, lastResults ServicesDescriptionListResult) (result ServicesDescriptionListResult, err error) { + req, err := lastResults.servicesDescriptionListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "healthcareapis.ServicesClient", "listNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "healthcareapis.ServicesClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "healthcareapis.ServicesClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client ServicesClient) ListComplete(ctx context.Context) (result ServicesDescriptionListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServicesClient.List") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.List(ctx) + return +} + +// ListByResourceGroup get all the service instances in a resource group. +// Parameters: +// resourceGroupName - the name of the resource group that contains the service instance. +func (client ServicesClient) ListByResourceGroup(ctx context.Context, resourceGroupName string) (result ServicesDescriptionListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServicesClient.ListByResourceGroup") + defer func() { + sc := -1 + if result.sdlr.Response.Response != nil { + sc = result.sdlr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("healthcareapis.ServicesClient", "ListByResourceGroup", err.Error()) + } + + result.fn = client.listByResourceGroupNextResults + req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "healthcareapis.ServicesClient", "ListByResourceGroup", nil, "Failure preparing request") + return + } + + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.sdlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "healthcareapis.ServicesClient", "ListByResourceGroup", resp, "Failure sending request") + return + } + + result.sdlr, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "healthcareapis.ServicesClient", "ListByResourceGroup", resp, "Failure responding to request") + return + } + if result.sdlr.hasNextLink() && result.sdlr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByResourceGroupPreparer prepares the ListByResourceGroup request. +func (client ServicesClient) ListByResourceGroupPreparer(ctx context.Context, resourceGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-11-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HealthcareApis/services", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByResourceGroupSender sends the ListByResourceGroup request. The method will close the +// http.Response Body if it receives an error. +func (client ServicesClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always +// closes the http.Response Body. +func (client ServicesClient) ListByResourceGroupResponder(resp *http.Response) (result ServicesDescriptionListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByResourceGroupNextResults retrieves the next set of results, if any. +func (client ServicesClient) listByResourceGroupNextResults(ctx context.Context, lastResults ServicesDescriptionListResult) (result ServicesDescriptionListResult, err error) { + req, err := lastResults.servicesDescriptionListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "healthcareapis.ServicesClient", "listByResourceGroupNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "healthcareapis.ServicesClient", "listByResourceGroupNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "healthcareapis.ServicesClient", "listByResourceGroupNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByResourceGroupComplete enumerates all values, automatically crossing page boundaries as required. +func (client ServicesClient) ListByResourceGroupComplete(ctx context.Context, resourceGroupName string) (result ServicesDescriptionListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServicesClient.ListByResourceGroup") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByResourceGroup(ctx, resourceGroupName) + return +} + +// Update update the metadata of a service instance. +// Parameters: +// resourceGroupName - the name of the resource group that contains the service instance. +// resourceName - the name of the service instance. +// servicePatchDescription - the service instance metadata and security metadata. +func (client ServicesClient) Update(ctx context.Context, resourceGroupName string, resourceName string, servicePatchDescription ServicesPatchDescription) (result ServicesUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ServicesClient.Update") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: resourceName, + Constraints: []validation.Constraint{{Target: "resourceName", Name: validation.MaxLength, Rule: 24, Chain: nil}, + {Target: "resourceName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil { + return result, validation.NewError("healthcareapis.ServicesClient", "Update", err.Error()) + } + + req, err := client.UpdatePreparer(ctx, resourceGroupName, resourceName, servicePatchDescription) + if err != nil { + err = autorest.NewErrorWithError(err, "healthcareapis.ServicesClient", "Update", nil, "Failure preparing request") + return + } + + result, err = client.UpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "healthcareapis.ServicesClient", "Update", result.Response(), "Failure sending request") + return + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client ServicesClient) UpdatePreparer(ctx context.Context, resourceGroupName string, resourceName string, servicePatchDescription ServicesPatchDescription) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-11-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HealthcareApis/services/{resourceName}", pathParameters), + autorest.WithJSON(servicePatchDescription), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client ServicesClient) UpdateSender(req *http.Request) (future ServicesUpdateFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client ServicesClient) UpdateResponder(resp *http.Response) (result ServicesDescription, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/healthcareapis/mgmt/2021-11-01/healthcareapis/version.go b/vendor/github.com/Azure/azure-sdk-for-go/services/healthcareapis/mgmt/2021-11-01/healthcareapis/version.go new file mode 100644 index 000000000000..c4404f7463db --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/healthcareapis/mgmt/2021-11-01/healthcareapis/version.go @@ -0,0 +1,19 @@ +package healthcareapis + +import "github.com/Azure/azure-sdk-for-go/version" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +// UserAgent returns the UserAgent string to use when sending http.Requests. +func UserAgent() string { + return "Azure-SDK-For-Go/" + Version() + " healthcareapis/2021-11-01" +} + +// Version returns the semantic version (see http://semver.org) of the client. +func Version() string { + return version.Number +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/healthcareapis/mgmt/2021-11-01/healthcareapis/workspaceprivateendpointconnections.go b/vendor/github.com/Azure/azure-sdk-for-go/services/healthcareapis/mgmt/2021-11-01/healthcareapis/workspaceprivateendpointconnections.go new file mode 100644 index 000000000000..a5b9c58b60bd --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/healthcareapis/mgmt/2021-11-01/healthcareapis/workspaceprivateendpointconnections.go @@ -0,0 +1,399 @@ +package healthcareapis + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// WorkspacePrivateEndpointConnectionsClient is the azure Healthcare APIs Client +type WorkspacePrivateEndpointConnectionsClient struct { + BaseClient +} + +// NewWorkspacePrivateEndpointConnectionsClient creates an instance of the WorkspacePrivateEndpointConnectionsClient +// client. +func NewWorkspacePrivateEndpointConnectionsClient(subscriptionID string) WorkspacePrivateEndpointConnectionsClient { + return NewWorkspacePrivateEndpointConnectionsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewWorkspacePrivateEndpointConnectionsClientWithBaseURI creates an instance of the +// WorkspacePrivateEndpointConnectionsClient client using a custom endpoint. Use this when interacting with an Azure +// cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewWorkspacePrivateEndpointConnectionsClientWithBaseURI(baseURI string, subscriptionID string) WorkspacePrivateEndpointConnectionsClient { + return WorkspacePrivateEndpointConnectionsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate update the state of the specified private endpoint connection associated with the workspace. +// Parameters: +// resourceGroupName - the name of the resource group that contains the service instance. +// workspaceName - the name of workspace resource. +// privateEndpointConnectionName - the name of the private endpoint connection associated with the Azure +// resource +// properties - the private endpoint connection properties. +func (client WorkspacePrivateEndpointConnectionsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, workspaceName string, privateEndpointConnectionName string, properties PrivateEndpointConnectionDescription) (result WorkspacePrivateEndpointConnectionsCreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/WorkspacePrivateEndpointConnectionsClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: workspaceName, + Constraints: []validation.Constraint{{Target: "workspaceName", Name: validation.MaxLength, Rule: 24, Chain: nil}, + {Target: "workspaceName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil { + return result, validation.NewError("healthcareapis.WorkspacePrivateEndpointConnectionsClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, workspaceName, privateEndpointConnectionName, properties) + if err != nil { + err = autorest.NewErrorWithError(err, "healthcareapis.WorkspacePrivateEndpointConnectionsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "healthcareapis.WorkspacePrivateEndpointConnectionsClient", "CreateOrUpdate", result.Response(), "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client WorkspacePrivateEndpointConnectionsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, workspaceName string, privateEndpointConnectionName string, properties PrivateEndpointConnectionDescription) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "privateEndpointConnectionName": autorest.Encode("path", privateEndpointConnectionName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "workspaceName": autorest.Encode("path", workspaceName), + } + + const APIVersion = "2021-11-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HealthcareApis/workspaces/{workspaceName}/privateEndpointConnections/{privateEndpointConnectionName}", pathParameters), + autorest.WithJSON(properties), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client WorkspacePrivateEndpointConnectionsClient) CreateOrUpdateSender(req *http.Request) (future WorkspacePrivateEndpointConnectionsCreateOrUpdateFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client WorkspacePrivateEndpointConnectionsClient) CreateOrUpdateResponder(resp *http.Response) (result PrivateEndpointConnectionDescription, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes a private endpoint connection. +// Parameters: +// resourceGroupName - the name of the resource group that contains the service instance. +// workspaceName - the name of workspace resource. +// privateEndpointConnectionName - the name of the private endpoint connection associated with the Azure +// resource +func (client WorkspacePrivateEndpointConnectionsClient) Delete(ctx context.Context, resourceGroupName string, workspaceName string, privateEndpointConnectionName string) (result WorkspacePrivateEndpointConnectionsDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/WorkspacePrivateEndpointConnectionsClient.Delete") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: workspaceName, + Constraints: []validation.Constraint{{Target: "workspaceName", Name: validation.MaxLength, Rule: 24, Chain: nil}, + {Target: "workspaceName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil { + return result, validation.NewError("healthcareapis.WorkspacePrivateEndpointConnectionsClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, workspaceName, privateEndpointConnectionName) + if err != nil { + err = autorest.NewErrorWithError(err, "healthcareapis.WorkspacePrivateEndpointConnectionsClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "healthcareapis.WorkspacePrivateEndpointConnectionsClient", "Delete", result.Response(), "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client WorkspacePrivateEndpointConnectionsClient) DeletePreparer(ctx context.Context, resourceGroupName string, workspaceName string, privateEndpointConnectionName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "privateEndpointConnectionName": autorest.Encode("path", privateEndpointConnectionName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "workspaceName": autorest.Encode("path", workspaceName), + } + + const APIVersion = "2021-11-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HealthcareApis/workspaces/{workspaceName}/privateEndpointConnections/{privateEndpointConnectionName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client WorkspacePrivateEndpointConnectionsClient) DeleteSender(req *http.Request) (future WorkspacePrivateEndpointConnectionsDeleteFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client WorkspacePrivateEndpointConnectionsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets the specified private endpoint connection associated with the workspace. +// Parameters: +// resourceGroupName - the name of the resource group that contains the service instance. +// workspaceName - the name of workspace resource. +// privateEndpointConnectionName - the name of the private endpoint connection associated with the Azure +// resource +func (client WorkspacePrivateEndpointConnectionsClient) Get(ctx context.Context, resourceGroupName string, workspaceName string, privateEndpointConnectionName string) (result PrivateEndpointConnectionDescription, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/WorkspacePrivateEndpointConnectionsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: workspaceName, + Constraints: []validation.Constraint{{Target: "workspaceName", Name: validation.MaxLength, Rule: 24, Chain: nil}, + {Target: "workspaceName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil { + return result, validation.NewError("healthcareapis.WorkspacePrivateEndpointConnectionsClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, workspaceName, privateEndpointConnectionName) + if err != nil { + err = autorest.NewErrorWithError(err, "healthcareapis.WorkspacePrivateEndpointConnectionsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "healthcareapis.WorkspacePrivateEndpointConnectionsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "healthcareapis.WorkspacePrivateEndpointConnectionsClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client WorkspacePrivateEndpointConnectionsClient) GetPreparer(ctx context.Context, resourceGroupName string, workspaceName string, privateEndpointConnectionName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "privateEndpointConnectionName": autorest.Encode("path", privateEndpointConnectionName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "workspaceName": autorest.Encode("path", workspaceName), + } + + const APIVersion = "2021-11-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HealthcareApis/workspaces/{workspaceName}/privateEndpointConnections/{privateEndpointConnectionName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client WorkspacePrivateEndpointConnectionsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client WorkspacePrivateEndpointConnectionsClient) GetResponder(resp *http.Response) (result PrivateEndpointConnectionDescription, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByWorkspace lists all private endpoint connections for a workspace. +// Parameters: +// resourceGroupName - the name of the resource group that contains the service instance. +// workspaceName - the name of workspace resource. +func (client WorkspacePrivateEndpointConnectionsClient) ListByWorkspace(ctx context.Context, resourceGroupName string, workspaceName string) (result PrivateEndpointConnectionListResultDescription, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/WorkspacePrivateEndpointConnectionsClient.ListByWorkspace") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: workspaceName, + Constraints: []validation.Constraint{{Target: "workspaceName", Name: validation.MaxLength, Rule: 24, Chain: nil}, + {Target: "workspaceName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil { + return result, validation.NewError("healthcareapis.WorkspacePrivateEndpointConnectionsClient", "ListByWorkspace", err.Error()) + } + + req, err := client.ListByWorkspacePreparer(ctx, resourceGroupName, workspaceName) + if err != nil { + err = autorest.NewErrorWithError(err, "healthcareapis.WorkspacePrivateEndpointConnectionsClient", "ListByWorkspace", nil, "Failure preparing request") + return + } + + resp, err := client.ListByWorkspaceSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "healthcareapis.WorkspacePrivateEndpointConnectionsClient", "ListByWorkspace", resp, "Failure sending request") + return + } + + result, err = client.ListByWorkspaceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "healthcareapis.WorkspacePrivateEndpointConnectionsClient", "ListByWorkspace", resp, "Failure responding to request") + return + } + + return +} + +// ListByWorkspacePreparer prepares the ListByWorkspace request. +func (client WorkspacePrivateEndpointConnectionsClient) ListByWorkspacePreparer(ctx context.Context, resourceGroupName string, workspaceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "workspaceName": autorest.Encode("path", workspaceName), + } + + const APIVersion = "2021-11-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HealthcareApis/workspaces/{workspaceName}/privateEndpointConnections", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByWorkspaceSender sends the ListByWorkspace request. The method will close the +// http.Response Body if it receives an error. +func (client WorkspacePrivateEndpointConnectionsClient) ListByWorkspaceSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByWorkspaceResponder handles the response to the ListByWorkspace request. The method always +// closes the http.Response Body. +func (client WorkspacePrivateEndpointConnectionsClient) ListByWorkspaceResponder(resp *http.Response) (result PrivateEndpointConnectionListResultDescription, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/healthcareapis/mgmt/2021-11-01/healthcareapis/workspaceprivatelinkresources.go b/vendor/github.com/Azure/azure-sdk-for-go/services/healthcareapis/mgmt/2021-11-01/healthcareapis/workspaceprivatelinkresources.go new file mode 100644 index 000000000000..56e9ae2eae9b --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/healthcareapis/mgmt/2021-11-01/healthcareapis/workspaceprivatelinkresources.go @@ -0,0 +1,209 @@ +package healthcareapis + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// WorkspacePrivateLinkResourcesClient is the azure Healthcare APIs Client +type WorkspacePrivateLinkResourcesClient struct { + BaseClient +} + +// NewWorkspacePrivateLinkResourcesClient creates an instance of the WorkspacePrivateLinkResourcesClient client. +func NewWorkspacePrivateLinkResourcesClient(subscriptionID string) WorkspacePrivateLinkResourcesClient { + return NewWorkspacePrivateLinkResourcesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewWorkspacePrivateLinkResourcesClientWithBaseURI creates an instance of the WorkspacePrivateLinkResourcesClient +// client using a custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI +// (sovereign clouds, Azure stack). +func NewWorkspacePrivateLinkResourcesClientWithBaseURI(baseURI string, subscriptionID string) WorkspacePrivateLinkResourcesClient { + return WorkspacePrivateLinkResourcesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Get gets a private link resource that need to be created for a workspace. +// Parameters: +// resourceGroupName - the name of the resource group that contains the service instance. +// workspaceName - the name of workspace resource. +// groupName - the name of the private link resource group. +func (client WorkspacePrivateLinkResourcesClient) Get(ctx context.Context, resourceGroupName string, workspaceName string, groupName string) (result PrivateLinkResourceDescription, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/WorkspacePrivateLinkResourcesClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: workspaceName, + Constraints: []validation.Constraint{{Target: "workspaceName", Name: validation.MaxLength, Rule: 24, Chain: nil}, + {Target: "workspaceName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil { + return result, validation.NewError("healthcareapis.WorkspacePrivateLinkResourcesClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, workspaceName, groupName) + if err != nil { + err = autorest.NewErrorWithError(err, "healthcareapis.WorkspacePrivateLinkResourcesClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "healthcareapis.WorkspacePrivateLinkResourcesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "healthcareapis.WorkspacePrivateLinkResourcesClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client WorkspacePrivateLinkResourcesClient) GetPreparer(ctx context.Context, resourceGroupName string, workspaceName string, groupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "groupName": autorest.Encode("path", groupName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "workspaceName": autorest.Encode("path", workspaceName), + } + + const APIVersion = "2021-11-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HealthcareApis/workspaces/{workspaceName}/privateLinkResources/{groupName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client WorkspacePrivateLinkResourcesClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client WorkspacePrivateLinkResourcesClient) GetResponder(resp *http.Response) (result PrivateLinkResourceDescription, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByWorkspace gets the private link resources that need to be created for a workspace. +// Parameters: +// resourceGroupName - the name of the resource group that contains the service instance. +// workspaceName - the name of workspace resource. +func (client WorkspacePrivateLinkResourcesClient) ListByWorkspace(ctx context.Context, resourceGroupName string, workspaceName string) (result PrivateLinkResourceListResultDescription, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/WorkspacePrivateLinkResourcesClient.ListByWorkspace") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: workspaceName, + Constraints: []validation.Constraint{{Target: "workspaceName", Name: validation.MaxLength, Rule: 24, Chain: nil}, + {Target: "workspaceName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil { + return result, validation.NewError("healthcareapis.WorkspacePrivateLinkResourcesClient", "ListByWorkspace", err.Error()) + } + + req, err := client.ListByWorkspacePreparer(ctx, resourceGroupName, workspaceName) + if err != nil { + err = autorest.NewErrorWithError(err, "healthcareapis.WorkspacePrivateLinkResourcesClient", "ListByWorkspace", nil, "Failure preparing request") + return + } + + resp, err := client.ListByWorkspaceSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "healthcareapis.WorkspacePrivateLinkResourcesClient", "ListByWorkspace", resp, "Failure sending request") + return + } + + result, err = client.ListByWorkspaceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "healthcareapis.WorkspacePrivateLinkResourcesClient", "ListByWorkspace", resp, "Failure responding to request") + return + } + + return +} + +// ListByWorkspacePreparer prepares the ListByWorkspace request. +func (client WorkspacePrivateLinkResourcesClient) ListByWorkspacePreparer(ctx context.Context, resourceGroupName string, workspaceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "workspaceName": autorest.Encode("path", workspaceName), + } + + const APIVersion = "2021-11-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HealthcareApis/workspaces/{workspaceName}/privateLinkResources", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByWorkspaceSender sends the ListByWorkspace request. The method will close the +// http.Response Body if it receives an error. +func (client WorkspacePrivateLinkResourcesClient) ListByWorkspaceSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByWorkspaceResponder handles the response to the ListByWorkspace request. The method always +// closes the http.Response Body. +func (client WorkspacePrivateLinkResourcesClient) ListByWorkspaceResponder(resp *http.Response) (result PrivateLinkResourceListResultDescription, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/healthcareapis/mgmt/2021-11-01/healthcareapis/workspaces.go b/vendor/github.com/Azure/azure-sdk-for-go/services/healthcareapis/mgmt/2021-11-01/healthcareapis/workspaces.go new file mode 100644 index 000000000000..3d48d1dcd5b3 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/healthcareapis/mgmt/2021-11-01/healthcareapis/workspaces.go @@ -0,0 +1,631 @@ +package healthcareapis + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// WorkspacesClient is the azure Healthcare APIs Client +type WorkspacesClient struct { + BaseClient +} + +// NewWorkspacesClient creates an instance of the WorkspacesClient client. +func NewWorkspacesClient(subscriptionID string) WorkspacesClient { + return NewWorkspacesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewWorkspacesClientWithBaseURI creates an instance of the WorkspacesClient client using a custom endpoint. Use this +// when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewWorkspacesClientWithBaseURI(baseURI string, subscriptionID string) WorkspacesClient { + return WorkspacesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates a workspace resource with the specified parameters. +// Parameters: +// resourceGroupName - the name of the resource group that contains the service instance. +// workspaceName - the name of workspace resource. +// workspace - the parameters for creating or updating a healthcare workspace. +func (client WorkspacesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, workspaceName string, workspace Workspace) (result WorkspacesCreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/WorkspacesClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: workspaceName, + Constraints: []validation.Constraint{{Target: "workspaceName", Name: validation.MaxLength, Rule: 24, Chain: nil}, + {Target: "workspaceName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil { + return result, validation.NewError("healthcareapis.WorkspacesClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, workspaceName, workspace) + if err != nil { + err = autorest.NewErrorWithError(err, "healthcareapis.WorkspacesClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "healthcareapis.WorkspacesClient", "CreateOrUpdate", result.Response(), "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client WorkspacesClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, workspaceName string, workspace Workspace) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "workspaceName": autorest.Encode("path", workspaceName), + } + + const APIVersion = "2021-11-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HealthcareApis/workspaces/{workspaceName}", pathParameters), + autorest.WithJSON(workspace), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client WorkspacesClient) CreateOrUpdateSender(req *http.Request) (future WorkspacesCreateOrUpdateFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client WorkspacesClient) CreateOrUpdateResponder(resp *http.Response) (result Workspace, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes a specified workspace. +// Parameters: +// resourceGroupName - the name of the resource group that contains the service instance. +// workspaceName - the name of workspace resource. +func (client WorkspacesClient) Delete(ctx context.Context, resourceGroupName string, workspaceName string) (result WorkspacesDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/WorkspacesClient.Delete") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: workspaceName, + Constraints: []validation.Constraint{{Target: "workspaceName", Name: validation.MaxLength, Rule: 24, Chain: nil}, + {Target: "workspaceName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil { + return result, validation.NewError("healthcareapis.WorkspacesClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, workspaceName) + if err != nil { + err = autorest.NewErrorWithError(err, "healthcareapis.WorkspacesClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "healthcareapis.WorkspacesClient", "Delete", result.Response(), "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client WorkspacesClient) DeletePreparer(ctx context.Context, resourceGroupName string, workspaceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "workspaceName": autorest.Encode("path", workspaceName), + } + + const APIVersion = "2021-11-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HealthcareApis/workspaces/{workspaceName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client WorkspacesClient) DeleteSender(req *http.Request) (future WorkspacesDeleteFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client WorkspacesClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets the properties of the specified workspace. +// Parameters: +// resourceGroupName - the name of the resource group that contains the service instance. +// workspaceName - the name of workspace resource. +func (client WorkspacesClient) Get(ctx context.Context, resourceGroupName string, workspaceName string) (result Workspace, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/WorkspacesClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: workspaceName, + Constraints: []validation.Constraint{{Target: "workspaceName", Name: validation.MaxLength, Rule: 24, Chain: nil}, + {Target: "workspaceName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil { + return result, validation.NewError("healthcareapis.WorkspacesClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, workspaceName) + if err != nil { + err = autorest.NewErrorWithError(err, "healthcareapis.WorkspacesClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "healthcareapis.WorkspacesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "healthcareapis.WorkspacesClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client WorkspacesClient) GetPreparer(ctx context.Context, resourceGroupName string, workspaceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "workspaceName": autorest.Encode("path", workspaceName), + } + + const APIVersion = "2021-11-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HealthcareApis/workspaces/{workspaceName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client WorkspacesClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client WorkspacesClient) GetResponder(resp *http.Response) (result Workspace, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByResourceGroup lists all the available workspaces under the specified resource group. +// Parameters: +// resourceGroupName - the name of the resource group that contains the service instance. +func (client WorkspacesClient) ListByResourceGroup(ctx context.Context, resourceGroupName string) (result WorkspaceListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/WorkspacesClient.ListByResourceGroup") + defer func() { + sc := -1 + if result.wl.Response.Response != nil { + sc = result.wl.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("healthcareapis.WorkspacesClient", "ListByResourceGroup", err.Error()) + } + + result.fn = client.listByResourceGroupNextResults + req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "healthcareapis.WorkspacesClient", "ListByResourceGroup", nil, "Failure preparing request") + return + } + + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.wl.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "healthcareapis.WorkspacesClient", "ListByResourceGroup", resp, "Failure sending request") + return + } + + result.wl, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "healthcareapis.WorkspacesClient", "ListByResourceGroup", resp, "Failure responding to request") + return + } + if result.wl.hasNextLink() && result.wl.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByResourceGroupPreparer prepares the ListByResourceGroup request. +func (client WorkspacesClient) ListByResourceGroupPreparer(ctx context.Context, resourceGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-11-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HealthcareApis/workspaces", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByResourceGroupSender sends the ListByResourceGroup request. The method will close the +// http.Response Body if it receives an error. +func (client WorkspacesClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always +// closes the http.Response Body. +func (client WorkspacesClient) ListByResourceGroupResponder(resp *http.Response) (result WorkspaceList, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByResourceGroupNextResults retrieves the next set of results, if any. +func (client WorkspacesClient) listByResourceGroupNextResults(ctx context.Context, lastResults WorkspaceList) (result WorkspaceList, err error) { + req, err := lastResults.workspaceListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "healthcareapis.WorkspacesClient", "listByResourceGroupNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "healthcareapis.WorkspacesClient", "listByResourceGroupNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "healthcareapis.WorkspacesClient", "listByResourceGroupNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByResourceGroupComplete enumerates all values, automatically crossing page boundaries as required. +func (client WorkspacesClient) ListByResourceGroupComplete(ctx context.Context, resourceGroupName string) (result WorkspaceListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/WorkspacesClient.ListByResourceGroup") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByResourceGroup(ctx, resourceGroupName) + return +} + +// ListBySubscription lists all the available workspaces under the specified subscription. +func (client WorkspacesClient) ListBySubscription(ctx context.Context) (result WorkspaceListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/WorkspacesClient.ListBySubscription") + defer func() { + sc := -1 + if result.wl.Response.Response != nil { + sc = result.wl.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listBySubscriptionNextResults + req, err := client.ListBySubscriptionPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "healthcareapis.WorkspacesClient", "ListBySubscription", nil, "Failure preparing request") + return + } + + resp, err := client.ListBySubscriptionSender(req) + if err != nil { + result.wl.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "healthcareapis.WorkspacesClient", "ListBySubscription", resp, "Failure sending request") + return + } + + result.wl, err = client.ListBySubscriptionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "healthcareapis.WorkspacesClient", "ListBySubscription", resp, "Failure responding to request") + return + } + if result.wl.hasNextLink() && result.wl.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListBySubscriptionPreparer prepares the ListBySubscription request. +func (client WorkspacesClient) ListBySubscriptionPreparer(ctx context.Context) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2021-11-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.HealthcareApis/workspaces", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListBySubscriptionSender sends the ListBySubscription request. The method will close the +// http.Response Body if it receives an error. +func (client WorkspacesClient) ListBySubscriptionSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListBySubscriptionResponder handles the response to the ListBySubscription request. The method always +// closes the http.Response Body. +func (client WorkspacesClient) ListBySubscriptionResponder(resp *http.Response) (result WorkspaceList, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listBySubscriptionNextResults retrieves the next set of results, if any. +func (client WorkspacesClient) listBySubscriptionNextResults(ctx context.Context, lastResults WorkspaceList) (result WorkspaceList, err error) { + req, err := lastResults.workspaceListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "healthcareapis.WorkspacesClient", "listBySubscriptionNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListBySubscriptionSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "healthcareapis.WorkspacesClient", "listBySubscriptionNextResults", resp, "Failure sending next results request") + } + result, err = client.ListBySubscriptionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "healthcareapis.WorkspacesClient", "listBySubscriptionNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListBySubscriptionComplete enumerates all values, automatically crossing page boundaries as required. +func (client WorkspacesClient) ListBySubscriptionComplete(ctx context.Context) (result WorkspaceListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/WorkspacesClient.ListBySubscription") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListBySubscription(ctx) + return +} + +// Update patch workspace details. +// Parameters: +// resourceGroupName - the name of the resource group that contains the service instance. +// workspaceName - the name of workspace resource. +// workspacePatchResource - the parameters for updating a specified workspace. +func (client WorkspacesClient) Update(ctx context.Context, resourceGroupName string, workspaceName string, workspacePatchResource WorkspacePatchResource) (result WorkspacesUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/WorkspacesClient.Update") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, + {TargetValue: workspaceName, + Constraints: []validation.Constraint{{Target: "workspaceName", Name: validation.MaxLength, Rule: 24, Chain: nil}, + {Target: "workspaceName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil { + return result, validation.NewError("healthcareapis.WorkspacesClient", "Update", err.Error()) + } + + req, err := client.UpdatePreparer(ctx, resourceGroupName, workspaceName, workspacePatchResource) + if err != nil { + err = autorest.NewErrorWithError(err, "healthcareapis.WorkspacesClient", "Update", nil, "Failure preparing request") + return + } + + result, err = client.UpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "healthcareapis.WorkspacesClient", "Update", result.Response(), "Failure sending request") + return + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client WorkspacesClient) UpdatePreparer(ctx context.Context, resourceGroupName string, workspaceName string, workspacePatchResource WorkspacePatchResource) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "workspaceName": autorest.Encode("path", workspaceName), + } + + const APIVersion = "2021-11-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HealthcareApis/workspaces/{workspaceName}", pathParameters), + autorest.WithJSON(workspacePatchResource), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client WorkspacesClient) UpdateSender(req *http.Request) (future WorkspacesUpdateFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client WorkspacesClient) UpdateResponder(resp *http.Response) (result Workspace, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/vendor/modules.txt b/vendor/modules.txt index e5c933ffacb9..c75cb3f58ec4 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -36,6 +36,7 @@ github.com/Azure/azure-sdk-for-go/services/guestconfiguration/mgmt/2020-06-25/gu github.com/Azure/azure-sdk-for-go/services/hdinsight/mgmt/2018-06-01/hdinsight github.com/Azure/azure-sdk-for-go/services/healthbot/mgmt/2020-12-08/healthbot github.com/Azure/azure-sdk-for-go/services/healthcareapis/mgmt/2020-03-30/healthcareapis +github.com/Azure/azure-sdk-for-go/services/healthcareapis/mgmt/2021-11-01/healthcareapis github.com/Azure/azure-sdk-for-go/services/iotcentral/mgmt/2018-09-01/iotcentral github.com/Azure/azure-sdk-for-go/services/iothub/mgmt/2021-07-02/devices github.com/Azure/azure-sdk-for-go/services/keyvault/v7.1/keyvault From f367927400368baab20ce6d0d336ba357a42e04d Mon Sep 17 00:00:00 2001 From: xiaxyi Date: Tue, 15 Mar 2022 22:02:15 +0800 Subject: [PATCH 04/22] add workspace --- internal/services/healthcare/client/client.go | 17 ++- .../healthcare_apis_dicom_resource.go | 8 +- .../healthcare_apis_workspace_data_source.go | 67 ++++++++ ...lthcare_apis_workspace_data_source_test.go | 48 ++++++ .../healthcare_apis_workspace_resource.go | 144 ++++++++++++++++++ ...healthcare_apis_workspace_resource_test.go | 89 +++++++++++ internal/services/healthcare/registration.go | 10 +- .../healthcare/validate/workspace_name.go | 24 +++ 8 files changed, 392 insertions(+), 15 deletions(-) create mode 100644 internal/services/healthcare/healthcare_apis_workspace_data_source.go create mode 100644 internal/services/healthcare/healthcare_apis_workspace_data_source_test.go create mode 100644 internal/services/healthcare/healthcare_apis_workspace_resource.go create mode 100644 internal/services/healthcare/healthcare_apis_workspace_resource_test.go create mode 100644 internal/services/healthcare/validate/workspace_name.go diff --git a/internal/services/healthcare/client/client.go b/internal/services/healthcare/client/client.go index 1a7591ef1c2d..dc6a8024c902 100644 --- a/internal/services/healthcare/client/client.go +++ b/internal/services/healthcare/client/client.go @@ -1,26 +1,29 @@ package client import ( - healthcare "github.com/Azure/azure-sdk-for-go/services/healthcareapis/mgmt/2020-03-30/healthcareapis" + "github.com/Azure/azure-sdk-for-go/services/healthcareapis/mgmt/2021-11-01/healthcareapis" "github.com/hashicorp/terraform-provider-azurerm/internal/common" - healthcareWorkspaceDicom "github.com/Azure/azure-sdk-for-go/services/healthcareapis/mgmt/2021-11-01/healthcareapis" - ) type Client struct { - HealthcareServiceClient *healthcare.ServicesClient - HealthcareWorkspaceDicomServiceClient *healthcareWorkspaceDicom.DicomServicesClient + HealthcareServiceClient *healthcareapis.ServicesClient + HealthcareWorkspaceClient *healthcareapis.WorkspacesClient + HealthcareWorkspaceDicomServiceClient *healthcareapis.DicomServicesClient } func NewClient(o *common.ClientOptions) *Client { - HealthcareServiceClient := healthcare.NewServicesClientWithBaseURI(o.ResourceManagerEndpoint, o.SubscriptionId) + HealthcareServiceClient := healthcareapis.NewServicesClientWithBaseURI(o.ResourceManagerEndpoint, o.SubscriptionId) + o.ConfigureClient(&HealthcareServiceClient.Client, o.ResourceManagerAuthorizer) + + HealthcareWorkspaceClient := healthcareapis.NewWorkspacesClientWithBaseURI(o.ResourceManagerEndpoint, o.SubscriptionId) o.ConfigureClient(&HealthcareServiceClient.Client, o.ResourceManagerAuthorizer) - HealthcareWorkspaceDicomServiceClient := healthcareWorkspaceDicom.NewDicomServicesClientWithBaseURI(o.ResourceManagerEndpoint, o.SubscriptionId) + HealthcareWorkspaceDicomServiceClient := healthcareapis.NewDicomServicesClientWithBaseURI(o.ResourceManagerEndpoint, o.SubscriptionId) o.ConfigureClient(&HealthcareWorkspaceDicomServiceClient.Client, o.ResourceManagerAuthorizer) return &Client{ HealthcareServiceClient: &HealthcareServiceClient, + HealthcareWorkspaceClient: &HealthcareWorkspaceClient, HealthcareWorkspaceDicomServiceClient: &HealthcareWorkspaceDicomServiceClient, } } diff --git a/internal/services/healthcare/healthcare_apis_dicom_resource.go b/internal/services/healthcare/healthcare_apis_dicom_resource.go index 4780728cc1c4..96db7fd3865c 100644 --- a/internal/services/healthcare/healthcare_apis_dicom_resource.go +++ b/internal/services/healthcare/healthcare_apis_dicom_resource.go @@ -2,12 +2,12 @@ package healthcare import ( "fmt" + "github.com/hashicorp/go-azure-helpers/resourcemanager/location" "log" "time" "github.com/Azure/azure-sdk-for-go/services/healthcareapis/mgmt/2021-11-01/healthcareapis" "github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema" - "github.com/hashicorp/terraform-provider-azurerm/helpers/azure" "github.com/hashicorp/terraform-provider-azurerm/helpers/tf" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" "github.com/hashicorp/terraform-provider-azurerm/internal/services/healthcare/parse" @@ -52,7 +52,7 @@ func resourceHealthcareApisDicomService() *pluginsdk.Resource { ValidateFunc: validate.WorkspaceID, }, - "location": azure.SchemaLocation(), + "location": commonschema.Location(), "public_network_access_enabled": { Type: pluginsdk.TypeBool, @@ -140,7 +140,7 @@ func resourceHealthcareApisDicomServiceCreateUpdate(d *pluginsdk.ResourceData, m } parameters := healthcareapis.DicomService{ - Location: utils.String(azure.NormalizeLocation(d.Get("location").(string))), + Location: utils.String(location.Normalize(d.Get("location").(string))), Tags: tags.Expand(t), DicomServiceProperties: &healthcareapis.DicomServiceProperties{ PublicNetworkAccess: publicNetworkAccess, @@ -184,7 +184,7 @@ func resourceHealthcareApisDicomServiceRead(d *pluginsdk.ResourceData, meta inte d.Set("workspace_id", workspaceId.ID()) if resp.Location != nil { - d.Set("location", azure.NormalizeLocation(*resp.Location)) + d.Set("location", location.Normalize(*resp.Location)) } if props := resp.DicomServiceProperties; props != nil { diff --git a/internal/services/healthcare/healthcare_apis_workspace_data_source.go b/internal/services/healthcare/healthcare_apis_workspace_data_source.go new file mode 100644 index 000000000000..ba06a400514e --- /dev/null +++ b/internal/services/healthcare/healthcare_apis_workspace_data_source.go @@ -0,0 +1,67 @@ +package healthcare + +import ( + "fmt" + "time" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema" + "github.com/hashicorp/go-azure-helpers/resourcemanager/location" + "github.com/hashicorp/terraform-provider-azurerm/internal/clients" + "github.com/hashicorp/terraform-provider-azurerm/internal/services/healthcare/parse" + "github.com/hashicorp/terraform-provider-azurerm/internal/services/healthcare/validate" + "github.com/hashicorp/terraform-provider-azurerm/internal/tags" + "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" + "github.com/hashicorp/terraform-provider-azurerm/internal/timeouts" + "github.com/hashicorp/terraform-provider-azurerm/utils" +) + +func dataSourceHealthcareWorkspace() *pluginsdk.Resource { + return &pluginsdk.Resource{ + Read: dataSourceHealthcareWorkspaceRead, + + Timeouts: &pluginsdk.ResourceTimeout{ + Read: pluginsdk.DefaultTimeout(5 * time.Minute), + }, + + Schema: map[string]*pluginsdk.Schema{ + "name": { + Type: pluginsdk.TypeString, + Required: true, + ValidateFunc: validate.WorkspaceName, + }, + + "location": commonschema.Location(), + + "resource_group_name": commonschema.ResourceGroupName(), + + "tags": tags.Schema(), + }, + } +} + +func dataSourceHealthcareWorkspaceRead(d *pluginsdk.ResourceData, meta interface{}) error { + client := meta.(*clients.Client).HealthCare.HealthcareWorkspaceClient + subscriptionId := meta.(*clients.Client).Account.SubscriptionId + ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d) + defer cancel() + + id := parse.NewWorkspaceID(subscriptionId, d.Get("resource_group_name").(string), d.Get("name").(string)) + resp, err := client.Get(ctx, id.ResourceGroup, id.Name) + if err != nil { + if utils.ResponseWasNotFound(resp.Response) { + return fmt.Errorf("%s was not found", id) + } + return fmt.Errorf("retrieving %s: %+v", id, err) + } + + d.SetId(id.ID()) + + d.Set("name", id.Name) + d.Set("resource_group_name", id.ResourceGroup) + + if locations := resp.Location; locations != nil { + d.Set("location", location.Normalize(*locations)) + } + + return tags.FlattenAndSet(d, resp.Tags) +} diff --git a/internal/services/healthcare/healthcare_apis_workspace_data_source_test.go b/internal/services/healthcare/healthcare_apis_workspace_data_source_test.go new file mode 100644 index 000000000000..08eb4d265351 --- /dev/null +++ b/internal/services/healthcare/healthcare_apis_workspace_data_source_test.go @@ -0,0 +1,48 @@ +package healthcare_test + +import ( + "fmt" + "testing" + + "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance" + "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance/check" +) + +type HealthCareWorkspaceDataSource struct{} + +func TestAccHealthCareWorkspaceDataSource_basic(t *testing.T) { + data := acceptance.BuildTestData(t, "data.azurerm_healthcareapis_workspace", "test") + r := HealthCareWorkspaceDataSource{} + + data.DataSourceTest(t, []acceptance.TestStep{ + { + Config: r.basic(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).Key("name").Exists()), + }, + }) +} + +func (HealthCareWorkspaceDataSource) basic(data acceptance.TestData) string { + return fmt.Sprintf(` +provider "azurerm" { + features {} +} + +resource "azurerm_resource_group" "test" { + name = "acctestRG-health-%d" + location = "%s" +} + +resource "azurerm_healthcareapis_workspace" "test" { + name = "acctestwk%d" + resource_group_name = azurerm_resource_group.test.name + location = azurerm_resource_group.test.location +} + +data "azurerm_healthcareapis_workspace" "test" { + name = azurerm_healthcareapis_workspace.test.name + resource_group_name = azurerm_healthcareapis_workspace.test.resource_group_name + location = azurerm_healthcareapis_workspace.test.location +}`, data.RandomInteger, data.Locations.Primary, data.RandomIntOfLength(8)) +} diff --git a/internal/services/healthcare/healthcare_apis_workspace_resource.go b/internal/services/healthcare/healthcare_apis_workspace_resource.go new file mode 100644 index 000000000000..ef6d93587514 --- /dev/null +++ b/internal/services/healthcare/healthcare_apis_workspace_resource.go @@ -0,0 +1,144 @@ +package healthcare + +import ( + "fmt" + "log" + "time" + + "github.com/Azure/azure-sdk-for-go/services/healthcareapis/mgmt/2021-11-01/healthcareapis" + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema" + "github.com/hashicorp/go-azure-helpers/resourcemanager/location" + "github.com/hashicorp/terraform-provider-azurerm/helpers/tf" + "github.com/hashicorp/terraform-provider-azurerm/internal/clients" + "github.com/hashicorp/terraform-provider-azurerm/internal/services/healthcare/parse" + "github.com/hashicorp/terraform-provider-azurerm/internal/services/healthcare/validate" + "github.com/hashicorp/terraform-provider-azurerm/internal/tags" + "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" + "github.com/hashicorp/terraform-provider-azurerm/internal/timeouts" + "github.com/hashicorp/terraform-provider-azurerm/utils" +) + +func resourceHealthcareApisWorkspace() *pluginsdk.Resource { + return &pluginsdk.Resource{ + Create: resourceHealthcareApisWorkspaceCreateUpdate, + Read: resourceHealthcareApisWorkspaceRead, + Update: resourceHealthcareApisWorkspaceCreateUpdate, + Delete: resourceHealthcareApisWorkspaceDelete, + + Timeouts: &pluginsdk.ResourceTimeout{ + Create: pluginsdk.DefaultTimeout(30 * time.Minute), + Read: pluginsdk.DefaultTimeout(5 * time.Minute), + Update: pluginsdk.DefaultTimeout(30 * time.Minute), + Delete: pluginsdk.DefaultTimeout(30 * time.Minute), + }, + + Importer: pluginsdk.ImporterValidatingResourceId(func(id string) error { + _, err := parse.WorkspaceID(id) + return err + }), + + Schema: map[string]*pluginsdk.Schema{ + "name": { + Type: pluginsdk.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: validate.WorkspaceName, + }, + + "resource_group_name": commonschema.ResourceGroupName(), + + "location": commonschema.Location(), + + "tags": tags.Schema(), + }, + } +} + +func resourceHealthcareApisWorkspaceCreateUpdate(d *pluginsdk.ResourceData, meta interface{}) error { + client := meta.(*clients.Client).HealthCare.HealthcareWorkspaceClient + subscriptionId := meta.(*clients.Client).Account.SubscriptionId + ctx, cancel := timeouts.ForCreateUpdate(meta.(*clients.Client).StopContext, d) + defer cancel() + log.Printf("[INFO] preparing arguments for AzureRM Healthcare Workspace creation.") + + id := parse.NewWorkspaceID(subscriptionId, d.Get("resource_group_name").(string), d.Get("name").(string)) + if d.IsNewResource() { + existing, err := client.Get(ctx, id.ResourceGroup, id.Name) + if err != nil { + if !utils.ResponseWasNotFound(existing.Response) { + return fmt.Errorf("checking for presence of existing %s: %+v", id, err) + } + } + if !utils.ResponseWasNotFound(existing.Response) { + return tf.ImportAsExistsError("azurerm_healthcare_workspace", id.ID()) + } + } + + location := location.Normalize(d.Get("location").(string)) + t := d.Get("tags").(map[string]interface{}) + + parameters := healthcareapis.Workspace{ + Location: &location, + Tags: tags.Expand(t), + } + + future, err := client.CreateOrUpdate(ctx, id.ResourceGroup, id.Name, parameters) + if err != nil { + return fmt.Errorf("creating/ updating %s: %+v", id, err) + } + + if err = future.WaitForCompletionRef(ctx, client.Client); err != nil { + return fmt.Errorf("waiting for creation/update of %s: %+v", id, err) + } + + d.SetId(id.ID()) + + return resourceHealthcareApisWorkspaceRead(d, meta) +} +func resourceHealthcareApisWorkspaceRead(d *pluginsdk.ResourceData, meta interface{}) error { + client := meta.(*clients.Client).HealthCare.HealthcareWorkspaceClient + ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d) + defer cancel() + + id, err := parse.WorkspaceID(d.Id()) + if err != nil { + return err + } + + resp, err := client.Get(ctx, id.ResourceGroup, id.Name) + if err != nil { + if utils.ResponseWasNotFound(resp.Response) { + d.SetId("") + return nil + } + return fmt.Errorf("retrieving %s: %+v", *id, err) + } + + d.Set("name", id.Name) + d.Set("resource_group_name", id.ResourceGroup) + if locations := resp.Location; locations != nil { + d.Set("location", location.Normalize(*locations)) + } + + return tags.FlattenAndSet(d, resp.Tags) +} +func resourceHealthcareApisWorkspaceDelete(d *pluginsdk.ResourceData, meta interface{}) error { + client := meta.(*clients.Client).HealthCare.HealthcareWorkspaceClient + ctx, cancel := timeouts.ForDelete(meta.(*clients.Client).StopContext, d) + defer cancel() + + id, err := parse.WorkspaceID(d.Id()) + if err != nil { + return err + } + + future, err := client.Delete(ctx, id.ResourceGroup, id.Name) + if err != nil { + return fmt.Errorf("deleting %s: %+v", id, err) + } + + if err = future.WaitForCompletionRef(ctx, client.Client); err != nil { + return fmt.Errorf("waiting for the deletion of %s: %+v", *id, err) + } + return nil +} diff --git a/internal/services/healthcare/healthcare_apis_workspace_resource_test.go b/internal/services/healthcare/healthcare_apis_workspace_resource_test.go new file mode 100644 index 000000000000..4f56bf76ff56 --- /dev/null +++ b/internal/services/healthcare/healthcare_apis_workspace_resource_test.go @@ -0,0 +1,89 @@ +package healthcare_test + +import ( + "context" + "fmt" + "testing" + + "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance" + "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance/check" + "github.com/hashicorp/terraform-provider-azurerm/internal/clients" + "github.com/hashicorp/terraform-provider-azurerm/internal/services/healthcare/parse" + "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" + "github.com/hashicorp/terraform-provider-azurerm/utils" +) + +type HealthCareWorkspaceResouce struct{} + +func TestAccHealthCareWorkspace_basic(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_healthcare_workspace", "test") + r := HealthCareWorkspaceResouce{} + + data.ResourceTest(t, r, []acceptance.TestStep{ + { + Config: r.basic(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r)), + }, + data.ImportStep(), + }) +} + +func TestAccHealthCareWorkspace_requiresImport(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_healthcare_workspace", "test") + r := HealthCareWorkspaceResouce{} + + data.ResourceTest(t, r, []acceptance.TestStep{ + { + Config: r.basic(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r)), + }, + data.RequiresImportErrorStep(r.requiresImport), + }) +} + +func (HealthCareWorkspaceResouce) Exists(ctx context.Context, clients *clients.Client, state *pluginsdk.InstanceState) (*bool, error) { + id, err := parse.WorkspaceID(state.ID) + if err != nil { + return nil, err + } + + resp, err := clients.HealthCare.HealthcareWorkspaceClient.Get(ctx, id.ResourceGroup, id.Name) + if err != nil { + return nil, fmt.Errorf("retrieving %s, %+v", *id, err) + } + + return utils.Bool(resp.Properties != nil), nil +} +func (HealthCareWorkspaceResouce) basic(data acceptance.TestData) string { + return fmt.Sprintf(` +provider "azurerm" { + features {} +} + +resource "azurerm_resource_group" "test" { + name = "acctestRG-health-%d" + location = "%s" +} + +resource "azurerm_healthcare_workspace" "test" { + name = "acctestwk%d" + resource_group_name = azurerm_resource_group.test.name + location = azurerm_resource_group.test.location +} +`, data.RandomInteger, data.Locations.Primary, data.RandomIntOfLength(8)) +} + +func (r HealthCareWorkspaceResouce) requiresImport(data acceptance.TestData) string { + return fmt.Sprintf(` +%s +resource "azurerm_healthcare_workspace" "import" { + name = azurerm_healthcare_workspace.test.name + resource_group_name = azurerm_healthcare_workspace.test.resource_group_name + location = azurerm_healthcare_workspace.test.location +} + + +`, r.basic(data)) +} diff --git a/internal/services/healthcare/registration.go b/internal/services/healthcare/registration.go index 2ec8aa2e1ad7..2ae287d99a99 100644 --- a/internal/services/healthcare/registration.go +++ b/internal/services/healthcare/registration.go @@ -28,15 +28,17 @@ func (r Registration) WebsiteCategories() []string { // SupportedDataSources returns the supported Data Sources supported by this Service func (r Registration) SupportedDataSources() map[string]*pluginsdk.Resource { return map[string]*pluginsdk.Resource{ - "azurerm_healthcare_service": dataSourceHealthcareService(), - "azurerm_healthcare_apis_dicom_service": dataSourceHealthcareApisDicomService(), + "azurerm_healthcare_service": dataSourceHealthcareService(), + "azurerm_healthcare_workspace": dataSourceHealthcareWorkspace(), + "azurerm_healthcare_dicom_service": dataSourceHealthcareApisDicomService(), } } // SupportedResources returns the supported Resources supported by this Service func (r Registration) SupportedResources() map[string]*pluginsdk.Resource { return map[string]*pluginsdk.Resource{ - "azurerm_healthcare_service": resourceHealthcareService(), - "azurerm_healthcare_apis_dicom_service": resourceHealthcareApisDicomService(), + "azurerm_healthcare_service": resourceHealthcareService(), + "azurerm_healthcare_workspace": resourceHealthcareApisWorkspace(), + "azurerm_healthcare_dicom_service": resourceHealthcareApisDicomService(), } } diff --git a/internal/services/healthcare/validate/workspace_name.go b/internal/services/healthcare/validate/workspace_name.go new file mode 100644 index 000000000000..ac7ec1d45649 --- /dev/null +++ b/internal/services/healthcare/validate/workspace_name.go @@ -0,0 +1,24 @@ +package validate + +import ( + "fmt" + "regexp" +) + +func WorkspaceName(i interface{}, k string) (warnings []string, errors []error) { + v, ok := i.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected type of %s to be string", k)) + return + } + + // The name attribute rules are : + // 1. The value must be between 1 and 24 characters long + // 2. must contain only lowercase letters or numbers. + + if !regexp.MustCompile(`^[a-z0-9]{1,24}$`).MatchString(v) { + errors = append(errors, fmt.Errorf("%s must be between 1 and 24 characters long and can contain only lowercase letters or numbers", k)) + return + } + return warnings, errors +} \ No newline at end of file From b3eb32537db264f70e098ef94d153d618ce41c1d Mon Sep 17 00:00:00 2001 From: xiaxyi Date: Wed, 16 Mar 2022 17:47:10 +0800 Subject: [PATCH 05/22] dicom --- .../healthcare_apis_dicom_resource_test.go | 30 ------ ...rce.go => healthcare_dicom_data_source.go} | 0 ...source.go => healthcare_dicom_resource.go} | 14 --- .../healthcare_dicom_resource_test.go | 94 +++++++++++++++++++ ...go => healthcare_workspace_data_source.go} | 0 ... healthcare_workspace_data_source_test.go} | 15 +-- ...ce.go => healthcare_workspace_resource.go} | 81 +++++++++++++++- ... => healthcare_workspace_resource_test.go} | 0 8 files changed, 179 insertions(+), 55 deletions(-) delete mode 100644 internal/services/healthcare/healthcare_apis_dicom_resource_test.go rename internal/services/healthcare/{healthcare_apis_dicom_data_source.go => healthcare_dicom_data_source.go} (100%) rename internal/services/healthcare/{healthcare_apis_dicom_resource.go => healthcare_dicom_resource.go} (94%) create mode 100644 internal/services/healthcare/healthcare_dicom_resource_test.go rename internal/services/healthcare/{healthcare_apis_workspace_data_source.go => healthcare_workspace_data_source.go} (100%) rename internal/services/healthcare/{healthcare_apis_workspace_data_source_test.go => healthcare_workspace_data_source_test.go} (66%) rename internal/services/healthcare/{healthcare_apis_workspace_resource.go => healthcare_workspace_resource.go} (69%) rename internal/services/healthcare/{healthcare_apis_workspace_resource_test.go => healthcare_workspace_resource_test.go} (100%) diff --git a/internal/services/healthcare/healthcare_apis_dicom_resource_test.go b/internal/services/healthcare/healthcare_apis_dicom_resource_test.go deleted file mode 100644 index 4c7609031c7c..000000000000 --- a/internal/services/healthcare/healthcare_apis_dicom_resource_test.go +++ /dev/null @@ -1,30 +0,0 @@ -package healthcare_test - -import ( - "fmt" - "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance" -) - -type HealthCareApisDicomResource struct{} - -func (HealthCareApisDicomResource) basic (data acceptance.TestData) string { - return fmt.Sprintf(` -provider "azurerm" { - features {} -} - -resource "azurerm_resource_group" "test" { - name = "acctestRG-hcwk-%d" - location = "%s" -} - -resource "azurerm_healthcare_apis_dicom_service" "test"{ - name = "acctest-dicom%d" - workspace_id = "/subscriptions/85b3dbca-5974-4067-9669-67a141095a76/resourceGroups/xiaxintestrg-healthcare/providers/Microsoft.HealthcareApis/workspaces/xiaxintestworkspace" - location = "east us" - public_network_access_enabled = false -} -`, data.RandomInteger, data.Locations.Primary, data.RandomIntOfLength(8)) -} - - diff --git a/internal/services/healthcare/healthcare_apis_dicom_data_source.go b/internal/services/healthcare/healthcare_dicom_data_source.go similarity index 100% rename from internal/services/healthcare/healthcare_apis_dicom_data_source.go rename to internal/services/healthcare/healthcare_dicom_data_source.go diff --git a/internal/services/healthcare/healthcare_apis_dicom_resource.go b/internal/services/healthcare/healthcare_dicom_resource.go similarity index 94% rename from internal/services/healthcare/healthcare_apis_dicom_resource.go rename to internal/services/healthcare/healthcare_dicom_resource.go index 96db7fd3865c..51f22bee57a5 100644 --- a/internal/services/healthcare/healthcare_apis_dicom_resource.go +++ b/internal/services/healthcare/healthcare_dicom_resource.go @@ -54,12 +54,6 @@ func resourceHealthcareApisDicomService() *pluginsdk.Resource { "location": commonschema.Location(), - "public_network_access_enabled": { - Type: pluginsdk.TypeBool, - Optional: true, - Default: true, - }, - "authentication_configuration": { Type: pluginsdk.TypeList, Optional: true, @@ -134,17 +128,9 @@ func resourceHealthcareApisDicomServiceCreateUpdate(d *pluginsdk.ResourceData, m t := d.Get("tags").(map[string]interface{}) - publicNetworkAccess := healthcareapis.PublicNetworkAccessEnabled - if !d.Get("public_network_access_enabled").(bool) { - publicNetworkAccess = healthcareapis.PublicNetworkAccessDisabled - } - parameters := healthcareapis.DicomService{ Location: utils.String(location.Normalize(d.Get("location").(string))), Tags: tags.Expand(t), - DicomServiceProperties: &healthcareapis.DicomServiceProperties{ - PublicNetworkAccess: publicNetworkAccess, - }, } future, err := client.CreateOrUpdate(ctx, dicomServiceId.ResourceGroup, dicomServiceId.WorkspaceName, dicomServiceId.Name, parameters) diff --git a/internal/services/healthcare/healthcare_dicom_resource_test.go b/internal/services/healthcare/healthcare_dicom_resource_test.go new file mode 100644 index 000000000000..4bf980573c2c --- /dev/null +++ b/internal/services/healthcare/healthcare_dicom_resource_test.go @@ -0,0 +1,94 @@ +package healthcare_test + +import ( + "context" + "fmt" + "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance/check" + "testing" + + "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance" + "github.com/hashicorp/terraform-provider-azurerm/internal/clients" + "github.com/hashicorp/terraform-provider-azurerm/internal/services/healthcare/parse" + "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" + "github.com/hashicorp/terraform-provider-azurerm/utils" +) + +type HealthCareDicomResource struct{} + +func TestAccHealthCareDicom_basic(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_healthcare_dicom_service", "test") + r := HealthCareDicomResource{} + + data.ResourceTest(t, r, []acceptance.TestStep{ + { + Config: r.basic(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r)), + }, + data.ImportStep(), + }) +} + +func TestAccHealthCareDicom_requiresImport(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_healthcare_dicom_service", "test") + r := HealthCareWorkspaceResouce{} + + data.ResourceTest(t, r, []acceptance.TestStep{ + { + Config: r.basic(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r)), + }, + data.RequiresImportErrorStep(r.requiresImport), + }) +} + +func (HealthCareDicomResource) Exists(ctx context.Context, clients *clients.Client, state *pluginsdk.InstanceState) (*bool, error) { + id, err := parse.DicomServiceID(state.ID) + if err != nil { + return nil, err + } + + resp, err := clients.HealthCare.HealthcareWorkspaceDicomServiceClient.Get(ctx, id.ResourceGroup, id.WorkspaceName, id.Name) + if err != nil { + return nil, fmt.Errorf("retrieving %s, %+v", *id, err) + } + + return utils.Bool(resp.DicomServiceProperties != nil), nil +} + +func (HealthCareDicomResource) basic(data acceptance.TestData) string { + return fmt.Sprintf(` +provider "azurerm" { + features {} +} + +resource "azurerm_resource_group" "test" { + name = "acctestRG-hcwk-%d" + location = "%s" +} + +resource "azurerm_healthcare_workspace" "test" { + name = "acctestwk%d" + resource_group_name = azurerm_resource_group.test.name + location = azurerm_resource_group.test.location +} + +resource "azurerm_healthcare_dicom_service" "test" { + name = "acctest-dicom%d" + workspace_id = azurerm_healthcare_workspace.test.id + location = "east us" +} +`, data.RandomInteger, data.Locations.Primary, data.RandomIntOfLength(8), data.RandomIntOfLength(8)) +} + +func (r HealthCareDicomResource) requiresImport(data acceptance.TestData) string { + return fmt.Sprintf(` +%s +resource "azurerm_healthcare_dicom_service" "import" { + name = azurerm_healthcare_dicom_service.test.name + workspace_id = azurerm_healthcare_dicom_service.test.workspace_id + location = azurerm_healthcare_dicom_service.test.location +} +`, r.basic(data)) +} diff --git a/internal/services/healthcare/healthcare_apis_workspace_data_source.go b/internal/services/healthcare/healthcare_workspace_data_source.go similarity index 100% rename from internal/services/healthcare/healthcare_apis_workspace_data_source.go rename to internal/services/healthcare/healthcare_workspace_data_source.go diff --git a/internal/services/healthcare/healthcare_apis_workspace_data_source_test.go b/internal/services/healthcare/healthcare_workspace_data_source_test.go similarity index 66% rename from internal/services/healthcare/healthcare_apis_workspace_data_source_test.go rename to internal/services/healthcare/healthcare_workspace_data_source_test.go index 08eb4d265351..7a9db80cb253 100644 --- a/internal/services/healthcare/healthcare_apis_workspace_data_source_test.go +++ b/internal/services/healthcare/healthcare_workspace_data_source_test.go @@ -11,7 +11,7 @@ import ( type HealthCareWorkspaceDataSource struct{} func TestAccHealthCareWorkspaceDataSource_basic(t *testing.T) { - data := acceptance.BuildTestData(t, "data.azurerm_healthcareapis_workspace", "test") + data := acceptance.BuildTestData(t, "data.azurerm_healthcare_workspace", "test") r := HealthCareWorkspaceDataSource{} data.DataSourceTest(t, []acceptance.TestStep{ @@ -34,15 +34,16 @@ resource "azurerm_resource_group" "test" { location = "%s" } -resource "azurerm_healthcareapis_workspace" "test" { +resource "azurerm_healthcare_workspace" "test" { name = "acctestwk%d" resource_group_name = azurerm_resource_group.test.name location = azurerm_resource_group.test.location } -data "azurerm_healthcareapis_workspace" "test" { - name = azurerm_healthcareapis_workspace.test.name - resource_group_name = azurerm_healthcareapis_workspace.test.resource_group_name - location = azurerm_healthcareapis_workspace.test.location -}`, data.RandomInteger, data.Locations.Primary, data.RandomIntOfLength(8)) +data "azurerm_healthcare_workspace" "test" { + name = azurerm_healthcare_workspace.test.name + resource_group_name = azurerm_healthcare_workspace.test.resource_group_name + location = azurerm_healthcare_workspace.test.location +} +`, data.RandomInteger, data.Locations.Primary, data.RandomIntOfLength(8)) } diff --git a/internal/services/healthcare/healthcare_apis_workspace_resource.go b/internal/services/healthcare/healthcare_workspace_resource.go similarity index 69% rename from internal/services/healthcare/healthcare_apis_workspace_resource.go rename to internal/services/healthcare/healthcare_workspace_resource.go index ef6d93587514..462bf317f1a6 100644 --- a/internal/services/healthcare/healthcare_apis_workspace_resource.go +++ b/internal/services/healthcare/healthcare_workspace_resource.go @@ -20,9 +20,9 @@ import ( func resourceHealthcareApisWorkspace() *pluginsdk.Resource { return &pluginsdk.Resource{ - Create: resourceHealthcareApisWorkspaceCreateUpdate, + Create: resourceHealthcareApisWorkspaceCreate, Read: resourceHealthcareApisWorkspaceRead, - Update: resourceHealthcareApisWorkspaceCreateUpdate, + Update: resourceHealthcareApisWorkspaceUpdate, Delete: resourceHealthcareApisWorkspaceDelete, Timeouts: &pluginsdk.ResourceTimeout{ @@ -49,12 +49,30 @@ func resourceHealthcareApisWorkspace() *pluginsdk.Resource { "location": commonschema.Location(), - "tags": tags.Schema(), + "private_endpoint_connection": { + Type: pluginsdk.TypeSet, + Computed: true, + Elem: &pluginsdk.Resource{ + Schema: map[string]*pluginsdk.Schema{ + "name": { + Type: pluginsdk.TypeString, + Computed: true, + }, + + "id": { + Type: pluginsdk.TypeString, + Computed: true, + }, + }, + }, + }, + + "tags": commonschema.Tags(), }, } } -func resourceHealthcareApisWorkspaceCreateUpdate(d *pluginsdk.ResourceData, meta interface{}) error { +func resourceHealthcareApisWorkspaceCreate(d *pluginsdk.ResourceData, meta interface{}) error { client := meta.(*clients.Client).HealthCare.HealthcareWorkspaceClient subscriptionId := meta.(*clients.Client).Account.SubscriptionId ctx, cancel := timeouts.ForCreateUpdate(meta.(*clients.Client).StopContext, d) @@ -95,6 +113,7 @@ func resourceHealthcareApisWorkspaceCreateUpdate(d *pluginsdk.ResourceData, meta return resourceHealthcareApisWorkspaceRead(d, meta) } + func resourceHealthcareApisWorkspaceRead(d *pluginsdk.ResourceData, meta interface{}) error { client := meta.(*clients.Client).HealthCare.HealthcareWorkspaceClient ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d) @@ -120,8 +139,43 @@ func resourceHealthcareApisWorkspaceRead(d *pluginsdk.ResourceData, meta interfa d.Set("location", location.Normalize(*locations)) } + if props := resp.Properties; props != nil { + d.Set("private_endpoint_connection", flattenWorkspacePrivateEndpoint(props.PrivateEndpointConnections)) + } + return tags.FlattenAndSet(d, resp.Tags) } + +func resourceHealthcareApisWorkspaceUpdate(d *pluginsdk.ResourceData, meta interface{}) error { + client := meta.(*clients.Client).HealthCare.HealthcareWorkspaceClient + ctx, cancel := timeouts.ForUpdate(meta.(*clients.Client).StopContext, d) + defer cancel() + + id, err := parse.WorkspaceID(d.Id()) + if err != nil { + return err + } + + t := d.Get("tags").(map[string]interface{}) + + parameters := healthcareapis.WorkspacePatchResource{ + Tags: tags.Expand(t), + } + + future, err := client.Update(ctx, id.ResourceGroup, id.Name, parameters) + if err != nil { + return fmt.Errorf("updating %s: %+v", id, err) + } + + if err = future.WaitForCompletionRef(ctx, client.Client); err != nil { + return fmt.Errorf("waiting for update of %s: %+v", id, err) + } + + d.SetId(id.ID()) + + return resourceHealthcareApisWorkspaceRead(d, meta) +} + func resourceHealthcareApisWorkspaceDelete(d *pluginsdk.ResourceData, meta interface{}) error { client := meta.(*clients.Client).HealthCare.HealthcareWorkspaceClient ctx, cancel := timeouts.ForDelete(meta.(*clients.Client).StopContext, d) @@ -142,3 +196,22 @@ func resourceHealthcareApisWorkspaceDelete(d *pluginsdk.ResourceData, meta inter } return nil } + +func flattenWorkspacePrivateEndpoint(input *[]healthcareapis.PrivateEndpointConnection) []interface{} { + results := make([]interface{}, 0) + if input == nil { + return results + } + + for _, endpoint := range *input { + result := map[string]interface{}{} + if endpoint.Name != nil { + result["name"] = *endpoint.Name + } + + if endpoint.ID != nil { + result["id"] = *endpoint.ID + } + } + return results +} diff --git a/internal/services/healthcare/healthcare_apis_workspace_resource_test.go b/internal/services/healthcare/healthcare_workspace_resource_test.go similarity index 100% rename from internal/services/healthcare/healthcare_apis_workspace_resource_test.go rename to internal/services/healthcare/healthcare_workspace_resource_test.go From 57a4702773b8d259b19183e75e1333245621c2c2 Mon Sep 17 00:00:00 2001 From: xiaxyi Date: Thu, 17 Mar 2022 09:53:43 +0800 Subject: [PATCH 06/22] merge main --- .../healthcare/healthcare_dicom_resource.go | 30 +++ .../healthcare_workspace_data_source.go | 67 ------ .../healthcare_workspace_data_source_test.go | 49 ---- .../healthcare_workspace_resource.go | 217 ------------------ .../healthcare_workspace_resource_test.go | 89 ------- internal/services/healthcare/registration.go | 2 - internal/services/healthcare/resourceids.go | 1 - 7 files changed, 30 insertions(+), 425 deletions(-) delete mode 100644 internal/services/healthcare/healthcare_workspace_data_source.go delete mode 100644 internal/services/healthcare/healthcare_workspace_data_source_test.go delete mode 100644 internal/services/healthcare/healthcare_workspace_resource.go delete mode 100644 internal/services/healthcare/healthcare_workspace_resource_test.go diff --git a/internal/services/healthcare/healthcare_dicom_resource.go b/internal/services/healthcare/healthcare_dicom_resource.go index 51f22bee57a5..dd47b3af5330 100644 --- a/internal/services/healthcare/healthcare_dicom_resource.go +++ b/internal/services/healthcare/healthcare_dicom_resource.go @@ -2,6 +2,8 @@ package healthcare import ( "fmt" + "github.com/Azure/azure-sdk-for-go/services/webpubsub/mgmt/2021-10-01/webpubsub" + "github.com/hashicorp/go-azure-helpers/resourcemanager/identity" "github.com/hashicorp/go-azure-helpers/resourcemanager/location" "log" "time" @@ -54,6 +56,8 @@ func resourceHealthcareApisDicomService() *pluginsdk.Resource { "location": commonschema.Location(), + "identity": commonschema.SystemOrUserAssignedIdentityOptional(), + "authentication_configuration": { Type: pluginsdk.TypeList, Optional: true, @@ -126,6 +130,11 @@ func resourceHealthcareApisDicomServiceCreateUpdate(d *pluginsdk.ResourceData, m } } + identity, err := expandManagedIdentity(d.Get("identity").([]interface{})) + if err != nil { + return fmt.Errorf("expanding `identity`: %+v", err) + } + t := d.Get("tags").(map[string]interface{}) parameters := healthcareapis.DicomService{ @@ -247,3 +256,24 @@ func flattenDicomServicePrivateEndpoint(input *[]healthcareapis.PrivateEndpointC } return results } + +func expandManagedIdentity(input []interface{}) (*healthcareapis.ServiceManagedIdentityIdentity, error) { + expanded, err := identity.ExpandSystemOrUserAssignedMap(input) + if err != nil { + return nil, err + } + + out := healthcareapis.ServiceManagedIdentityIdentity{ + Type: healthcareapis.ServiceManagedIdentityType(expanded.Type), + } + + if len(expanded.IdentityIds) > 0 { + out.UserAssignedIdentities = make(map[string]*healthcareapis.UserAssignedIdentity) + for k := range expanded.IdentityIds { + out.UserAssignedIdentities[k] = &healthcareapis.UserAssignedIdentity{ + } + } + } + + return &out, nil +} diff --git a/internal/services/healthcare/healthcare_workspace_data_source.go b/internal/services/healthcare/healthcare_workspace_data_source.go deleted file mode 100644 index ba06a400514e..000000000000 --- a/internal/services/healthcare/healthcare_workspace_data_source.go +++ /dev/null @@ -1,67 +0,0 @@ -package healthcare - -import ( - "fmt" - "time" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema" - "github.com/hashicorp/go-azure-helpers/resourcemanager/location" - "github.com/hashicorp/terraform-provider-azurerm/internal/clients" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/healthcare/parse" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/healthcare/validate" - "github.com/hashicorp/terraform-provider-azurerm/internal/tags" - "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" - "github.com/hashicorp/terraform-provider-azurerm/internal/timeouts" - "github.com/hashicorp/terraform-provider-azurerm/utils" -) - -func dataSourceHealthcareWorkspace() *pluginsdk.Resource { - return &pluginsdk.Resource{ - Read: dataSourceHealthcareWorkspaceRead, - - Timeouts: &pluginsdk.ResourceTimeout{ - Read: pluginsdk.DefaultTimeout(5 * time.Minute), - }, - - Schema: map[string]*pluginsdk.Schema{ - "name": { - Type: pluginsdk.TypeString, - Required: true, - ValidateFunc: validate.WorkspaceName, - }, - - "location": commonschema.Location(), - - "resource_group_name": commonschema.ResourceGroupName(), - - "tags": tags.Schema(), - }, - } -} - -func dataSourceHealthcareWorkspaceRead(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).HealthCare.HealthcareWorkspaceClient - subscriptionId := meta.(*clients.Client).Account.SubscriptionId - ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d) - defer cancel() - - id := parse.NewWorkspaceID(subscriptionId, d.Get("resource_group_name").(string), d.Get("name").(string)) - resp, err := client.Get(ctx, id.ResourceGroup, id.Name) - if err != nil { - if utils.ResponseWasNotFound(resp.Response) { - return fmt.Errorf("%s was not found", id) - } - return fmt.Errorf("retrieving %s: %+v", id, err) - } - - d.SetId(id.ID()) - - d.Set("name", id.Name) - d.Set("resource_group_name", id.ResourceGroup) - - if locations := resp.Location; locations != nil { - d.Set("location", location.Normalize(*locations)) - } - - return tags.FlattenAndSet(d, resp.Tags) -} diff --git a/internal/services/healthcare/healthcare_workspace_data_source_test.go b/internal/services/healthcare/healthcare_workspace_data_source_test.go deleted file mode 100644 index 7a9db80cb253..000000000000 --- a/internal/services/healthcare/healthcare_workspace_data_source_test.go +++ /dev/null @@ -1,49 +0,0 @@ -package healthcare_test - -import ( - "fmt" - "testing" - - "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance" - "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance/check" -) - -type HealthCareWorkspaceDataSource struct{} - -func TestAccHealthCareWorkspaceDataSource_basic(t *testing.T) { - data := acceptance.BuildTestData(t, "data.azurerm_healthcare_workspace", "test") - r := HealthCareWorkspaceDataSource{} - - data.DataSourceTest(t, []acceptance.TestStep{ - { - Config: r.basic(data), - Check: acceptance.ComposeTestCheckFunc( - check.That(data.ResourceName).Key("name").Exists()), - }, - }) -} - -func (HealthCareWorkspaceDataSource) basic(data acceptance.TestData) string { - return fmt.Sprintf(` -provider "azurerm" { - features {} -} - -resource "azurerm_resource_group" "test" { - name = "acctestRG-health-%d" - location = "%s" -} - -resource "azurerm_healthcare_workspace" "test" { - name = "acctestwk%d" - resource_group_name = azurerm_resource_group.test.name - location = azurerm_resource_group.test.location -} - -data "azurerm_healthcare_workspace" "test" { - name = azurerm_healthcare_workspace.test.name - resource_group_name = azurerm_healthcare_workspace.test.resource_group_name - location = azurerm_healthcare_workspace.test.location -} -`, data.RandomInteger, data.Locations.Primary, data.RandomIntOfLength(8)) -} diff --git a/internal/services/healthcare/healthcare_workspace_resource.go b/internal/services/healthcare/healthcare_workspace_resource.go deleted file mode 100644 index 462bf317f1a6..000000000000 --- a/internal/services/healthcare/healthcare_workspace_resource.go +++ /dev/null @@ -1,217 +0,0 @@ -package healthcare - -import ( - "fmt" - "log" - "time" - - "github.com/Azure/azure-sdk-for-go/services/healthcareapis/mgmt/2021-11-01/healthcareapis" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema" - "github.com/hashicorp/go-azure-helpers/resourcemanager/location" - "github.com/hashicorp/terraform-provider-azurerm/helpers/tf" - "github.com/hashicorp/terraform-provider-azurerm/internal/clients" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/healthcare/parse" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/healthcare/validate" - "github.com/hashicorp/terraform-provider-azurerm/internal/tags" - "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" - "github.com/hashicorp/terraform-provider-azurerm/internal/timeouts" - "github.com/hashicorp/terraform-provider-azurerm/utils" -) - -func resourceHealthcareApisWorkspace() *pluginsdk.Resource { - return &pluginsdk.Resource{ - Create: resourceHealthcareApisWorkspaceCreate, - Read: resourceHealthcareApisWorkspaceRead, - Update: resourceHealthcareApisWorkspaceUpdate, - Delete: resourceHealthcareApisWorkspaceDelete, - - Timeouts: &pluginsdk.ResourceTimeout{ - Create: pluginsdk.DefaultTimeout(30 * time.Minute), - Read: pluginsdk.DefaultTimeout(5 * time.Minute), - Update: pluginsdk.DefaultTimeout(30 * time.Minute), - Delete: pluginsdk.DefaultTimeout(30 * time.Minute), - }, - - Importer: pluginsdk.ImporterValidatingResourceId(func(id string) error { - _, err := parse.WorkspaceID(id) - return err - }), - - Schema: map[string]*pluginsdk.Schema{ - "name": { - Type: pluginsdk.TypeString, - Required: true, - ForceNew: true, - ValidateFunc: validate.WorkspaceName, - }, - - "resource_group_name": commonschema.ResourceGroupName(), - - "location": commonschema.Location(), - - "private_endpoint_connection": { - Type: pluginsdk.TypeSet, - Computed: true, - Elem: &pluginsdk.Resource{ - Schema: map[string]*pluginsdk.Schema{ - "name": { - Type: pluginsdk.TypeString, - Computed: true, - }, - - "id": { - Type: pluginsdk.TypeString, - Computed: true, - }, - }, - }, - }, - - "tags": commonschema.Tags(), - }, - } -} - -func resourceHealthcareApisWorkspaceCreate(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).HealthCare.HealthcareWorkspaceClient - subscriptionId := meta.(*clients.Client).Account.SubscriptionId - ctx, cancel := timeouts.ForCreateUpdate(meta.(*clients.Client).StopContext, d) - defer cancel() - log.Printf("[INFO] preparing arguments for AzureRM Healthcare Workspace creation.") - - id := parse.NewWorkspaceID(subscriptionId, d.Get("resource_group_name").(string), d.Get("name").(string)) - if d.IsNewResource() { - existing, err := client.Get(ctx, id.ResourceGroup, id.Name) - if err != nil { - if !utils.ResponseWasNotFound(existing.Response) { - return fmt.Errorf("checking for presence of existing %s: %+v", id, err) - } - } - if !utils.ResponseWasNotFound(existing.Response) { - return tf.ImportAsExistsError("azurerm_healthcare_workspace", id.ID()) - } - } - - location := location.Normalize(d.Get("location").(string)) - t := d.Get("tags").(map[string]interface{}) - - parameters := healthcareapis.Workspace{ - Location: &location, - Tags: tags.Expand(t), - } - - future, err := client.CreateOrUpdate(ctx, id.ResourceGroup, id.Name, parameters) - if err != nil { - return fmt.Errorf("creating/ updating %s: %+v", id, err) - } - - if err = future.WaitForCompletionRef(ctx, client.Client); err != nil { - return fmt.Errorf("waiting for creation/update of %s: %+v", id, err) - } - - d.SetId(id.ID()) - - return resourceHealthcareApisWorkspaceRead(d, meta) -} - -func resourceHealthcareApisWorkspaceRead(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).HealthCare.HealthcareWorkspaceClient - ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d) - defer cancel() - - id, err := parse.WorkspaceID(d.Id()) - if err != nil { - return err - } - - resp, err := client.Get(ctx, id.ResourceGroup, id.Name) - if err != nil { - if utils.ResponseWasNotFound(resp.Response) { - d.SetId("") - return nil - } - return fmt.Errorf("retrieving %s: %+v", *id, err) - } - - d.Set("name", id.Name) - d.Set("resource_group_name", id.ResourceGroup) - if locations := resp.Location; locations != nil { - d.Set("location", location.Normalize(*locations)) - } - - if props := resp.Properties; props != nil { - d.Set("private_endpoint_connection", flattenWorkspacePrivateEndpoint(props.PrivateEndpointConnections)) - } - - return tags.FlattenAndSet(d, resp.Tags) -} - -func resourceHealthcareApisWorkspaceUpdate(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).HealthCare.HealthcareWorkspaceClient - ctx, cancel := timeouts.ForUpdate(meta.(*clients.Client).StopContext, d) - defer cancel() - - id, err := parse.WorkspaceID(d.Id()) - if err != nil { - return err - } - - t := d.Get("tags").(map[string]interface{}) - - parameters := healthcareapis.WorkspacePatchResource{ - Tags: tags.Expand(t), - } - - future, err := client.Update(ctx, id.ResourceGroup, id.Name, parameters) - if err != nil { - return fmt.Errorf("updating %s: %+v", id, err) - } - - if err = future.WaitForCompletionRef(ctx, client.Client); err != nil { - return fmt.Errorf("waiting for update of %s: %+v", id, err) - } - - d.SetId(id.ID()) - - return resourceHealthcareApisWorkspaceRead(d, meta) -} - -func resourceHealthcareApisWorkspaceDelete(d *pluginsdk.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).HealthCare.HealthcareWorkspaceClient - ctx, cancel := timeouts.ForDelete(meta.(*clients.Client).StopContext, d) - defer cancel() - - id, err := parse.WorkspaceID(d.Id()) - if err != nil { - return err - } - - future, err := client.Delete(ctx, id.ResourceGroup, id.Name) - if err != nil { - return fmt.Errorf("deleting %s: %+v", id, err) - } - - if err = future.WaitForCompletionRef(ctx, client.Client); err != nil { - return fmt.Errorf("waiting for the deletion of %s: %+v", *id, err) - } - return nil -} - -func flattenWorkspacePrivateEndpoint(input *[]healthcareapis.PrivateEndpointConnection) []interface{} { - results := make([]interface{}, 0) - if input == nil { - return results - } - - for _, endpoint := range *input { - result := map[string]interface{}{} - if endpoint.Name != nil { - result["name"] = *endpoint.Name - } - - if endpoint.ID != nil { - result["id"] = *endpoint.ID - } - } - return results -} diff --git a/internal/services/healthcare/healthcare_workspace_resource_test.go b/internal/services/healthcare/healthcare_workspace_resource_test.go deleted file mode 100644 index 4f56bf76ff56..000000000000 --- a/internal/services/healthcare/healthcare_workspace_resource_test.go +++ /dev/null @@ -1,89 +0,0 @@ -package healthcare_test - -import ( - "context" - "fmt" - "testing" - - "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance" - "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance/check" - "github.com/hashicorp/terraform-provider-azurerm/internal/clients" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/healthcare/parse" - "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" - "github.com/hashicorp/terraform-provider-azurerm/utils" -) - -type HealthCareWorkspaceResouce struct{} - -func TestAccHealthCareWorkspace_basic(t *testing.T) { - data := acceptance.BuildTestData(t, "azurerm_healthcare_workspace", "test") - r := HealthCareWorkspaceResouce{} - - data.ResourceTest(t, r, []acceptance.TestStep{ - { - Config: r.basic(data), - Check: acceptance.ComposeTestCheckFunc( - check.That(data.ResourceName).ExistsInAzure(r)), - }, - data.ImportStep(), - }) -} - -func TestAccHealthCareWorkspace_requiresImport(t *testing.T) { - data := acceptance.BuildTestData(t, "azurerm_healthcare_workspace", "test") - r := HealthCareWorkspaceResouce{} - - data.ResourceTest(t, r, []acceptance.TestStep{ - { - Config: r.basic(data), - Check: acceptance.ComposeTestCheckFunc( - check.That(data.ResourceName).ExistsInAzure(r)), - }, - data.RequiresImportErrorStep(r.requiresImport), - }) -} - -func (HealthCareWorkspaceResouce) Exists(ctx context.Context, clients *clients.Client, state *pluginsdk.InstanceState) (*bool, error) { - id, err := parse.WorkspaceID(state.ID) - if err != nil { - return nil, err - } - - resp, err := clients.HealthCare.HealthcareWorkspaceClient.Get(ctx, id.ResourceGroup, id.Name) - if err != nil { - return nil, fmt.Errorf("retrieving %s, %+v", *id, err) - } - - return utils.Bool(resp.Properties != nil), nil -} -func (HealthCareWorkspaceResouce) basic(data acceptance.TestData) string { - return fmt.Sprintf(` -provider "azurerm" { - features {} -} - -resource "azurerm_resource_group" "test" { - name = "acctestRG-health-%d" - location = "%s" -} - -resource "azurerm_healthcare_workspace" "test" { - name = "acctestwk%d" - resource_group_name = azurerm_resource_group.test.name - location = azurerm_resource_group.test.location -} -`, data.RandomInteger, data.Locations.Primary, data.RandomIntOfLength(8)) -} - -func (r HealthCareWorkspaceResouce) requiresImport(data acceptance.TestData) string { - return fmt.Sprintf(` -%s -resource "azurerm_healthcare_workspace" "import" { - name = azurerm_healthcare_workspace.test.name - resource_group_name = azurerm_healthcare_workspace.test.resource_group_name - location = azurerm_healthcare_workspace.test.location -} - - -`, r.basic(data)) -} diff --git a/internal/services/healthcare/registration.go b/internal/services/healthcare/registration.go index 2ae287d99a99..8e67572ecb14 100644 --- a/internal/services/healthcare/registration.go +++ b/internal/services/healthcare/registration.go @@ -29,7 +29,6 @@ func (r Registration) WebsiteCategories() []string { func (r Registration) SupportedDataSources() map[string]*pluginsdk.Resource { return map[string]*pluginsdk.Resource{ "azurerm_healthcare_service": dataSourceHealthcareService(), - "azurerm_healthcare_workspace": dataSourceHealthcareWorkspace(), "azurerm_healthcare_dicom_service": dataSourceHealthcareApisDicomService(), } } @@ -38,7 +37,6 @@ func (r Registration) SupportedDataSources() map[string]*pluginsdk.Resource { func (r Registration) SupportedResources() map[string]*pluginsdk.Resource { return map[string]*pluginsdk.Resource{ "azurerm_healthcare_service": resourceHealthcareService(), - "azurerm_healthcare_workspace": resourceHealthcareApisWorkspace(), "azurerm_healthcare_dicom_service": resourceHealthcareApisDicomService(), } } diff --git a/internal/services/healthcare/resourceids.go b/internal/services/healthcare/resourceids.go index b8b2510c7aa4..3d703d57b906 100644 --- a/internal/services/healthcare/resourceids.go +++ b/internal/services/healthcare/resourceids.go @@ -1,5 +1,4 @@ package healthcare //go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=Service -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/group1/providers/Microsoft.HealthcareApis/services/service1 -//go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=Workspace -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/group1/providers/Microsoft.HealthcareApis/workspaces/workspace1 //go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=DicomService -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/group1/providers/Microsoft.HealthcareApis/workspaces/workspace1/dicomservices/service1 From 29d7d1fe767ba93e400cf360772a519615dde352 Mon Sep 17 00:00:00 2001 From: xiaxyi Date: Fri, 18 Mar 2022 09:44:55 +0800 Subject: [PATCH 07/22] dicom update --- internal/services/healthcare/client/client.go | 13 +- .../healthcare_dicom_data_source.go | 54 +++++-- .../healthcare_dicom_data_source_test.go | 35 +++++ .../healthcare/healthcare_dicom_resource.go | 103 +++++++++++-- .../healthcare_dicom_resource_test.go | 145 ++++++++++++++++-- internal/services/healthcare/registration.go | 10 +- internal/services/healthcare/resourceids.go | 1 + website/docs/d/healthcare_dicom.html.markdown | 58 +++++++ website/docs/r/healthcare_dicom.html.markdown | 89 +++++++++++ 9 files changed, 467 insertions(+), 41 deletions(-) create mode 100644 internal/services/healthcare/healthcare_dicom_data_source_test.go create mode 100644 website/docs/d/healthcare_dicom.html.markdown create mode 100644 website/docs/r/healthcare_dicom.html.markdown diff --git a/internal/services/healthcare/client/client.go b/internal/services/healthcare/client/client.go index 6b6e37e26e4a..07984b15646f 100644 --- a/internal/services/healthcare/client/client.go +++ b/internal/services/healthcare/client/client.go @@ -6,8 +6,9 @@ import ( ) type Client struct { - HealthcareServiceClient *healthcareapis.ServicesClient - HealthcareWorkspaceClient *healthcareapis.WorkspacesClient + HealthcareServiceClient *healthcareapis.ServicesClient + HealthcareWorkspaceClient *healthcareapis.WorkspacesClient + HealthcareWorkspaceDicomServiceClient *healthcareapis.DicomServicesClient } func NewClient(o *common.ClientOptions) *Client { @@ -17,8 +18,12 @@ func NewClient(o *common.ClientOptions) *Client { HealthcareWorkspaceClient := healthcareapis.NewWorkspacesClientWithBaseURI(o.ResourceManagerEndpoint, o.SubscriptionId) o.ConfigureClient(&HealthcareWorkspaceClient.Client, o.ResourceManagerAuthorizer) + HealthcareWorkspaceDicomServiceClient := healthcareapis.NewDicomServicesClientWithBaseURI(o.ResourceManagerEndpoint, o.SubscriptionId) + o.ConfigureClient(&HealthcareWorkspaceDicomServiceClient.Client, o.ResourceManagerAuthorizer) + return &Client{ - HealthcareServiceClient: &HealthcareServiceClient, - HealthcareWorkspaceClient: &HealthcareWorkspaceClient, + HealthcareServiceClient: &HealthcareServiceClient, + HealthcareWorkspaceClient: &HealthcareWorkspaceClient, + HealthcareWorkspaceDicomServiceClient: &HealthcareWorkspaceDicomServiceClient, } } diff --git a/internal/services/healthcare/healthcare_dicom_data_source.go b/internal/services/healthcare/healthcare_dicom_data_source.go index 4b7299a8f859..cf5fc9af92e2 100644 --- a/internal/services/healthcare/healthcare_dicom_data_source.go +++ b/internal/services/healthcare/healthcare_dicom_data_source.go @@ -2,10 +2,10 @@ package healthcare import ( "fmt" + "github.com/hashicorp/go-azure-helpers/resourcemanager/location" "time" "github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema" - "github.com/hashicorp/terraform-provider-azurerm/helpers/azure" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" "github.com/hashicorp/terraform-provider-azurerm/internal/services/healthcare/parse" "github.com/hashicorp/terraform-provider-azurerm/internal/services/healthcare/validate" @@ -15,7 +15,7 @@ import ( "github.com/hashicorp/terraform-provider-azurerm/utils" ) -func dataSourceHealthcareApisDicomService() *pluginsdk.Resource { +func dataSourceHealthcareDicomService() *pluginsdk.Resource { return &pluginsdk.Resource{ Read: dataSourceHealthcareApisDicomServiceRead, @@ -30,9 +30,14 @@ func dataSourceHealthcareApisDicomService() *pluginsdk.Resource { ValidateFunc: validate.DicomServiceName(), }, - "location": commonschema.LocationComputed(), + "workspace_id": { + Type: pluginsdk.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: validate.WorkspaceID, + }, - "resource_group_name": azure.SchemaResourceGroupName(), + "location": commonschema.LocationComputed(), "authentication_configuration": { Type: pluginsdk.TypeList, @@ -52,41 +57,62 @@ func dataSourceHealthcareApisDicomService() *pluginsdk.Resource { }, }, + "private_endpoint_connection": { + Type: pluginsdk.TypeList, + Computed: true, + Elem: &pluginsdk.Resource{ + Schema: map[string]*pluginsdk.Schema{ + "name": { + Type: pluginsdk.TypeString, + Computed: true, + }, + + "id": { + Type: pluginsdk.TypeString, + Computed: true, + }, + }, + }, + }, + "service_url": { Type: pluginsdk.TypeString, Computed: true, }, - "tags": commonschema.Tags(), + "tags": tags.SchemaDataSource(), }, } } func dataSourceHealthcareApisDicomServiceRead(d *pluginsdk.ResourceData, meta interface{}) error { client := meta.(*clients.Client).HealthCare.HealthcareWorkspaceDicomServiceClient + subscriptionId := meta.(*clients.Client).Account.SubscriptionId ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d) defer cancel() - id, err := parse.DicomServiceID(d.Id()) + workspaceId, err := parse.WorkspaceID(d.Get("workspace_id").(string)) if err != nil { - return fmt.Errorf("parsing Dicom service error: %+v", err) + return fmt.Errorf("parsing workspace id error: %+v", err) } + id := parse.NewDicomServiceID(subscriptionId, workspaceId.ResourceGroup, workspaceId.Name, d.Get("name").(string)) resp, err := client.Get(ctx, id.ResourceGroup, id.WorkspaceName, id.Name) if err != nil { if utils.ResponseWasNotFound(resp.Response) { d.SetId("") return nil } - return fmt.Errorf("retrieving %s: %+v", *id, err) + return fmt.Errorf("retrieving %s: %+v", id, err) } + d.SetId(id.ID()) + d.Set("name", id.Name) - workspaceId := parse.NewWorkspaceID(id.SubscriptionId, id.ResourceGroup, id.WorkspaceName) d.Set("workspace_id", workspaceId.ID()) if resp.Location != nil { - d.Set("location", azure.NormalizeLocation(*resp.Location)) + d.Set("location", location.Normalize(*resp.Location)) } if props := resp.DicomServiceProperties; props != nil { @@ -95,6 +121,14 @@ func dataSourceHealthcareApisDicomServiceRead(d *pluginsdk.ResourceData, meta in d.Set("service_url", props.ServiceURL) } + identity, err := flattenManagedIdentity(resp.Identity) + if err != nil { + return fmt.Errorf("setting `identity`: %+v", err) + } + if err := d.Set("identity", identity); err != nil { + return fmt.Errorf("setting `identity`: %+v", err) + } + if err := tags.FlattenAndSet(d, resp.Tags); err != nil { return err } diff --git a/internal/services/healthcare/healthcare_dicom_data_source_test.go b/internal/services/healthcare/healthcare_dicom_data_source_test.go new file mode 100644 index 000000000000..854fa0f0be89 --- /dev/null +++ b/internal/services/healthcare/healthcare_dicom_data_source_test.go @@ -0,0 +1,35 @@ +package healthcare_test + +import ( + "fmt" + "testing" + + "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance" + "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance/check" +) + +type HealthCareDicomServiceDataSource struct{} + +func TestAccHealthCareDicomDataSource_basic(t *testing.T) { + data := acceptance.BuildTestData(t, "data.azurerm_healthcare_dicom_service", "test") + r := HealthCareDicomServiceDataSource{} + + data.DataSourceTest(t, []acceptance.TestStep{ + { + Config: r.basic(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).Key("name").Exists()), + }, + }) +} + +func (r HealthCareDicomServiceDataSource) basic(data acceptance.TestData) string { + return fmt.Sprintf(` +%s + +data "azurerm_healthcare_dicom_service" "test" { + name = azurerm_healthcare_dicom_service.test.name + workspace_id = azurerm_healthcare_dicom_service.test.workspace_id +} +`, HealthCareDicomResource{}.complete(data)) +} diff --git a/internal/services/healthcare/healthcare_dicom_resource.go b/internal/services/healthcare/healthcare_dicom_resource.go index dd47b3af5330..714904526356 100644 --- a/internal/services/healthcare/healthcare_dicom_resource.go +++ b/internal/services/healthcare/healthcare_dicom_resource.go @@ -2,14 +2,13 @@ package healthcare import ( "fmt" - "github.com/Azure/azure-sdk-for-go/services/webpubsub/mgmt/2021-10-01/webpubsub" - "github.com/hashicorp/go-azure-helpers/resourcemanager/identity" - "github.com/hashicorp/go-azure-helpers/resourcemanager/location" "log" "time" "github.com/Azure/azure-sdk-for-go/services/healthcareapis/mgmt/2021-11-01/healthcareapis" "github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema" + "github.com/hashicorp/go-azure-helpers/resourcemanager/identity" + "github.com/hashicorp/go-azure-helpers/resourcemanager/location" "github.com/hashicorp/terraform-provider-azurerm/helpers/tf" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" "github.com/hashicorp/terraform-provider-azurerm/internal/services/healthcare/parse" @@ -22,9 +21,9 @@ import ( func resourceHealthcareApisDicomService() *pluginsdk.Resource { return &pluginsdk.Resource{ - Create: resourceHealthcareApisDicomServiceCreateUpdate, + Create: resourceHealthcareApisDicomServiceCreate, Read: resourceHealthcareApisDicomServiceRead, - Update: resourceHealthcareApisDicomServiceCreateUpdate, + Update: resourceHealthcareApisDicomServiceUpdate, Delete: resourceHealthcareApisDicomServiceDelete, Timeouts: &pluginsdk.ResourceTimeout{ @@ -60,7 +59,7 @@ func resourceHealthcareApisDicomService() *pluginsdk.Resource { "authentication_configuration": { Type: pluginsdk.TypeList, - Optional: true, + Computed: true, Elem: &pluginsdk.Resource{ Schema: map[string]*pluginsdk.Schema{ "authority": { @@ -104,9 +103,9 @@ func resourceHealthcareApisDicomService() *pluginsdk.Resource { } } -func resourceHealthcareApisDicomServiceCreateUpdate(d *pluginsdk.ResourceData, meta interface{}) error { +func resourceHealthcareApisDicomServiceCreate(d *pluginsdk.ResourceData, meta interface{}) error { client := meta.(*clients.Client).HealthCare.HealthcareWorkspaceDicomServiceClient - ctx, cancel := timeouts.ForCreateUpdate(meta.(*clients.Client).StopContext, d) + ctx, cancel := timeouts.ForCreate(meta.(*clients.Client).StopContext, d) defer cancel() log.Printf("[INFO] preparing arguments for AzureRM Healthcare Dicom Service creation.") @@ -126,7 +125,7 @@ func resourceHealthcareApisDicomServiceCreateUpdate(d *pluginsdk.ResourceData, m } if !utils.ResponseWasNotFound(existing.Response) { - return tf.ImportAsExistsError("azurerm_healthcareapis_dicom_service", dicomServiceId.ID()) + return tf.ImportAsExistsError("azurerm_healthcare_dicom_service", dicomServiceId.ID()) } } @@ -138,6 +137,7 @@ func resourceHealthcareApisDicomServiceCreateUpdate(d *pluginsdk.ResourceData, m t := d.Get("tags").(map[string]interface{}) parameters := healthcareapis.DicomService{ + Identity: identity, Location: utils.String(location.Normalize(d.Get("location").(string))), Tags: tags.Expand(t), } @@ -152,6 +152,7 @@ func resourceHealthcareApisDicomServiceCreateUpdate(d *pluginsdk.ResourceData, m } d.SetId(dicomServiceId.ID()) + return resourceHealthcareApisDicomServiceRead(d, meta) } @@ -188,6 +189,15 @@ func resourceHealthcareApisDicomServiceRead(d *pluginsdk.ResourceData, meta inte d.Set("service_url", props.ServiceURL) } + identity, err := flattenManagedIdentity(resp.Identity) + if err != nil { + return fmt.Errorf("setting `identity`: %+v", err) + } + + if err := d.Set("identity", identity); err != nil { + return fmt.Errorf("setting `identity`: %+v", err) + } + if err := tags.FlattenAndSet(d, resp.Tags); err != nil { return err } @@ -195,6 +205,46 @@ func resourceHealthcareApisDicomServiceRead(d *pluginsdk.ResourceData, meta inte return nil } +func resourceHealthcareApisDicomServiceUpdate(d *pluginsdk.ResourceData, meta interface{}) error { + client := meta.(*clients.Client).HealthCare.HealthcareWorkspaceDicomServiceClient + ctx, cancel := timeouts.ForUpdate(meta.(*clients.Client).StopContext, d) + defer cancel() + + dicomServiceId, err := parse.DicomServiceID(d.Id()) + if err != nil { + return err + } + + existing, err := client.Get(ctx, dicomServiceId.ResourceGroup, dicomServiceId.WorkspaceName, dicomServiceId.Name) + if err != nil { + return fmt.Errorf("retrieving %s: %+v", *dicomServiceId, err) + } + if existing.DicomServiceProperties == nil { + return fmt.Errorf("retrieving %s: `properties` was nil", *dicomServiceId) + } + + update := healthcareapis.DicomServicePatchResource{} + + update.Tags = tags.Expand(d.Get("tags").(map[string]interface{})) + + identity, err := expandManagedIdentity(d.Get("identity").([]interface{})) + if err != nil { + return fmt.Errorf("expanding `identity`: %+v", err) + } + update.Identity = identity + + future, err := client.Update(ctx, dicomServiceId.ResourceGroup, dicomServiceId.Name, dicomServiceId.WorkspaceName, update) + if err != nil { + return fmt.Errorf("updating %s: %+v", dicomServiceId, err) + } + + if err = future.WaitForCompletionRef(ctx, client.Client); err != nil { + return fmt.Errorf("waiting for update %s: %+v", dicomServiceId, err) + } + + return resourceHealthcareApisDicomServiceRead(d, meta) +} + func resourceHealthcareApisDicomServiceDelete(d *pluginsdk.ResourceData, meta interface{}) error { client := meta.(*clients.Client).HealthCare.HealthcareWorkspaceDicomServiceClient ctx, cancel := timeouts.ForDelete(meta.(*clients.Client).StopContext, d) @@ -264,16 +314,45 @@ func expandManagedIdentity(input []interface{}) (*healthcareapis.ServiceManagedI } out := healthcareapis.ServiceManagedIdentityIdentity{ - Type: healthcareapis.ServiceManagedIdentityType(expanded.Type), + Type: healthcareapis.ServiceManagedIdentityType(string(expanded.Type)), } if len(expanded.IdentityIds) > 0 { out.UserAssignedIdentities = make(map[string]*healthcareapis.UserAssignedIdentity) for k := range expanded.IdentityIds { - out.UserAssignedIdentities[k] = &healthcareapis.UserAssignedIdentity{ - } + out.UserAssignedIdentities[k] = &healthcareapis.UserAssignedIdentity{} } } return &out, nil } + +func flattenManagedIdentity(input *healthcareapis.ServiceManagedIdentityIdentity) (*[]interface{}, error) { + var transform *identity.SystemOrUserAssignedMap + + if input != nil { + transform = &identity.SystemOrUserAssignedMap{ + IdentityIds: make(map[string]identity.UserAssignedIdentityDetails), + Type: identity.Type(string(input.Type)), + } + if input.PrincipalID != nil { + id := *input.PrincipalID + transform.PrincipalId = id.String() + } + if input.TenantID != nil { + tenantID := *input.TenantID + transform.TenantId = tenantID.String() + } + + for k, v := range input.UserAssignedIdentities { + clientID := v.ClientID + principalID := v.PrincipalID + transform.IdentityIds[k] = identity.UserAssignedIdentityDetails{ + ClientId: utils.String(clientID.String()), + PrincipalId: utils.String(principalID.String()), + } + } + } + + return identity.FlattenSystemOrUserAssignedMap(transform) +} diff --git a/internal/services/healthcare/healthcare_dicom_resource_test.go b/internal/services/healthcare/healthcare_dicom_resource_test.go index 4bf980573c2c..17b8baac647d 100644 --- a/internal/services/healthcare/healthcare_dicom_resource_test.go +++ b/internal/services/healthcare/healthcare_dicom_resource_test.go @@ -3,10 +3,10 @@ package healthcare_test import ( "context" "fmt" - "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance/check" "testing" "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance" + "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance/check" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" "github.com/hashicorp/terraform-provider-azurerm/internal/services/healthcare/parse" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" @@ -29,9 +29,63 @@ func TestAccHealthCareDicom_basic(t *testing.T) { }) } +func TestAccHealthCareDicom_complete(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_healthcare_dicom_service", "test") + r := HealthCareDicomResource{} + + data.ResourceTest(t, r, []acceptance.TestStep{ + { + Config: r.complete(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r)), + }, + data.ImportStep(), + }) +} + +func TestAccHealthCareDicom_update(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_healthcare_dicom_service", "test") + r := HealthCareDicomResource{} + + data.ResourceTest(t, r, []acceptance.TestStep{ + { + Config: r.basic(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r)), + }, + data.ImportStep(), + { + Config: r.update(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r)), + }, + data.ImportStep(), + }) +} + +func TestAccHealthCareDicom_updateIdentity(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_healthcare_dicom_service", "test") + r := HealthCareDicomResource{} + + data.ResourceTest(t, r, []acceptance.TestStep{ + { + Config: r.complete(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r)), + }, + data.ImportStep(), + { + Config: r.userAssignedIdentity(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r)), + }, + data.ImportStep(), + }) +} + func TestAccHealthCareDicom_requiresImport(t *testing.T) { data := acceptance.BuildTestData(t, "azurerm_healthcare_dicom_service", "test") - r := HealthCareWorkspaceResouce{} + r := HealthCareDicomResource{} data.ResourceTest(t, r, []acceptance.TestStep{ { @@ -57,19 +111,60 @@ func (HealthCareDicomResource) Exists(ctx context.Context, clients *clients.Clie return utils.Bool(resp.DicomServiceProperties != nil), nil } -func (HealthCareDicomResource) basic(data acceptance.TestData) string { +func (r HealthCareDicomResource) basic(data acceptance.TestData) string { return fmt.Sprintf(` -provider "azurerm" { - features {} +%s + +resource "azurerm_healthcare_dicom_service" "test" { + name = "acctest-dicom%d" + workspace_id = azurerm_healthcare_workspace.test.id + location = "east us" +} +`, r.template(data), data.RandomIntOfLength(8)) } -resource "azurerm_resource_group" "test" { - name = "acctestRG-hcwk-%d" - location = "%s" +func (r HealthCareDicomResource) complete(data acceptance.TestData) string { + return fmt.Sprintf(` +%s + +resource "azurerm_healthcare_dicom_service" "test" { + name = "acctest-dicom%d" + workspace_id = azurerm_healthcare_workspace.test.id + location = "east us" + + identity { + type = "SystemAssigned" + } + + tags = { + environment = "None" + } +} +`, r.template(data), data.RandomIntOfLength(8)) } -resource "azurerm_healthcare_workspace" "test" { - name = "acctestwk%d" +func (r HealthCareDicomResource) update(data acceptance.TestData) string { + return fmt.Sprintf(` +%s + +resource "azurerm_healthcare_dicom_service" "test" { + name = "acctest-dicom%d" + workspace_id = azurerm_healthcare_workspace.test.id + location = "east us" + + tags = { + environment = "Prod" + } +} +`, r.template(data), data.RandomIntOfLength(8)) +} + +func (r HealthCareDicomResource) userAssignedIdentity(data acceptance.TestData) string { + return fmt.Sprintf(` +%s + +resource "azurerm_user_assigned_identity" "test" { + name = "acctest-uai-%d" resource_group_name = azurerm_resource_group.test.name location = azurerm_resource_group.test.location } @@ -78,8 +173,17 @@ resource "azurerm_healthcare_dicom_service" "test" { name = "acctest-dicom%d" workspace_id = azurerm_healthcare_workspace.test.id location = "east us" + + identity { + type = "UserAssigned" + identity_ids = [azurerm_user_assigned_identity.test.id] + } + + tags = { + environment = "None" + } } -`, data.RandomInteger, data.Locations.Primary, data.RandomIntOfLength(8), data.RandomIntOfLength(8)) +`, r.template(data), data.RandomInteger, data.RandomIntOfLength(8)) } func (r HealthCareDicomResource) requiresImport(data acceptance.TestData) string { @@ -92,3 +196,22 @@ resource "azurerm_healthcare_dicom_service" "import" { } `, r.basic(data)) } + +func (HealthCareDicomResource) template(data acceptance.TestData) string { + return fmt.Sprintf(` +provider "azurerm" { + features {} +} + +resource "azurerm_resource_group" "test" { + name = "acctestRG-dicom-%d" + location = "%s" +} + +resource "azurerm_healthcare_workspace" "test" { + name = "acctestwk%d" + resource_group_name = azurerm_resource_group.test.name + location = azurerm_resource_group.test.location +} +`, data.RandomInteger, data.Locations.Primary, data.RandomIntOfLength(8)) +} diff --git a/internal/services/healthcare/registration.go b/internal/services/healthcare/registration.go index 75f534108c4f..632233c1fb59 100644 --- a/internal/services/healthcare/registration.go +++ b/internal/services/healthcare/registration.go @@ -28,15 +28,17 @@ func (r Registration) WebsiteCategories() []string { // SupportedDataSources returns the supported Data Sources supported by this Service func (r Registration) SupportedDataSources() map[string]*pluginsdk.Resource { return map[string]*pluginsdk.Resource{ - "azurerm_healthcare_service": dataSourceHealthcareService(), - "azurerm_healthcare_workspace": dataSourceHealthcareWorkspace(), + "azurerm_healthcare_service": dataSourceHealthcareService(), + "azurerm_healthcare_workspace": dataSourceHealthcareWorkspace(), + "azurerm_healthcare_dicom_service": dataSourceHealthcareDicomService(), } } // SupportedResources returns the supported Resources supported by this Service func (r Registration) SupportedResources() map[string]*pluginsdk.Resource { return map[string]*pluginsdk.Resource{ - "azurerm_healthcare_service": resourceHealthcareService(), - "azurerm_healthcare_workspace": resourceHealthcareApisWorkspace(), + "azurerm_healthcare_service": resourceHealthcareService(), + "azurerm_healthcare_workspace": resourceHealthcareApisWorkspace(), + "azurerm_healthcare_dicom_service": resourceHealthcareApisDicomService(), } } diff --git a/internal/services/healthcare/resourceids.go b/internal/services/healthcare/resourceids.go index 0f0d65503ecb..b8b2510c7aa4 100644 --- a/internal/services/healthcare/resourceids.go +++ b/internal/services/healthcare/resourceids.go @@ -2,3 +2,4 @@ package healthcare //go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=Service -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/group1/providers/Microsoft.HealthcareApis/services/service1 //go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=Workspace -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/group1/providers/Microsoft.HealthcareApis/workspaces/workspace1 +//go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=DicomService -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/group1/providers/Microsoft.HealthcareApis/workspaces/workspace1/dicomservices/service1 diff --git a/website/docs/d/healthcare_dicom.html.markdown b/website/docs/d/healthcare_dicom.html.markdown new file mode 100644 index 000000000000..e40f9a567f96 --- /dev/null +++ b/website/docs/d/healthcare_dicom.html.markdown @@ -0,0 +1,58 @@ +--- +subcategory: "Healthcare" +layout: "azurerm" +page_title: "Azure Resource Manager: azurerm_healthcare_dicom_service" +description: |- + Get information about an existing Healthcare Dicom Service +--- + +# Data Source: azurerm_healthcare_dicom_service + +Use this data source to access information about an existing Healthcare Dicom Service + +## Example Usage + +```hcl +data "azurerm_healthcare_dicom_service" "example" { + name = "example-healthcare_dicom_service" + workspace_id = "example_healthcare_workspace" +} + +output "azurerm_healthcare_dicom_service" { + value = data.azurerm_healthcare_dicom_service.example.id +} +``` + +## Argument Reference + +* `name` - The name of the Healthcare Dicom Service + +* `workspace_id` - The name of the Healthcare Workspace in which the Healthcare Dicom Service exists. + +## Attributes Reference + +The following attributes are exported: + +* `id` - The ID of the Healthcare Workspace. + +* `location` - The Azure Region where the Healthcare Dicom Service is located. + +* `authentication_configuration` - The `authentication_configuration` block as defined below. + +* `service_url` - The url of the Healthcare Dicom Services. + +* `tags` - A map of tags assigned to the Healthcare Dicom Service. + +--- +An `authentication_configuration` supports the following: + +* `authority` - The Azure Active Directory (tenant) that serves as the authentication authority to access the service. The default authority is the Directory defined in the authentication scheme in use when running Terraform. + Authority must be registered to Azure AD and in the following format: https://{Azure-AD-endpoint}/{tenant-id}. + +* `audience` - The intended audience to receive authentication tokens for the service. The default value is https://dicom.azurehealthcareapis.azure.com + +## Timeouts + +The `timeouts` block allows you to specify [timeouts](https://www.terraform.io/docs/configuration/resources.html#timeouts) for certain actions: + +* `read` - (Defaults to 5 minutes) Used when retrieving the Healthcare Dicom Service. diff --git a/website/docs/r/healthcare_dicom.html.markdown b/website/docs/r/healthcare_dicom.html.markdown new file mode 100644 index 000000000000..a3721b5b0e72 --- /dev/null +++ b/website/docs/r/healthcare_dicom.html.markdown @@ -0,0 +1,89 @@ +--- +subcategory: "Healthcare" +layout: "azurerm" +page_title: "Azure Resource Manager: azurerm_healthcare_dicom_service" +description: |- + Manages a Healthcare Dicom Service. +--- + +# azurerm_healthcare_dicom_service + +Manages a Healthcare Dicom Service + +## Example Usage + +```hcl +resource "azurerm_healthcare_workspace" "test" { + name = "tfexworkspace" + resource_group_name = "tfex-resource_group" + location = "east us" +} + +resource "azurerm_healthcare_dicom_service" "test" { + name = "tfexDicom" + workspace_id = azurerm_healthcare_workspace.test.id + location = "east us" + + identity { + type = "SystemAssigned" + } + + tags = { + environment = "None" + } +} +``` + +## Argument Reference + +The following arguments are supported: + +* `name` - (Required) Specifies the name of the Healthcare Dicom Service. Changing this forces a new Healthcare Workspace to be created. + +* `workspace_id` - (Required) Specifies the name of the Healthcare Workspace where the Healthcare Dicom Service should exist. Changing this forces a new Healthcare Workspace to be created. + +* `location` - (Required) Specifies the Azure Region where the Healthcare Dicom Service should be created. Changing this forces a new Healthcare Workspace to be created. + +* `identity` - (Optional) An `identity` block as defined below. + +--- + +An `identity` block supports the following: + +* `type` - (Required) The type of identity used for the Healthcare Dicom service. Possible values are `SystemAssigned` and `UserAssigned`. If `UserAssigned` is set, an `identity_ids` must be set as well. + +* `identity_ids` - (Optional) A list of User Assigned Identity IDs which should be assigned to this Healthcare Dicom service. + +## Attributes Reference + +The following attributes are exported: + +* `id` - The ID of the Healthcare Dicom Service. + +* `authentication_configuration` - The `authentication_configuration` block as defined below. + +* `service_url` - The url of the Healthcare Dicom Services. + +--- +An `authentication_configuration` supports the following: + +* `authority` - The Azure Active Directory (tenant) that serves as the authentication authority to access the service. The default authority is the Directory defined in the authentication scheme in use when running Terraform. + Authority must be registered to Azure AD and in the following format: https://{Azure-AD-endpoint}/{tenant-id}. + +* `audience` - The intended audience to receive authentication tokens for the service. The default value is https://dicom.azurehealthcareapis.azure.com + +## Timeouts +The `timeouts` block allows you to specify [timeouts](https://www.terraform.io/docs/configuration/resources.html#timeouts) for certain actions: + +* `create` - (Defaults to 30 minutes) Used when creating the Healthcare Dicom Service. + * `update` - (Defaults to 30 minutes) Used when updating the Healthcare Dicom Service. + * `read` - (Defaults to 5 minutes) Used when retrieving the Healthcare Dicom Service. + * `delete` - (Defaults to 30 minutes) Used when deleting the Healthcare Dicom Service. + +## Import + +Healthcare Dicom Service can be imported using the resource`id`, e.g. + +```shell +terraform import azurerm_healthcare_dicom_service.example /subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/group1/providers/Microsoft.HealthcareApis/workspaces/workspace1/dicomservices/service1 +``` From ef05499839668751f391cbc1bd2671e761cc50eb Mon Sep 17 00:00:00 2001 From: xiaxin18 Date: Fri, 18 Mar 2022 22:39:06 +0800 Subject: [PATCH 08/22] dicom --- .../healthcare_dicom_data_source.go | 5 +- .../healthcare/healthcare_dicom_resource.go | 70 ++++++++----------- .../healthcare_dicom_resource_test.go | 2 +- website/docs/r/healthcare_dicom.html.markdown | 6 +- 4 files changed, 34 insertions(+), 49 deletions(-) diff --git a/internal/services/healthcare/healthcare_dicom_data_source.go b/internal/services/healthcare/healthcare_dicom_data_source.go index cf5fc9af92e2..41125cff5b6b 100644 --- a/internal/services/healthcare/healthcare_dicom_data_source.go +++ b/internal/services/healthcare/healthcare_dicom_data_source.go @@ -121,10 +121,7 @@ func dataSourceHealthcareApisDicomServiceRead(d *pluginsdk.ResourceData, meta in d.Set("service_url", props.ServiceURL) } - identity, err := flattenManagedIdentity(resp.Identity) - if err != nil { - return fmt.Errorf("setting `identity`: %+v", err) - } + identity, _ := flattenDicomManagedIdentity(resp.Identity) if err := d.Set("identity", identity); err != nil { return fmt.Errorf("setting `identity`: %+v", err) } diff --git a/internal/services/healthcare/healthcare_dicom_resource.go b/internal/services/healthcare/healthcare_dicom_resource.go index 714904526356..7a4ad275e1f9 100644 --- a/internal/services/healthcare/healthcare_dicom_resource.go +++ b/internal/services/healthcare/healthcare_dicom_resource.go @@ -55,7 +55,7 @@ func resourceHealthcareApisDicomService() *pluginsdk.Resource { "location": commonschema.Location(), - "identity": commonschema.SystemOrUserAssignedIdentityOptional(), + "identity": commonschema.SystemAssignedUserAssignedIdentityOptional(), "authentication_configuration": { Type: pluginsdk.TypeList, @@ -129,7 +129,7 @@ func resourceHealthcareApisDicomServiceCreate(d *pluginsdk.ResourceData, meta in } } - identity, err := expandManagedIdentity(d.Get("identity").([]interface{})) + identity, err := expandDicomManagedIdentity(d.Get("identity").([]interface{})) if err != nil { return fmt.Errorf("expanding `identity`: %+v", err) } @@ -189,11 +189,7 @@ func resourceHealthcareApisDicomServiceRead(d *pluginsdk.ResourceData, meta inte d.Set("service_url", props.ServiceURL) } - identity, err := flattenManagedIdentity(resp.Identity) - if err != nil { - return fmt.Errorf("setting `identity`: %+v", err) - } - + identity, _ := flattenDicomManagedIdentity(resp.Identity) if err := d.Set("identity", identity); err != nil { return fmt.Errorf("setting `identity`: %+v", err) } @@ -201,47 +197,40 @@ func resourceHealthcareApisDicomServiceRead(d *pluginsdk.ResourceData, meta inte if err := tags.FlattenAndSet(d, resp.Tags); err != nil { return err } - return nil } func resourceHealthcareApisDicomServiceUpdate(d *pluginsdk.ResourceData, meta interface{}) error { client := meta.(*clients.Client).HealthCare.HealthcareWorkspaceDicomServiceClient - ctx, cancel := timeouts.ForUpdate(meta.(*clients.Client).StopContext, d) + ctx, cancel := timeouts.ForCreateUpdate(meta.(*clients.Client).StopContext, d) defer cancel() - dicomServiceId, err := parse.DicomServiceID(d.Id()) + id, err := parse.DicomServiceID(d.Id()) if err != nil { return err } - existing, err := client.Get(ctx, dicomServiceId.ResourceGroup, dicomServiceId.WorkspaceName, dicomServiceId.Name) - if err != nil { - return fmt.Errorf("retrieving %s: %+v", *dicomServiceId, err) - } - if existing.DicomServiceProperties == nil { - return fmt.Errorf("retrieving %s: `properties` was nil", *dicomServiceId) - } - - update := healthcareapis.DicomServicePatchResource{} - - update.Tags = tags.Expand(d.Get("tags").(map[string]interface{})) - - identity, err := expandManagedIdentity(d.Get("identity").([]interface{})) + expandedIdentity, err := expandDicomManagedIdentity(d.Get("identity").([]interface{})) if err != nil { return fmt.Errorf("expanding `identity`: %+v", err) } - update.Identity = identity - future, err := client.Update(ctx, dicomServiceId.ResourceGroup, dicomServiceId.Name, dicomServiceId.WorkspaceName, update) + parameters := healthcareapis.DicomService{ + Location: utils.String(location.Normalize(d.Get("location").(string))), + Identity: expandedIdentity, + DicomServiceProperties: &healthcareapis.DicomServiceProperties{}, + Tags: tags.Expand(d.Get("tags").(map[string]interface{})), + } + future, err := client.CreateOrUpdate(ctx, id.ResourceGroup, id.WorkspaceName, id.Name, parameters) if err != nil { - return fmt.Errorf("updating %s: %+v", dicomServiceId, err) + return fmt.Errorf("updating %s: %+v", id, err) } if err = future.WaitForCompletionRef(ctx, client.Client); err != nil { - return fmt.Errorf("waiting for update %s: %+v", dicomServiceId, err) + return fmt.Errorf("waiting for update %s: %+v", id, err) } + d.SetId(id.ID()) return resourceHealthcareApisDicomServiceRead(d, meta) } @@ -307,8 +296,8 @@ func flattenDicomServicePrivateEndpoint(input *[]healthcareapis.PrivateEndpointC return results } -func expandManagedIdentity(input []interface{}) (*healthcareapis.ServiceManagedIdentityIdentity, error) { - expanded, err := identity.ExpandSystemOrUserAssignedMap(input) +func expandDicomManagedIdentity(input []interface{}) (*healthcareapis.ServiceManagedIdentityIdentity, error) { + expanded, err := identity.ExpandSystemAndUserAssignedMap(input) if err != nil { return nil, err } @@ -317,23 +306,24 @@ func expandManagedIdentity(input []interface{}) (*healthcareapis.ServiceManagedI Type: healthcareapis.ServiceManagedIdentityType(string(expanded.Type)), } - if len(expanded.IdentityIds) > 0 { + if expanded.Type == identity.TypeUserAssigned || expanded.Type == identity.TypeSystemAssignedUserAssigned { out.UserAssignedIdentities = make(map[string]*healthcareapis.UserAssignedIdentity) for k := range expanded.IdentityIds { - out.UserAssignedIdentities[k] = &healthcareapis.UserAssignedIdentity{} + out.UserAssignedIdentities[k] = &healthcareapis.UserAssignedIdentity{ + // intentionally empty + } } } - return &out, nil } -func flattenManagedIdentity(input *healthcareapis.ServiceManagedIdentityIdentity) (*[]interface{}, error) { - var transform *identity.SystemOrUserAssignedMap +func flattenDicomManagedIdentity(input *healthcareapis.ServiceManagedIdentityIdentity) (*[]interface{}, error) { + var transform *identity.SystemAndUserAssignedMap if input != nil { - transform = &identity.SystemOrUserAssignedMap{ - IdentityIds: make(map[string]identity.UserAssignedIdentityDetails), + transform = &identity.SystemAndUserAssignedMap{ Type: identity.Type(string(input.Type)), + IdentityIds: make(map[string]identity.UserAssignedIdentityDetails), } if input.PrincipalID != nil { id := *input.PrincipalID @@ -345,14 +335,12 @@ func flattenManagedIdentity(input *healthcareapis.ServiceManagedIdentityIdentity } for k, v := range input.UserAssignedIdentities { - clientID := v.ClientID - principalID := v.PrincipalID transform.IdentityIds[k] = identity.UserAssignedIdentityDetails{ - ClientId: utils.String(clientID.String()), - PrincipalId: utils.String(principalID.String()), + ClientId: utils.String(v.ClientID.String()), + PrincipalId: utils.String(v.PrincipalID.String()), } } } - return identity.FlattenSystemOrUserAssignedMap(transform) + return identity.FlattenSystemAndUserAssignedMap(transform) } diff --git a/internal/services/healthcare/healthcare_dicom_resource_test.go b/internal/services/healthcare/healthcare_dicom_resource_test.go index 17b8baac647d..e35292a34813 100644 --- a/internal/services/healthcare/healthcare_dicom_resource_test.go +++ b/internal/services/healthcare/healthcare_dicom_resource_test.go @@ -63,7 +63,7 @@ func TestAccHealthCareDicom_update(t *testing.T) { }) } -func TestAccHealthCareDicom_updateIdentity(t *testing.T) { +func TestAccHealthCareDicom_userAssignedIdentity(t *testing.T) { data := acceptance.BuildTestData(t, "azurerm_healthcare_dicom_service", "test") r := HealthCareDicomResource{} diff --git a/website/docs/r/healthcare_dicom.html.markdown b/website/docs/r/healthcare_dicom.html.markdown index a3721b5b0e72..3baeed94afd1 100644 --- a/website/docs/r/healthcare_dicom.html.markdown +++ b/website/docs/r/healthcare_dicom.html.markdown @@ -38,11 +38,11 @@ resource "azurerm_healthcare_dicom_service" "test" { The following arguments are supported: -* `name` - (Required) Specifies the name of the Healthcare Dicom Service. Changing this forces a new Healthcare Workspace to be created. +* `name` - (Required) Specifies the name of the Healthcare Dicom Service. Changing this forces a new Healthcare Dicom Service to be created. -* `workspace_id` - (Required) Specifies the name of the Healthcare Workspace where the Healthcare Dicom Service should exist. Changing this forces a new Healthcare Workspace to be created. +* `workspace_id` - (Required) Specifies the name of the Healthcare Workspace where the Healthcare Dicom Service should exist. Changing this forces a new Healthcare Dicom Service to be created. -* `location` - (Required) Specifies the Azure Region where the Healthcare Dicom Service should be created. Changing this forces a new Healthcare Workspace to be created. +* `location` - (Required) Specifies the Azure Region where the Healthcare Dicom Service should be created. Changing this forces a new Healthcare Dicom Service to be created. * `identity` - (Optional) An `identity` block as defined below. From 4b7c5f25a9f5ce017df01213abde2d67ddc0b578 Mon Sep 17 00:00:00 2001 From: xiaxin18 Date: Fri, 18 Mar 2022 22:55:10 +0800 Subject: [PATCH 09/22] dicom update --- .../healthcare/healthcare_dicom_resource.go | 26 ++++++++++++++++++- website/docs/r/healthcare_dicom.html.markdown | 2 ++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/internal/services/healthcare/healthcare_dicom_resource.go b/internal/services/healthcare/healthcare_dicom_resource.go index 7a4ad275e1f9..b69613028040 100644 --- a/internal/services/healthcare/healthcare_dicom_resource.go +++ b/internal/services/healthcare/healthcare_dicom_resource.go @@ -98,6 +98,12 @@ func resourceHealthcareApisDicomService() *pluginsdk.Resource { Computed: true, }, + "public_network_access_enabled" :{ + Type: pluginsdk.TypeBool, + Optional: true, + Default: true, + }, + "tags": commonschema.Tags(), }, } @@ -138,9 +144,15 @@ func resourceHealthcareApisDicomServiceCreate(d *pluginsdk.ResourceData, meta in parameters := healthcareapis.DicomService{ Identity: identity, + DicomServiceProperties:&healthcareapis.DicomServiceProperties{ + PublicNetworkAccess:healthcareapis.PublicNetworkAccessEnabled, + }, Location: utils.String(location.Normalize(d.Get("location").(string))), Tags: tags.Expand(t), } + if enabled := d.Get("public_network_access_enabled").(bool); !enabled { + parameters.DicomServiceProperties.PublicNetworkAccess = healthcareapis.PublicNetworkAccessDisabled + } future, err := client.CreateOrUpdate(ctx, dicomServiceId.ResourceGroup, dicomServiceId.WorkspaceName, dicomServiceId.Name, parameters) if err != nil { @@ -187,8 +199,13 @@ func resourceHealthcareApisDicomServiceRead(d *pluginsdk.ResourceData, meta inte d.Set("authentication_configuration", flattenDicomAuthentication(props.AuthenticationConfiguration)) d.Set("private_endpoint_connection", flattenDicomServicePrivateEndpoint(props.PrivateEndpointConnections)) d.Set("service_url", props.ServiceURL) + + if props.PublicNetworkAccess != "" { + d.Set("public_network_access_enabled", props.PublicNetworkAccess == healthcareapis.PublicNetworkAccessEnabled) + } } + identity, _ := flattenDicomManagedIdentity(resp.Identity) if err := d.Set("identity", identity); err != nil { return fmt.Errorf("setting `identity`: %+v", err) @@ -218,9 +235,16 @@ func resourceHealthcareApisDicomServiceUpdate(d *pluginsdk.ResourceData, meta in parameters := healthcareapis.DicomService{ Location: utils.String(location.Normalize(d.Get("location").(string))), Identity: expandedIdentity, - DicomServiceProperties: &healthcareapis.DicomServiceProperties{}, + DicomServiceProperties: &healthcareapis.DicomServiceProperties{ + PublicNetworkAccess: healthcareapis.PublicNetworkAccessEnabled, + }, Tags: tags.Expand(d.Get("tags").(map[string]interface{})), } + + if enabled := d.Get("public_network_access_enabled").(bool); !enabled { + parameters.DicomServiceProperties.PublicNetworkAccess = healthcareapis.PublicNetworkAccessDisabled + } + future, err := client.CreateOrUpdate(ctx, id.ResourceGroup, id.WorkspaceName, id.Name, parameters) if err != nil { return fmt.Errorf("updating %s: %+v", id, err) diff --git a/website/docs/r/healthcare_dicom.html.markdown b/website/docs/r/healthcare_dicom.html.markdown index 3baeed94afd1..f5e716ccfd63 100644 --- a/website/docs/r/healthcare_dicom.html.markdown +++ b/website/docs/r/healthcare_dicom.html.markdown @@ -46,6 +46,8 @@ The following arguments are supported: * `identity` - (Optional) An `identity` block as defined below. +* `public_network_access_enabled` - (Optional) Whether to enabled public networks when data plane traffic coming from public networks while private endpoint is enabled. + --- An `identity` block supports the following: From 0269d550b5935ec5079f294cdf25952f7f917a95 Mon Sep 17 00:00:00 2001 From: xiaxin18 Date: Fri, 18 Mar 2022 23:34:57 +0800 Subject: [PATCH 10/22] update --- .../healthcare/healthcare_dicom_data_source.go | 1 - .../healthcare/healthcare_dicom_resource.go | 17 ++++++++--------- vendor/modules.txt | 4 ---- website/docs/d/healthcare_dicom.html.markdown | 4 ++-- 4 files changed, 10 insertions(+), 16 deletions(-) diff --git a/internal/services/healthcare/healthcare_dicom_data_source.go b/internal/services/healthcare/healthcare_dicom_data_source.go index 41125cff5b6b..77be44d93cdb 100644 --- a/internal/services/healthcare/healthcare_dicom_data_source.go +++ b/internal/services/healthcare/healthcare_dicom_data_source.go @@ -33,7 +33,6 @@ func dataSourceHealthcareDicomService() *pluginsdk.Resource { "workspace_id": { Type: pluginsdk.TypeString, Required: true, - ForceNew: true, ValidateFunc: validate.WorkspaceID, }, diff --git a/internal/services/healthcare/healthcare_dicom_resource.go b/internal/services/healthcare/healthcare_dicom_resource.go index b69613028040..8696fef52795 100644 --- a/internal/services/healthcare/healthcare_dicom_resource.go +++ b/internal/services/healthcare/healthcare_dicom_resource.go @@ -98,10 +98,10 @@ func resourceHealthcareApisDicomService() *pluginsdk.Resource { Computed: true, }, - "public_network_access_enabled" :{ - Type: pluginsdk.TypeBool, + "public_network_access_enabled": { + Type: pluginsdk.TypeBool, Optional: true, - Default: true, + Default: true, }, "tags": commonschema.Tags(), @@ -144,8 +144,8 @@ func resourceHealthcareApisDicomServiceCreate(d *pluginsdk.ResourceData, meta in parameters := healthcareapis.DicomService{ Identity: identity, - DicomServiceProperties:&healthcareapis.DicomServiceProperties{ - PublicNetworkAccess:healthcareapis.PublicNetworkAccessEnabled, + DicomServiceProperties: &healthcareapis.DicomServiceProperties{ + PublicNetworkAccess: healthcareapis.PublicNetworkAccessEnabled, }, Location: utils.String(location.Normalize(d.Get("location").(string))), Tags: tags.Expand(t), @@ -205,7 +205,6 @@ func resourceHealthcareApisDicomServiceRead(d *pluginsdk.ResourceData, meta inte } } - identity, _ := flattenDicomManagedIdentity(resp.Identity) if err := d.Set("identity", identity); err != nil { return fmt.Errorf("setting `identity`: %+v", err) @@ -233,12 +232,12 @@ func resourceHealthcareApisDicomServiceUpdate(d *pluginsdk.ResourceData, meta in } parameters := healthcareapis.DicomService{ - Location: utils.String(location.Normalize(d.Get("location").(string))), - Identity: expandedIdentity, + Location: utils.String(location.Normalize(d.Get("location").(string))), + Identity: expandedIdentity, DicomServiceProperties: &healthcareapis.DicomServiceProperties{ PublicNetworkAccess: healthcareapis.PublicNetworkAccessEnabled, }, - Tags: tags.Expand(d.Get("tags").(map[string]interface{})), + Tags: tags.Expand(d.Get("tags").(map[string]interface{})), } if enabled := d.Get("public_network_access_enabled").(bool); !enabled { diff --git a/vendor/modules.txt b/vendor/modules.txt index 80655fd1d29b..2545bb15973d 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -35,10 +35,6 @@ github.com/Azure/azure-sdk-for-go/services/graphrbac/1.6/graphrbac github.com/Azure/azure-sdk-for-go/services/guestconfiguration/mgmt/2020-06-25/guestconfiguration github.com/Azure/azure-sdk-for-go/services/hdinsight/mgmt/2018-06-01/hdinsight github.com/Azure/azure-sdk-for-go/services/healthbot/mgmt/2020-12-08/healthbot -<<<<<<< HEAD -github.com/Azure/azure-sdk-for-go/services/healthcareapis/mgmt/2020-03-30/healthcareapis -======= ->>>>>>> upstream/main github.com/Azure/azure-sdk-for-go/services/healthcareapis/mgmt/2021-11-01/healthcareapis github.com/Azure/azure-sdk-for-go/services/iotcentral/mgmt/2018-09-01/iotcentral github.com/Azure/azure-sdk-for-go/services/iothub/mgmt/2021-07-02/devices diff --git a/website/docs/d/healthcare_dicom.html.markdown b/website/docs/d/healthcare_dicom.html.markdown index e40f9a567f96..16a4757feba3 100644 --- a/website/docs/d/healthcare_dicom.html.markdown +++ b/website/docs/d/healthcare_dicom.html.markdown @@ -14,7 +14,7 @@ Use this data source to access information about an existing Healthcare Dicom Se ```hcl data "azurerm_healthcare_dicom_service" "example" { - name = "example-healthcare_dicom_service" + name = "example-healthcare_dicom_service" workspace_id = "example_healthcare_workspace" } @@ -33,7 +33,7 @@ output "azurerm_healthcare_dicom_service" { The following attributes are exported: -* `id` - The ID of the Healthcare Workspace. +* `id` - The ID of the Healthcare Dicom Service. * `location` - The Azure Region where the Healthcare Dicom Service is located. From 48c740ebc1b06b8eeba20b7fc12704b9fba4e442 Mon Sep 17 00:00:00 2001 From: xiaxin18 Date: Sat, 19 Mar 2022 08:41:40 +0800 Subject: [PATCH 11/22] sort import --- internal/services/healthcare/healthcare_dicom_data_source.go | 2 +- internal/services/healthcare/healthcare_dicom_resource.go | 2 +- .../recoveryservices/recovery_services_vault_resource.go | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/internal/services/healthcare/healthcare_dicom_data_source.go b/internal/services/healthcare/healthcare_dicom_data_source.go index 77be44d93cdb..b16bb7683b82 100644 --- a/internal/services/healthcare/healthcare_dicom_data_source.go +++ b/internal/services/healthcare/healthcare_dicom_data_source.go @@ -2,10 +2,10 @@ package healthcare import ( "fmt" - "github.com/hashicorp/go-azure-helpers/resourcemanager/location" "time" "github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema" + "github.com/hashicorp/go-azure-helpers/resourcemanager/location" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" "github.com/hashicorp/terraform-provider-azurerm/internal/services/healthcare/parse" "github.com/hashicorp/terraform-provider-azurerm/internal/services/healthcare/validate" diff --git a/internal/services/healthcare/healthcare_dicom_resource.go b/internal/services/healthcare/healthcare_dicom_resource.go index 8696fef52795..d5ace4f5888a 100644 --- a/internal/services/healthcare/healthcare_dicom_resource.go +++ b/internal/services/healthcare/healthcare_dicom_resource.go @@ -126,7 +126,7 @@ func resourceHealthcareApisDicomServiceCreate(d *pluginsdk.ResourceData, meta in existing, err := client.Get(ctx, dicomServiceId.ResourceGroup, dicomServiceId.WorkspaceName, dicomServiceId.Name) if err != nil { if !utils.ResponseWasNotFound(existing.Response) { - return fmt.Errorf("checking for presense of existing %s: %+v", dicomServiceId, err) + return fmt.Errorf("checking for presence of existing %s: %+v", dicomServiceId, err) } } diff --git a/internal/services/recoveryservices/recovery_services_vault_resource.go b/internal/services/recoveryservices/recovery_services_vault_resource.go index 47490a0009b5..f861caf44c88 100644 --- a/internal/services/recoveryservices/recovery_services_vault_resource.go +++ b/internal/services/recoveryservices/recovery_services_vault_resource.go @@ -352,7 +352,7 @@ func resourceRecoveryServicesVaultRead(d *pluginsdk.ResourceData, meta interface if props := storageCfg.Properties; props != nil { d.Set("storage_mode_type", string(props.StorageModelType)) - d.Set("cross_region_restore_enabled", *props.CrossRegionRestoreFlag) + d.Set("cross_region_restore_enabled", props.CrossRegionRestoreFlag) } if err := d.Set("identity", flattenVaultIdentity(resp.Identity)); err != nil { From 2a94b9cc45e7975f0fc08dba54e60a7ac745cd1d Mon Sep 17 00:00:00 2001 From: xiaxin18 Date: Sat, 19 Mar 2022 09:00:31 +0800 Subject: [PATCH 12/22] fmt --- .../services/healthcare/healthcare_dicom_data_source_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/services/healthcare/healthcare_dicom_data_source_test.go b/internal/services/healthcare/healthcare_dicom_data_source_test.go index 854fa0f0be89..664a98cafc35 100644 --- a/internal/services/healthcare/healthcare_dicom_data_source_test.go +++ b/internal/services/healthcare/healthcare_dicom_data_source_test.go @@ -28,8 +28,8 @@ func (r HealthCareDicomServiceDataSource) basic(data acceptance.TestData) string %s data "azurerm_healthcare_dicom_service" "test" { - name = azurerm_healthcare_dicom_service.test.name - workspace_id = azurerm_healthcare_dicom_service.test.workspace_id + name = azurerm_healthcare_dicom_service.test.name + workspace_id = azurerm_healthcare_dicom_service.test.workspace_id } `, HealthCareDicomResource{}.complete(data)) } From 21cfb99d64c677cacdbea71403b911bf1cf473a5 Mon Sep 17 00:00:00 2001 From: xiaxin18 Date: Sun, 20 Mar 2022 22:01:23 +0800 Subject: [PATCH 13/22] update --- .../healthcare_dicom_data_source.go | 2 + .../healthcare/healthcare_dicom_resource.go | 62 ++++++++++++++----- .../healthcare_dicom_resource_test.go | 6 +- 3 files changed, 53 insertions(+), 17 deletions(-) diff --git a/internal/services/healthcare/healthcare_dicom_data_source.go b/internal/services/healthcare/healthcare_dicom_data_source.go index b16bb7683b82..a8a4e750b1cf 100644 --- a/internal/services/healthcare/healthcare_dicom_data_source.go +++ b/internal/services/healthcare/healthcare_dicom_data_source.go @@ -38,6 +38,8 @@ func dataSourceHealthcareDicomService() *pluginsdk.Resource { "location": commonschema.LocationComputed(), + "identity": commonschema.SystemAssignedUserAssignedIdentityComputed(), + "authentication_configuration": { Type: pluginsdk.TypeList, Computed: true, diff --git a/internal/services/healthcare/healthcare_dicom_resource.go b/internal/services/healthcare/healthcare_dicom_resource.go index d5ace4f5888a..66d19856f38c 100644 --- a/internal/services/healthcare/healthcare_dicom_resource.go +++ b/internal/services/healthcare/healthcare_dicom_resource.go @@ -67,7 +67,7 @@ func resourceHealthcareApisDicomService() *pluginsdk.Resource { Computed: true, }, "audience": { - Type: pluginsdk.TypeSet, + Type: pluginsdk.TypeList, Computed: true, Elem: &pluginsdk.Schema{Type: pluginsdk.TypeString}, }, @@ -233,17 +233,22 @@ func resourceHealthcareApisDicomServiceUpdate(d *pluginsdk.ResourceData, meta in parameters := healthcareapis.DicomService{ Location: utils.String(location.Normalize(d.Get("location").(string))), - Identity: expandedIdentity, DicomServiceProperties: &healthcareapis.DicomServiceProperties{ PublicNetworkAccess: healthcareapis.PublicNetworkAccessEnabled, }, - Tags: tags.Expand(d.Get("tags").(map[string]interface{})), + Identity: expandedIdentity, } if enabled := d.Get("public_network_access_enabled").(bool); !enabled { parameters.DicomServiceProperties.PublicNetworkAccess = healthcareapis.PublicNetworkAccessDisabled } + if d.HasChange("tags") { + if err := updateTags(d, meta); err != nil { + return fmt.Errorf("updating tags error: %+v", err) + } + } + future, err := client.CreateOrUpdate(ctx, id.ResourceGroup, id.WorkspaceName, id.Name, parameters) if err != nil { return fmt.Errorf("updating %s: %+v", id, err) @@ -279,6 +284,32 @@ func resourceHealthcareApisDicomServiceDelete(d *pluginsdk.ResourceData, meta in return nil } +func updateTags(d *pluginsdk.ResourceData, meta interface{}) error { + client := meta.(*clients.Client).HealthCare.HealthcareWorkspaceDicomServiceClient + ctx, cancel := timeouts.ForUpdate(meta.(*clients.Client).StopContext, d) + defer cancel() + + id, err := parse.DicomServiceID(d.Id()) + if err != nil { + return err + } + + update := healthcareapis.DicomServicePatchResource{ + Tags: tags.Expand(d.Get("tags").(map[string]interface{})), + } + + future, err := client.Update(ctx, id.ResourceGroup, id.Name, id.WorkspaceName, update) + if err != nil { + return fmt.Errorf("updating %s: %+v", id, err) + } + + if err = future.WaitForCompletionRef(ctx, client.Client); err != nil { + return fmt.Errorf("waiting for update %s: %+v", id, err) + } + + return nil +} + func flattenDicomAuthentication(input *healthcareapis.DicomServiceAuthenticationConfiguration) []interface{} { if input == nil { return []interface{}{} @@ -295,7 +326,7 @@ func flattenDicomAuthentication(input *healthcareapis.DicomServiceAuthentication audience = append(audience, data) } } - authBlock["audience"] = pluginsdk.NewSet(pluginsdk.HashString, audience) + authBlock["audience"] = audience return []interface{}{authBlock} } @@ -341,29 +372,28 @@ func expandDicomManagedIdentity(input []interface{}) (*healthcareapis.ServiceMan } func flattenDicomManagedIdentity(input *healthcareapis.ServiceManagedIdentityIdentity) (*[]interface{}, error) { - var transform *identity.SystemAndUserAssignedMap + var config *identity.SystemAndUserAssignedList if input != nil { - transform = &identity.SystemAndUserAssignedMap{ - Type: identity.Type(string(input.Type)), - IdentityIds: make(map[string]identity.UserAssignedIdentityDetails), + config = &identity.SystemAndUserAssignedList{ + Type: identity.Type(string(input.Type)), } + if input.PrincipalID != nil { id := *input.PrincipalID - transform.PrincipalId = id.String() + config.PrincipalId = id.String() } if input.TenantID != nil { tenantID := *input.TenantID - transform.TenantId = tenantID.String() + config.TenantId = tenantID.String() } - for k, v := range input.UserAssignedIdentities { - transform.IdentityIds[k] = identity.UserAssignedIdentityDetails{ - ClientId: utils.String(v.ClientID.String()), - PrincipalId: utils.String(v.PrincipalID.String()), - } + userAssignedIdentityIds := make([]string, 0) + for k := range input.UserAssignedIdentities { + userAssignedIdentityIds = append(userAssignedIdentityIds, k) } + config.IdentityIds = userAssignedIdentityIds } - return identity.FlattenSystemAndUserAssignedMap(transform) + return identity.FlattenSystemAndUserAssignedList(config) } diff --git a/internal/services/healthcare/healthcare_dicom_resource_test.go b/internal/services/healthcare/healthcare_dicom_resource_test.go index e35292a34813..327bfecf9074 100644 --- a/internal/services/healthcare/healthcare_dicom_resource_test.go +++ b/internal/services/healthcare/healthcare_dicom_resource_test.go @@ -63,7 +63,7 @@ func TestAccHealthCareDicom_update(t *testing.T) { }) } -func TestAccHealthCareDicom_userAssignedIdentity(t *testing.T) { +func TestAccHealthCareDicom_updateUserAssignedIdentity(t *testing.T) { data := acceptance.BuildTestData(t, "azurerm_healthcare_dicom_service", "test") r := HealthCareDicomResource{} @@ -119,6 +119,7 @@ resource "azurerm_healthcare_dicom_service" "test" { name = "acctest-dicom%d" workspace_id = azurerm_healthcare_workspace.test.id location = "east us" + depends_on = [azurerm_healthcare_workspace.test] } `, r.template(data), data.RandomIntOfLength(8)) } @@ -139,6 +140,7 @@ resource "azurerm_healthcare_dicom_service" "test" { tags = { environment = "None" } + depends_on = [azurerm_healthcare_workspace.test] } `, r.template(data), data.RandomIntOfLength(8)) } @@ -155,6 +157,7 @@ resource "azurerm_healthcare_dicom_service" "test" { tags = { environment = "Prod" } + depends_on = [azurerm_healthcare_workspace.test] } `, r.template(data), data.RandomIntOfLength(8)) } @@ -182,6 +185,7 @@ resource "azurerm_healthcare_dicom_service" "test" { tags = { environment = "None" } + depends_on = [azurerm_healthcare_workspace.test] } `, r.template(data), data.RandomInteger, data.RandomIntOfLength(8)) } From ca7991ebd43a79ed1f305fda8e7376130d40c701 Mon Sep 17 00:00:00 2001 From: xiaxin18 Date: Mon, 21 Mar 2022 10:56:05 +0800 Subject: [PATCH 14/22] update --- .../healthcare_dicom_data_source.go | 8 +-- .../healthcare_dicom_data_source_test.go | 2 +- .../healthcare/healthcare_dicom_resource.go | 53 ++++++++++++++++--- .../healthcare_dicom_resource_test.go | 28 +++++----- 4 files changed, 66 insertions(+), 25 deletions(-) diff --git a/internal/services/healthcare/healthcare_dicom_data_source.go b/internal/services/healthcare/healthcare_dicom_data_source.go index a8a4e750b1cf..2d082935892f 100644 --- a/internal/services/healthcare/healthcare_dicom_data_source.go +++ b/internal/services/healthcare/healthcare_dicom_data_source.go @@ -40,7 +40,7 @@ func dataSourceHealthcareDicomService() *pluginsdk.Resource { "identity": commonschema.SystemAssignedUserAssignedIdentityComputed(), - "authentication_configuration": { + "authentication": { Type: pluginsdk.TypeList, Computed: true, Elem: &pluginsdk.Resource{ @@ -58,7 +58,7 @@ func dataSourceHealthcareDicomService() *pluginsdk.Resource { }, }, - "private_endpoint_connection": { + "private_endpoint": { Type: pluginsdk.TypeList, Computed: true, Elem: &pluginsdk.Resource{ @@ -117,8 +117,8 @@ func dataSourceHealthcareApisDicomServiceRead(d *pluginsdk.ResourceData, meta in } if props := resp.DicomServiceProperties; props != nil { - d.Set("authentication_configuration", flattenDicomAuthentication(props.AuthenticationConfiguration)) - d.Set("private_endpoint_connection", flattenDicomServicePrivateEndpoint(props.PrivateEndpointConnections)) + d.Set("authentication", flattenDicomAuthentication(props.AuthenticationConfiguration)) + d.Set("private_endpoint", flattenDicomServicePrivateEndpoint(props.PrivateEndpointConnections)) d.Set("service_url", props.ServiceURL) } diff --git a/internal/services/healthcare/healthcare_dicom_data_source_test.go b/internal/services/healthcare/healthcare_dicom_data_source_test.go index 664a98cafc35..1e1fdbbf78ab 100644 --- a/internal/services/healthcare/healthcare_dicom_data_source_test.go +++ b/internal/services/healthcare/healthcare_dicom_data_source_test.go @@ -31,5 +31,5 @@ data "azurerm_healthcare_dicom_service" "test" { name = azurerm_healthcare_dicom_service.test.name workspace_id = azurerm_healthcare_dicom_service.test.workspace_id } -`, HealthCareDicomResource{}.complete(data)) +`, HealthCareDicomResource{}.basic(data)) } diff --git a/internal/services/healthcare/healthcare_dicom_resource.go b/internal/services/healthcare/healthcare_dicom_resource.go index 66d19856f38c..68593abbc9b1 100644 --- a/internal/services/healthcare/healthcare_dicom_resource.go +++ b/internal/services/healthcare/healthcare_dicom_resource.go @@ -1,8 +1,11 @@ package healthcare import ( + "context" "fmt" + "github.com/hashicorp/go-azure-helpers/lang/response" "log" + "strconv" "time" "github.com/Azure/azure-sdk-for-go/services/healthcareapis/mgmt/2021-11-01/healthcareapis" @@ -57,7 +60,7 @@ func resourceHealthcareApisDicomService() *pluginsdk.Resource { "identity": commonschema.SystemAssignedUserAssignedIdentityOptional(), - "authentication_configuration": { + "authentication": { Type: pluginsdk.TypeList, Computed: true, Elem: &pluginsdk.Resource{ @@ -75,7 +78,7 @@ func resourceHealthcareApisDicomService() *pluginsdk.Resource { }, }, - "private_endpoint_connection": { + "private_endpoint": { Type: pluginsdk.TypeSet, Computed: true, Elem: &pluginsdk.Resource{ @@ -196,8 +199,8 @@ func resourceHealthcareApisDicomServiceRead(d *pluginsdk.ResourceData, meta inte } if props := resp.DicomServiceProperties; props != nil { - d.Set("authentication_configuration", flattenDicomAuthentication(props.AuthenticationConfiguration)) - d.Set("private_endpoint_connection", flattenDicomServicePrivateEndpoint(props.PrivateEndpointConnections)) + d.Set("authentication", flattenDicomAuthentication(props.AuthenticationConfiguration)) + d.Set("private_endpoint", flattenDicomServicePrivateEndpoint(props.PrivateEndpointConnections)) d.Set("service_url", props.ServiceURL) if props.PublicNetworkAccess != "" { @@ -274,16 +277,54 @@ func resourceHealthcareApisDicomServiceDelete(d *pluginsdk.ResourceData, meta in future, err := client.Delete(ctx, id.ResourceGroup, id.Name, id.WorkspaceName) if err != nil { + if response.WasNotFound(future.Response()) { + return nil + } return fmt.Errorf("deleting %s: %+v", *id, err) } - if err = future.WaitForCompletionRef(ctx, client.Client); err != nil { - return fmt.Errorf("waiting for deletion of %s: %+v", *id, err) + return waitForDicomServiceToBeDeleted(ctx, client, *id) +} + +func waitForDicomServiceToBeDeleted(ctx context.Context, client *healthcareapis.DicomServicesClient, id parse.DicomServiceId) error { + deadline, ok := ctx.Deadline() + if !ok { + return fmt.Errorf("context has no deadline") + } + + log.Printf("[DEBUG] Waiting for %s to be deleted..", id) + stateConf := &pluginsdk.StateChangeConf{ + Pending: []string{"200"}, + Target: []string{"404"}, + Refresh: dicomServiceStateStatusCodeRefreshFunc(ctx, client, id), + Timeout: time.Until(deadline), + } + + if _, err := stateConf.WaitForStateContext(ctx); err != nil { + return fmt.Errorf("waiting for %s to be deleted: %+v", id, err) } return nil } +func dicomServiceStateStatusCodeRefreshFunc(ctx context.Context, client *healthcareapis.DicomServicesClient, id parse.DicomServiceId) pluginsdk.StateRefreshFunc { + return func() (interface{}, string, error) { + res, err := client.Get(ctx, id.ResourceGroup, id.WorkspaceName, id.Name) + if res.Response.Response != nil { + log.Printf("Retrieving %s returned Status %d", id, res.Response.StatusCode) + } + + if err != nil { + if utils.ResponseWasNotFound(res.Response) { + return res, strconv.Itoa(res.Response.StatusCode), nil + } + return nil, "", fmt.Errorf("polling for the status of %s: %+v", id, err) + } + + return res, strconv.Itoa(res.Response.StatusCode), nil + } +} + func updateTags(d *pluginsdk.ResourceData, meta interface{}) error { client := meta.(*clients.Client).HealthCare.HealthcareWorkspaceDicomServiceClient ctx, cancel := timeouts.ForUpdate(meta.(*clients.Client).StopContext, d) diff --git a/internal/services/healthcare/healthcare_dicom_resource_test.go b/internal/services/healthcare/healthcare_dicom_resource_test.go index 327bfecf9074..d591e8416219 100644 --- a/internal/services/healthcare/healthcare_dicom_resource_test.go +++ b/internal/services/healthcare/healthcare_dicom_resource_test.go @@ -15,7 +15,7 @@ import ( type HealthCareDicomResource struct{} -func TestAccHealthCareDicom_basic(t *testing.T) { +func TestAccHealthCareDicomResource_basic(t *testing.T) { data := acceptance.BuildTestData(t, "azurerm_healthcare_dicom_service", "test") r := HealthCareDicomResource{} @@ -29,7 +29,7 @@ func TestAccHealthCareDicom_basic(t *testing.T) { }) } -func TestAccHealthCareDicom_complete(t *testing.T) { +func TestAccHealthCareDicomResource_complete(t *testing.T) { data := acceptance.BuildTestData(t, "azurerm_healthcare_dicom_service", "test") r := HealthCareDicomResource{} @@ -43,7 +43,7 @@ func TestAccHealthCareDicom_complete(t *testing.T) { }) } -func TestAccHealthCareDicom_update(t *testing.T) { +func TestAccHealthCareDicomResource_update(t *testing.T) { data := acceptance.BuildTestData(t, "azurerm_healthcare_dicom_service", "test") r := HealthCareDicomResource{} @@ -63,7 +63,7 @@ func TestAccHealthCareDicom_update(t *testing.T) { }) } -func TestAccHealthCareDicom_updateUserAssignedIdentity(t *testing.T) { +func TestAccHealthCareDicomResource_updateUserAssignedIdentity(t *testing.T) { data := acceptance.BuildTestData(t, "azurerm_healthcare_dicom_service", "test") r := HealthCareDicomResource{} @@ -83,7 +83,7 @@ func TestAccHealthCareDicom_updateUserAssignedIdentity(t *testing.T) { }) } -func TestAccHealthCareDicom_requiresImport(t *testing.T) { +func TestAccHealthCareDicomResource_requiresImport(t *testing.T) { data := acceptance.BuildTestData(t, "azurerm_healthcare_dicom_service", "test") r := HealthCareDicomResource{} @@ -118,10 +118,10 @@ func (r HealthCareDicomResource) basic(data acceptance.TestData) string { resource "azurerm_healthcare_dicom_service" "test" { name = "acctest-dicom%d" workspace_id = azurerm_healthcare_workspace.test.id - location = "east us" + location = "%s" depends_on = [azurerm_healthcare_workspace.test] } -`, r.template(data), data.RandomIntOfLength(8)) +`, r.template(data), data.RandomIntOfLength(8), data.Locations.Primary) } func (r HealthCareDicomResource) complete(data acceptance.TestData) string { @@ -131,7 +131,7 @@ func (r HealthCareDicomResource) complete(data acceptance.TestData) string { resource "azurerm_healthcare_dicom_service" "test" { name = "acctest-dicom%d" workspace_id = azurerm_healthcare_workspace.test.id - location = "east us" + location = "%s" identity { type = "SystemAssigned" @@ -142,7 +142,7 @@ resource "azurerm_healthcare_dicom_service" "test" { } depends_on = [azurerm_healthcare_workspace.test] } -`, r.template(data), data.RandomIntOfLength(8)) +`, r.template(data), data.RandomIntOfLength(8), data.Locations.Primary) } func (r HealthCareDicomResource) update(data acceptance.TestData) string { @@ -152,14 +152,14 @@ func (r HealthCareDicomResource) update(data acceptance.TestData) string { resource "azurerm_healthcare_dicom_service" "test" { name = "acctest-dicom%d" workspace_id = azurerm_healthcare_workspace.test.id - location = "east us" + location = "%s" tags = { environment = "Prod" } depends_on = [azurerm_healthcare_workspace.test] } -`, r.template(data), data.RandomIntOfLength(8)) +`, r.template(data), data.RandomIntOfLength(8), data.Locations.Primary) } func (r HealthCareDicomResource) userAssignedIdentity(data acceptance.TestData) string { @@ -175,7 +175,7 @@ resource "azurerm_user_assigned_identity" "test" { resource "azurerm_healthcare_dicom_service" "test" { name = "acctest-dicom%d" workspace_id = azurerm_healthcare_workspace.test.id - location = "east us" + location = "%s" identity { type = "UserAssigned" @@ -185,9 +185,9 @@ resource "azurerm_healthcare_dicom_service" "test" { tags = { environment = "None" } - depends_on = [azurerm_healthcare_workspace.test] + depends_on = [azurerm_healthcare_workspace.test, azurerm_user_assigned_identity.test] } -`, r.template(data), data.RandomInteger, data.RandomIntOfLength(8)) +`, r.template(data), data.RandomInteger, data.RandomIntOfLength(8), data.Locations.Primary) } func (r HealthCareDicomResource) requiresImport(data acceptance.TestData) string { From 2522eb3495de6e25c84e8e21dab654ec4b3f218b Mon Sep 17 00:00:00 2001 From: xiaxin18 Date: Mon, 21 Mar 2022 11:24:46 +0800 Subject: [PATCH 15/22] sort --- internal/services/healthcare/healthcare_dicom_resource.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/services/healthcare/healthcare_dicom_resource.go b/internal/services/healthcare/healthcare_dicom_resource.go index 68593abbc9b1..ebb307b07866 100644 --- a/internal/services/healthcare/healthcare_dicom_resource.go +++ b/internal/services/healthcare/healthcare_dicom_resource.go @@ -3,12 +3,12 @@ package healthcare import ( "context" "fmt" - "github.com/hashicorp/go-azure-helpers/lang/response" "log" "strconv" "time" "github.com/Azure/azure-sdk-for-go/services/healthcareapis/mgmt/2021-11-01/healthcareapis" + "github.com/hashicorp/go-azure-helpers/lang/response" "github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema" "github.com/hashicorp/go-azure-helpers/resourcemanager/identity" "github.com/hashicorp/go-azure-helpers/resourcemanager/location" From f712ca16e1c32cd17de46c20c34bcb7fa0e578b0 Mon Sep 17 00:00:00 2001 From: xiaxin18 Date: Mon, 21 Mar 2022 19:05:52 +0800 Subject: [PATCH 16/22] update --- .../healthcare/healthcare_dicom_resource.go | 38 +- .../healthcare_dicom_resource_test.go | 10 +- .../sdk/2021-01-11/collection/client.go | 15 - .../sdk/2021-01-11/collection/constants.go | 210 ---------- .../method_serviceslist_autorest.go | 184 --------- ...od_serviceslistbyresourcegroup_autorest.go | 184 --------- .../collection/model_privateendpoint.go | 5 - .../model_privateendpointconnection.go | 8 - ...del_privateendpointconnectionproperties.go | 7 - ...model_privatelinkserviceconnectionstate.go | 7 - .../model_serviceaccesspolicyentry.go | 5 - .../model_serviceacrconfigurationinfo.go | 5 - ..._serviceauthenticationconfigurationinfo.go | 7 - .../model_servicecorsconfigurationinfo.go | 9 - .../model_servicecosmosdbconfigurationinfo.go | 6 - .../model_serviceexportconfigurationinfo.go | 5 - .../collection/model_servicesdescription.go | 18 - .../collection/model_servicesproperties.go | 13 - .../2021-01-11/collection/model_systemdata.go | 40 -- .../sdk/2021-01-11/collection/predicates.go | 34 -- .../sdk/2021-01-11/collection/version.go | 9 - .../privateendpointconnections/client.go | 15 - .../privateendpointconnections/constants.go | 102 ----- .../id_privateendpointconnection.go | 137 ------- .../id_privateendpointconnection_test.go | 324 --------------- .../privateendpointconnections/id_service.go | 124 ------ .../id_service_test.go | 279 ------------- .../method_createorupdate_autorest.go | 75 ---- .../method_delete_autorest.go | 74 ---- .../method_get_autorest.go | 64 --- .../method_listbyservice_autorest.go | 65 --- .../model_privateendpoint.go | 5 - .../model_privateendpointconnection.go | 8 - ...el_privateendpointconnectiondescription.go | 9 - ...endpointconnectionlistresultdescription.go | 5 - ...del_privateendpointconnectionproperties.go | 7 - ...model_privatelinkserviceconnectionstate.go | 7 - .../model_systemdata.go | 40 -- .../privateendpointconnections/version.go | 9 - .../2021-01-11/privatelinkresources/client.go | 15 - .../privatelinkresources/constants.go | 37 -- .../id_privatelinkresource.go | 137 ------- .../id_privatelinkresource_test.go | 324 --------------- .../privatelinkresources/id_service.go | 124 ------ .../privatelinkresources/id_service_test.go | 279 ------------- .../method_get_autorest.go | 64 --- .../method_listbyservice_autorest.go | 65 --- .../model_privatelinkresourcedescription.go | 9 - ...rivatelinkresourcelistresultdescription.go | 5 - .../model_privatelinkresourceproperties.go | 7 - .../privatelinkresources/model_systemdata.go | 40 -- .../privatelinkresources/version.go | 9 - .../healthcare/sdk/2021-01-11/proxy/client.go | 15 - .../sdk/2021-01-11/proxy/constants.go | 31 -- ..._serviceschecknameavailability_autorest.go | 67 ---- .../model_checknameavailabilityparameters.go | 6 - .../model_servicesnameavailabilityinfo.go | 7 - .../sdk/2021-01-11/proxy/version.go | 9 - .../sdk/2021-01-11/resource/client.go | 15 - .../sdk/2021-01-11/resource/constants.go | 210 ---------- .../sdk/2021-01-11/resource/id_service.go | 124 ------ .../2021-01-11/resource/id_service_test.go | 279 ------------- .../method_servicescreateorupdate_autorest.go | 75 ---- .../method_servicesdelete_autorest.go | 74 ---- .../resource/method_servicesget_autorest.go | 64 --- .../method_servicesupdate_autorest.go | 75 ---- .../resource/model_privateendpoint.go | 5 - .../model_privateendpointconnection.go | 8 - ...del_privateendpointconnectionproperties.go | 7 - ...model_privatelinkserviceconnectionstate.go | 7 - .../model_serviceaccesspolicyentry.go | 5 - .../model_serviceacrconfigurationinfo.go | 5 - ..._serviceauthenticationconfigurationinfo.go | 7 - .../model_servicecorsconfigurationinfo.go | 9 - .../model_servicecosmosdbconfigurationinfo.go | 6 - .../model_serviceexportconfigurationinfo.go | 5 - .../resource/model_servicesdescription.go | 18 - .../model_servicespatchdescription.go | 6 - .../resource/model_servicesproperties.go | 13 - ...odel_servicespropertiesupdateparameters.go | 5 - .../2021-01-11/resource/model_systemdata.go | 40 -- .../sdk/2021-01-11/resource/version.go | 9 - .../2021-06-01-preview/collection/client.go | 15 - .../collection/constants.go | 210 ---------- .../method_serviceslist_autorest.go | 184 --------- ...od_serviceslistbyresourcegroup_autorest.go | 184 --------- .../collection/model_privateendpoint.go | 5 - .../model_privateendpointconnection.go | 8 - ...del_privateendpointconnectionproperties.go | 7 - ...model_privatelinkserviceconnectionstate.go | 7 - .../model_serviceaccesspolicyentry.go | 5 - .../model_serviceacrconfigurationinfo.go | 5 - ..._serviceauthenticationconfigurationinfo.go | 7 - .../model_servicecorsconfigurationinfo.go | 9 - .../model_servicecosmosdbconfigurationinfo.go | 6 - .../model_serviceexportconfigurationinfo.go | 5 - .../collection/model_servicesdescription.go | 18 - .../collection/model_servicesproperties.go | 13 - .../collection/model_systemdata.go | 40 -- .../collection/predicates.go | 34 -- .../2021-06-01-preview/collection/version.go | 9 - .../dicomservices/client.go | 15 - .../dicomservices/constants.go | 98 ----- .../dicomservices/id_dicomservice.go | 137 ------- .../dicomservices/id_dicomservice_test.go | 324 --------------- .../dicomservices/id_workspace.go | 124 ------ .../dicomservices/id_workspace_test.go | 279 ------------- .../method_createorupdate_autorest.go | 75 ---- .../dicomservices/method_delete_autorest.go | 74 ---- .../dicomservices/method_get_autorest.go | 64 --- .../method_listbyworkspace_autorest.go | 183 --------- .../dicomservices/method_update_autorest.go | 75 ---- .../dicomservices/model_dicomservice.go | 12 - ...dicomserviceauthenticationconfiguration.go | 6 - .../model_dicomserviceproperties.go | 7 - .../dicomservices/model_resourcetags.go | 5 - .../dicomservices/model_systemdata.go | 40 -- .../dicomservices/predicates.go | 34 -- .../dicomservices/version.go | 9 - .../2021-06-01-preview/fhirservices/client.go | 15 - .../fhirservices/constants.go | 154 -------- .../fhirservices/id_fhirservice.go | 137 ------- .../fhirservices/id_fhirservice_test.go | 324 --------------- .../fhirservices/id_workspace.go | 124 ------ .../fhirservices/id_workspace_test.go | 279 ------------- .../method_createorupdate_autorest.go | 75 ---- .../fhirservices/method_delete_autorest.go | 74 ---- .../fhirservices/method_get_autorest.go | 64 --- .../method_listbyworkspace_autorest.go | 183 --------- .../fhirservices/method_update_autorest.go | 75 ---- .../fhirservices/model_fhirservice.go | 14 - .../model_fhirserviceaccesspolicyentry.go | 5 - .../model_fhirserviceacrconfiguration.go | 5 - ..._fhirserviceauthenticationconfiguration.go | 7 - .../model_fhirservicecorsconfiguration.go | 9 - .../model_fhirserviceexportconfiguration.go | 5 - .../model_fhirservicepatchresource.go | 6 - .../model_fhirserviceproperties.go | 10 - .../model_servicemanagedidentityidentity.go | 5 - .../fhirservices/model_systemdata.go | 40 -- .../fhirservices/predicates.go | 34 -- .../fhirservices/version.go | 9 - .../iotconnectors/client.go | 15 - .../iotconnectors/constants.go | 154 -------- .../iotconnectors/id_fhirdestination.go | 150 ------- .../iotconnectors/id_fhirdestination_test.go | 369 ------------------ .../iotconnectors/id_iotconnector.go | 137 ------- .../iotconnectors/id_iotconnector_test.go | 324 --------------- .../iotconnectors/id_workspace.go | 124 ------ .../iotconnectors/id_workspace_test.go | 279 ------------- .../method_createorupdate_autorest.go | 75 ---- .../iotconnectors/method_delete_autorest.go | 74 ---- ...destinationslistbyiotconnector_autorest.go | 183 --------- .../iotconnectors/method_get_autorest.go | 64 --- ...rfhirdestinationcreateorupdate_autorest.go | 75 ---- ...connectorfhirdestinationdelete_autorest.go | 74 ---- ...iotconnectorfhirdestinationget_autorest.go | 64 --- .../method_listbyworkspace_autorest.go | 183 --------- .../iotconnectors/method_update_autorest.go | 75 ---- .../iotconnectors/model_iotconnector.go | 13 - .../model_iotconnectorpatchresource.go | 6 - .../model_iotconnectorproperties.go | 7 - ...teventhubingestionendpointconfiguration.go | 7 - .../iotconnectors/model_iotfhirdestination.go | 11 - .../model_iotfhirdestinationproperties.go | 8 - .../model_iotmappingproperties.go | 5 - .../model_servicemanagedidentityidentity.go | 5 - .../iotconnectors/model_systemdata.go | 40 -- .../iotconnectors/predicates.go | 67 ---- .../iotconnectors/version.go | 9 - .../privateendpointconnections/client.go | 15 - .../privateendpointconnections/constants.go | 102 ----- .../id_privateendpointconnection.go | 137 ------- .../id_privateendpointconnection_test.go | 324 --------------- .../privateendpointconnections/id_service.go | 124 ------ .../id_service_test.go | 279 ------------- .../method_createorupdate_autorest.go | 75 ---- .../method_delete_autorest.go | 74 ---- .../method_get_autorest.go | 64 --- .../method_listbyservice_autorest.go | 65 --- .../model_privateendpoint.go | 5 - .../model_privateendpointconnection.go | 8 - ...el_privateendpointconnectiondescription.go | 9 - ...endpointconnectionlistresultdescription.go | 5 - ...del_privateendpointconnectionproperties.go | 7 - ...model_privatelinkserviceconnectionstate.go | 7 - .../model_systemdata.go | 40 -- .../privateendpointconnections/version.go | 9 - .../privatelinkresources/client.go | 15 - .../privatelinkresources/constants.go | 37 -- .../id_privatelinkresource.go | 137 ------- .../id_privatelinkresource_test.go | 324 --------------- .../privatelinkresources/id_service.go | 124 ------ .../privatelinkresources/id_service_test.go | 279 ------------- .../method_get_autorest.go | 64 --- .../method_listbyservice_autorest.go | 65 --- .../model_privatelinkresourcedescription.go | 9 - ...rivatelinkresourcelistresultdescription.go | 5 - .../model_privatelinkresourceproperties.go | 7 - .../privatelinkresources/model_systemdata.go | 40 -- .../privatelinkresources/version.go | 9 - .../sdk/2021-06-01-preview/proxy/client.go | 15 - .../sdk/2021-06-01-preview/proxy/constants.go | 31 -- ..._serviceschecknameavailability_autorest.go | 67 ---- .../model_checknameavailabilityparameters.go | 6 - .../model_servicesnameavailabilityinfo.go | 7 - .../sdk/2021-06-01-preview/proxy/version.go | 9 - .../sdk/2021-06-01-preview/resource/client.go | 15 - .../2021-06-01-preview/resource/constants.go | 210 ---------- .../2021-06-01-preview/resource/id_service.go | 124 ------ .../resource/id_service_test.go | 279 ------------- .../method_servicescreateorupdate_autorest.go | 75 ---- .../method_servicesdelete_autorest.go | 74 ---- .../resource/method_servicesget_autorest.go | 64 --- .../method_servicesupdate_autorest.go | 75 ---- .../resource/model_privateendpoint.go | 5 - .../model_privateendpointconnection.go | 8 - ...del_privateendpointconnectionproperties.go | 7 - ...model_privatelinkserviceconnectionstate.go | 7 - .../model_serviceaccesspolicyentry.go | 5 - .../model_serviceacrconfigurationinfo.go | 5 - ..._serviceauthenticationconfigurationinfo.go | 7 - .../model_servicecorsconfigurationinfo.go | 9 - .../model_servicecosmosdbconfigurationinfo.go | 6 - .../model_serviceexportconfigurationinfo.go | 5 - .../resource/model_servicesdescription.go | 18 - .../model_servicespatchdescription.go | 6 - .../resource/model_servicesproperties.go | 13 - ...odel_servicespropertiesupdateparameters.go | 5 - .../resource/model_systemdata.go | 40 -- .../2021-06-01-preview/resource/version.go | 9 - .../2021-06-01-preview/workspaces/client.go | 15 - .../workspaces/constants.go | 98 ----- .../workspaces/id_workspace.go | 124 ------ .../workspaces/id_workspace_test.go | 279 ------------- .../method_createorupdate_autorest.go | 75 ---- .../workspaces/method_delete_autorest.go | 74 ---- .../workspaces/method_get_autorest.go | 64 --- .../method_listbyresourcegroup_autorest.go | 184 --------- .../method_listbysubscription_autorest.go | 184 --------- .../workspaces/method_update_autorest.go | 75 ---- .../workspaces/model_resourcetags.go | 5 - .../workspaces/model_systemdata.go | 40 -- .../workspaces/model_workspace.go | 12 - .../workspaces/model_workspaceproperties.go | 5 - .../workspaces/predicates.go | 34 -- .../2021-06-01-preview/workspaces/version.go | 9 - 247 files changed, 17 insertions(+), 16001 deletions(-) delete mode 100644 internal/services/healthcare/sdk/2021-01-11/collection/client.go delete mode 100644 internal/services/healthcare/sdk/2021-01-11/collection/constants.go delete mode 100644 internal/services/healthcare/sdk/2021-01-11/collection/method_serviceslist_autorest.go delete mode 100644 internal/services/healthcare/sdk/2021-01-11/collection/method_serviceslistbyresourcegroup_autorest.go delete mode 100644 internal/services/healthcare/sdk/2021-01-11/collection/model_privateendpoint.go delete mode 100644 internal/services/healthcare/sdk/2021-01-11/collection/model_privateendpointconnection.go delete mode 100644 internal/services/healthcare/sdk/2021-01-11/collection/model_privateendpointconnectionproperties.go delete mode 100644 internal/services/healthcare/sdk/2021-01-11/collection/model_privatelinkserviceconnectionstate.go delete mode 100644 internal/services/healthcare/sdk/2021-01-11/collection/model_serviceaccesspolicyentry.go delete mode 100644 internal/services/healthcare/sdk/2021-01-11/collection/model_serviceacrconfigurationinfo.go delete mode 100644 internal/services/healthcare/sdk/2021-01-11/collection/model_serviceauthenticationconfigurationinfo.go delete mode 100644 internal/services/healthcare/sdk/2021-01-11/collection/model_servicecorsconfigurationinfo.go delete mode 100644 internal/services/healthcare/sdk/2021-01-11/collection/model_servicecosmosdbconfigurationinfo.go delete mode 100644 internal/services/healthcare/sdk/2021-01-11/collection/model_serviceexportconfigurationinfo.go delete mode 100644 internal/services/healthcare/sdk/2021-01-11/collection/model_servicesdescription.go delete mode 100644 internal/services/healthcare/sdk/2021-01-11/collection/model_servicesproperties.go delete mode 100644 internal/services/healthcare/sdk/2021-01-11/collection/model_systemdata.go delete mode 100644 internal/services/healthcare/sdk/2021-01-11/collection/predicates.go delete mode 100644 internal/services/healthcare/sdk/2021-01-11/collection/version.go delete mode 100644 internal/services/healthcare/sdk/2021-01-11/privateendpointconnections/client.go delete mode 100644 internal/services/healthcare/sdk/2021-01-11/privateendpointconnections/constants.go delete mode 100644 internal/services/healthcare/sdk/2021-01-11/privateendpointconnections/id_privateendpointconnection.go delete mode 100644 internal/services/healthcare/sdk/2021-01-11/privateendpointconnections/id_privateendpointconnection_test.go delete mode 100644 internal/services/healthcare/sdk/2021-01-11/privateendpointconnections/id_service.go delete mode 100644 internal/services/healthcare/sdk/2021-01-11/privateendpointconnections/id_service_test.go delete mode 100644 internal/services/healthcare/sdk/2021-01-11/privateendpointconnections/method_createorupdate_autorest.go delete mode 100644 internal/services/healthcare/sdk/2021-01-11/privateendpointconnections/method_delete_autorest.go delete mode 100644 internal/services/healthcare/sdk/2021-01-11/privateendpointconnections/method_get_autorest.go delete mode 100644 internal/services/healthcare/sdk/2021-01-11/privateendpointconnections/method_listbyservice_autorest.go delete mode 100644 internal/services/healthcare/sdk/2021-01-11/privateendpointconnections/model_privateendpoint.go delete mode 100644 internal/services/healthcare/sdk/2021-01-11/privateendpointconnections/model_privateendpointconnection.go delete mode 100644 internal/services/healthcare/sdk/2021-01-11/privateendpointconnections/model_privateendpointconnectiondescription.go delete mode 100644 internal/services/healthcare/sdk/2021-01-11/privateendpointconnections/model_privateendpointconnectionlistresultdescription.go delete mode 100644 internal/services/healthcare/sdk/2021-01-11/privateendpointconnections/model_privateendpointconnectionproperties.go delete mode 100644 internal/services/healthcare/sdk/2021-01-11/privateendpointconnections/model_privatelinkserviceconnectionstate.go delete mode 100644 internal/services/healthcare/sdk/2021-01-11/privateendpointconnections/model_systemdata.go delete mode 100644 internal/services/healthcare/sdk/2021-01-11/privateendpointconnections/version.go delete mode 100644 internal/services/healthcare/sdk/2021-01-11/privatelinkresources/client.go delete mode 100644 internal/services/healthcare/sdk/2021-01-11/privatelinkresources/constants.go delete mode 100644 internal/services/healthcare/sdk/2021-01-11/privatelinkresources/id_privatelinkresource.go delete mode 100644 internal/services/healthcare/sdk/2021-01-11/privatelinkresources/id_privatelinkresource_test.go delete mode 100644 internal/services/healthcare/sdk/2021-01-11/privatelinkresources/id_service.go delete mode 100644 internal/services/healthcare/sdk/2021-01-11/privatelinkresources/id_service_test.go delete mode 100644 internal/services/healthcare/sdk/2021-01-11/privatelinkresources/method_get_autorest.go delete mode 100644 internal/services/healthcare/sdk/2021-01-11/privatelinkresources/method_listbyservice_autorest.go delete mode 100644 internal/services/healthcare/sdk/2021-01-11/privatelinkresources/model_privatelinkresourcedescription.go delete mode 100644 internal/services/healthcare/sdk/2021-01-11/privatelinkresources/model_privatelinkresourcelistresultdescription.go delete mode 100644 internal/services/healthcare/sdk/2021-01-11/privatelinkresources/model_privatelinkresourceproperties.go delete mode 100644 internal/services/healthcare/sdk/2021-01-11/privatelinkresources/model_systemdata.go delete mode 100644 internal/services/healthcare/sdk/2021-01-11/privatelinkresources/version.go delete mode 100644 internal/services/healthcare/sdk/2021-01-11/proxy/client.go delete mode 100644 internal/services/healthcare/sdk/2021-01-11/proxy/constants.go delete mode 100644 internal/services/healthcare/sdk/2021-01-11/proxy/method_serviceschecknameavailability_autorest.go delete mode 100644 internal/services/healthcare/sdk/2021-01-11/proxy/model_checknameavailabilityparameters.go delete mode 100644 internal/services/healthcare/sdk/2021-01-11/proxy/model_servicesnameavailabilityinfo.go delete mode 100644 internal/services/healthcare/sdk/2021-01-11/proxy/version.go delete mode 100644 internal/services/healthcare/sdk/2021-01-11/resource/client.go delete mode 100644 internal/services/healthcare/sdk/2021-01-11/resource/constants.go delete mode 100644 internal/services/healthcare/sdk/2021-01-11/resource/id_service.go delete mode 100644 internal/services/healthcare/sdk/2021-01-11/resource/id_service_test.go delete mode 100644 internal/services/healthcare/sdk/2021-01-11/resource/method_servicescreateorupdate_autorest.go delete mode 100644 internal/services/healthcare/sdk/2021-01-11/resource/method_servicesdelete_autorest.go delete mode 100644 internal/services/healthcare/sdk/2021-01-11/resource/method_servicesget_autorest.go delete mode 100644 internal/services/healthcare/sdk/2021-01-11/resource/method_servicesupdate_autorest.go delete mode 100644 internal/services/healthcare/sdk/2021-01-11/resource/model_privateendpoint.go delete mode 100644 internal/services/healthcare/sdk/2021-01-11/resource/model_privateendpointconnection.go delete mode 100644 internal/services/healthcare/sdk/2021-01-11/resource/model_privateendpointconnectionproperties.go delete mode 100644 internal/services/healthcare/sdk/2021-01-11/resource/model_privatelinkserviceconnectionstate.go delete mode 100644 internal/services/healthcare/sdk/2021-01-11/resource/model_serviceaccesspolicyentry.go delete mode 100644 internal/services/healthcare/sdk/2021-01-11/resource/model_serviceacrconfigurationinfo.go delete mode 100644 internal/services/healthcare/sdk/2021-01-11/resource/model_serviceauthenticationconfigurationinfo.go delete mode 100644 internal/services/healthcare/sdk/2021-01-11/resource/model_servicecorsconfigurationinfo.go delete mode 100644 internal/services/healthcare/sdk/2021-01-11/resource/model_servicecosmosdbconfigurationinfo.go delete mode 100644 internal/services/healthcare/sdk/2021-01-11/resource/model_serviceexportconfigurationinfo.go delete mode 100644 internal/services/healthcare/sdk/2021-01-11/resource/model_servicesdescription.go delete mode 100644 internal/services/healthcare/sdk/2021-01-11/resource/model_servicespatchdescription.go delete mode 100644 internal/services/healthcare/sdk/2021-01-11/resource/model_servicesproperties.go delete mode 100644 internal/services/healthcare/sdk/2021-01-11/resource/model_servicespropertiesupdateparameters.go delete mode 100644 internal/services/healthcare/sdk/2021-01-11/resource/model_systemdata.go delete mode 100644 internal/services/healthcare/sdk/2021-01-11/resource/version.go delete mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/collection/client.go delete mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/collection/constants.go delete mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/collection/method_serviceslist_autorest.go delete mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/collection/method_serviceslistbyresourcegroup_autorest.go delete mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/collection/model_privateendpoint.go delete mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/collection/model_privateendpointconnection.go delete mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/collection/model_privateendpointconnectionproperties.go delete mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/collection/model_privatelinkserviceconnectionstate.go delete mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/collection/model_serviceaccesspolicyentry.go delete mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/collection/model_serviceacrconfigurationinfo.go delete mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/collection/model_serviceauthenticationconfigurationinfo.go delete mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/collection/model_servicecorsconfigurationinfo.go delete mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/collection/model_servicecosmosdbconfigurationinfo.go delete mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/collection/model_serviceexportconfigurationinfo.go delete mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/collection/model_servicesdescription.go delete mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/collection/model_servicesproperties.go delete mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/collection/model_systemdata.go delete mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/collection/predicates.go delete mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/collection/version.go delete mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/dicomservices/client.go delete mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/dicomservices/constants.go delete mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/dicomservices/id_dicomservice.go delete mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/dicomservices/id_dicomservice_test.go delete mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/dicomservices/id_workspace.go delete mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/dicomservices/id_workspace_test.go delete mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/dicomservices/method_createorupdate_autorest.go delete mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/dicomservices/method_delete_autorest.go delete mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/dicomservices/method_get_autorest.go delete mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/dicomservices/method_listbyworkspace_autorest.go delete mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/dicomservices/method_update_autorest.go delete mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/dicomservices/model_dicomservice.go delete mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/dicomservices/model_dicomserviceauthenticationconfiguration.go delete mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/dicomservices/model_dicomserviceproperties.go delete mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/dicomservices/model_resourcetags.go delete mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/dicomservices/model_systemdata.go delete mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/dicomservices/predicates.go delete mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/dicomservices/version.go delete mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/client.go delete mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/constants.go delete mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/id_fhirservice.go delete mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/id_fhirservice_test.go delete mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/id_workspace.go delete mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/id_workspace_test.go delete mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/method_createorupdate_autorest.go delete mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/method_delete_autorest.go delete mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/method_get_autorest.go delete mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/method_listbyworkspace_autorest.go delete mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/method_update_autorest.go delete mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/model_fhirservice.go delete mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/model_fhirserviceaccesspolicyentry.go delete mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/model_fhirserviceacrconfiguration.go delete mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/model_fhirserviceauthenticationconfiguration.go delete mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/model_fhirservicecorsconfiguration.go delete mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/model_fhirserviceexportconfiguration.go delete mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/model_fhirservicepatchresource.go delete mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/model_fhirserviceproperties.go delete mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/model_servicemanagedidentityidentity.go delete mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/model_systemdata.go delete mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/predicates.go delete mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/version.go delete mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/client.go delete mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/constants.go delete mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/id_fhirdestination.go delete mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/id_fhirdestination_test.go delete mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/id_iotconnector.go delete mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/id_iotconnector_test.go delete mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/id_workspace.go delete mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/id_workspace_test.go delete mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/method_createorupdate_autorest.go delete mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/method_delete_autorest.go delete mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/method_fhirdestinationslistbyiotconnector_autorest.go delete mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/method_get_autorest.go delete mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/method_iotconnectorfhirdestinationcreateorupdate_autorest.go delete mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/method_iotconnectorfhirdestinationdelete_autorest.go delete mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/method_iotconnectorfhirdestinationget_autorest.go delete mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/method_listbyworkspace_autorest.go delete mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/method_update_autorest.go delete mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/model_iotconnector.go delete mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/model_iotconnectorpatchresource.go delete mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/model_iotconnectorproperties.go delete mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/model_ioteventhubingestionendpointconfiguration.go delete mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/model_iotfhirdestination.go delete mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/model_iotfhirdestinationproperties.go delete mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/model_iotmappingproperties.go delete mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/model_servicemanagedidentityidentity.go delete mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/model_systemdata.go delete mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/predicates.go delete mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/version.go delete mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/privateendpointconnections/client.go delete mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/privateendpointconnections/constants.go delete mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/privateendpointconnections/id_privateendpointconnection.go delete mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/privateendpointconnections/id_privateendpointconnection_test.go delete mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/privateendpointconnections/id_service.go delete mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/privateendpointconnections/id_service_test.go delete mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/privateendpointconnections/method_createorupdate_autorest.go delete mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/privateendpointconnections/method_delete_autorest.go delete mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/privateendpointconnections/method_get_autorest.go delete mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/privateendpointconnections/method_listbyservice_autorest.go delete mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/privateendpointconnections/model_privateendpoint.go delete mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/privateendpointconnections/model_privateendpointconnection.go delete mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/privateendpointconnections/model_privateendpointconnectiondescription.go delete mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/privateendpointconnections/model_privateendpointconnectionlistresultdescription.go delete mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/privateendpointconnections/model_privateendpointconnectionproperties.go delete mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/privateendpointconnections/model_privatelinkserviceconnectionstate.go delete mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/privateendpointconnections/model_systemdata.go delete mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/privateendpointconnections/version.go delete mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/privatelinkresources/client.go delete mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/privatelinkresources/constants.go delete mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/privatelinkresources/id_privatelinkresource.go delete mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/privatelinkresources/id_privatelinkresource_test.go delete mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/privatelinkresources/id_service.go delete mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/privatelinkresources/id_service_test.go delete mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/privatelinkresources/method_get_autorest.go delete mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/privatelinkresources/method_listbyservice_autorest.go delete mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/privatelinkresources/model_privatelinkresourcedescription.go delete mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/privatelinkresources/model_privatelinkresourcelistresultdescription.go delete mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/privatelinkresources/model_privatelinkresourceproperties.go delete mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/privatelinkresources/model_systemdata.go delete mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/privatelinkresources/version.go delete mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/proxy/client.go delete mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/proxy/constants.go delete mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/proxy/method_serviceschecknameavailability_autorest.go delete mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/proxy/model_checknameavailabilityparameters.go delete mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/proxy/model_servicesnameavailabilityinfo.go delete mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/proxy/version.go delete mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/resource/client.go delete mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/resource/constants.go delete mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/resource/id_service.go delete mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/resource/id_service_test.go delete mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/resource/method_servicescreateorupdate_autorest.go delete mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/resource/method_servicesdelete_autorest.go delete mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/resource/method_servicesget_autorest.go delete mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/resource/method_servicesupdate_autorest.go delete mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/resource/model_privateendpoint.go delete mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/resource/model_privateendpointconnection.go delete mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/resource/model_privateendpointconnectionproperties.go delete mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/resource/model_privatelinkserviceconnectionstate.go delete mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/resource/model_serviceaccesspolicyentry.go delete mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/resource/model_serviceacrconfigurationinfo.go delete mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/resource/model_serviceauthenticationconfigurationinfo.go delete mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/resource/model_servicecorsconfigurationinfo.go delete mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/resource/model_servicecosmosdbconfigurationinfo.go delete mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/resource/model_serviceexportconfigurationinfo.go delete mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/resource/model_servicesdescription.go delete mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/resource/model_servicespatchdescription.go delete mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/resource/model_servicesproperties.go delete mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/resource/model_servicespropertiesupdateparameters.go delete mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/resource/model_systemdata.go delete mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/resource/version.go delete mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/workspaces/client.go delete mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/workspaces/constants.go delete mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/workspaces/id_workspace.go delete mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/workspaces/id_workspace_test.go delete mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/workspaces/method_createorupdate_autorest.go delete mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/workspaces/method_delete_autorest.go delete mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/workspaces/method_get_autorest.go delete mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/workspaces/method_listbyresourcegroup_autorest.go delete mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/workspaces/method_listbysubscription_autorest.go delete mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/workspaces/method_update_autorest.go delete mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/workspaces/model_resourcetags.go delete mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/workspaces/model_systemdata.go delete mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/workspaces/model_workspace.go delete mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/workspaces/model_workspaceproperties.go delete mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/workspaces/predicates.go delete mode 100644 internal/services/healthcare/sdk/2021-06-01-preview/workspaces/version.go diff --git a/internal/services/healthcare/healthcare_dicom_resource.go b/internal/services/healthcare/healthcare_dicom_resource.go index ebb307b07866..0b609725a8c1 100644 --- a/internal/services/healthcare/healthcare_dicom_resource.go +++ b/internal/services/healthcare/healthcare_dicom_resource.go @@ -4,7 +4,6 @@ import ( "context" "fmt" "log" - "strconv" "time" "github.com/Azure/azure-sdk-for-go/services/healthcareapis/mgmt/2021-11-01/healthcareapis" @@ -163,7 +162,7 @@ func resourceHealthcareApisDicomServiceCreate(d *pluginsdk.ResourceData, meta in } if err = future.WaitForCompletionRef(ctx, client.Client); err != nil { - return fmt.Errorf("waiting for creation/update %s: %+v", dicomServiceId, err) + return fmt.Errorf("waiting for creation %s: %+v", dicomServiceId, err) } d.SetId(dicomServiceId.ID()) @@ -274,54 +273,41 @@ func resourceHealthcareApisDicomServiceDelete(d *pluginsdk.ResourceData, meta in if err != nil { return fmt.Errorf("parsing Dicom service error: %+v", err) } - future, err := client.Delete(ctx, id.ResourceGroup, id.Name, id.WorkspaceName) if err != nil { - if response.WasNotFound(future.Response()) { - return nil + if !response.WasNotFound(future.Response()) { + return fmt.Errorf("deleting %s: %+v", *id, err) } - return fmt.Errorf("deleting %s: %+v", *id, err) - } - - return waitForDicomServiceToBeDeleted(ctx, client, *id) -} - -func waitForDicomServiceToBeDeleted(ctx context.Context, client *healthcareapis.DicomServicesClient, id parse.DicomServiceId) error { - deadline, ok := ctx.Deadline() - if !ok { - return fmt.Errorf("context has no deadline") } log.Printf("[DEBUG] Waiting for %s to be deleted..", id) stateConf := &pluginsdk.StateChangeConf{ - Pending: []string{"200"}, - Target: []string{"404"}, - Refresh: dicomServiceStateStatusCodeRefreshFunc(ctx, client, id), - Timeout: time.Until(deadline), + Pending: []string{"Pending"}, + Target: []string{"Deleted"}, + Refresh: dicomServiceStateStatusCodeRefreshFunc(ctx, client, *id), + Timeout: d.Timeout(pluginsdk.TimeoutDelete), + ContinuousTargetOccurence: 3, + PollInterval: 10 * time.Second, } if _, err := stateConf.WaitForStateContext(ctx); err != nil { return fmt.Errorf("waiting for %s to be deleted: %+v", id, err) } - return nil } func dicomServiceStateStatusCodeRefreshFunc(ctx context.Context, client *healthcareapis.DicomServicesClient, id parse.DicomServiceId) pluginsdk.StateRefreshFunc { return func() (interface{}, string, error) { res, err := client.Get(ctx, id.ResourceGroup, id.WorkspaceName, id.Name) - if res.Response.Response != nil { - log.Printf("Retrieving %s returned Status %d", id, res.Response.StatusCode) - } if err != nil { if utils.ResponseWasNotFound(res.Response) { - return res, strconv.Itoa(res.Response.StatusCode), nil + return res, "Deleted", nil } - return nil, "", fmt.Errorf("polling for the status of %s: %+v", id, err) + return nil, "Error", fmt.Errorf("polling for the status of %s: %+v", id, err) } - return res, strconv.Itoa(res.Response.StatusCode), nil + return res, "Pending", nil } } diff --git a/internal/services/healthcare/healthcare_dicom_resource_test.go b/internal/services/healthcare/healthcare_dicom_resource_test.go index d591e8416219..31411acc3ade 100644 --- a/internal/services/healthcare/healthcare_dicom_resource_test.go +++ b/internal/services/healthcare/healthcare_dicom_resource_test.go @@ -116,7 +116,7 @@ func (r HealthCareDicomResource) basic(data acceptance.TestData) string { %s resource "azurerm_healthcare_dicom_service" "test" { - name = "acctest-dicom%d" + name = "dicom%d" workspace_id = azurerm_healthcare_workspace.test.id location = "%s" depends_on = [azurerm_healthcare_workspace.test] @@ -129,7 +129,7 @@ func (r HealthCareDicomResource) complete(data acceptance.TestData) string { %s resource "azurerm_healthcare_dicom_service" "test" { - name = "acctest-dicom%d" + name = "dicom%d" workspace_id = azurerm_healthcare_workspace.test.id location = "%s" @@ -150,7 +150,7 @@ func (r HealthCareDicomResource) update(data acceptance.TestData) string { %s resource "azurerm_healthcare_dicom_service" "test" { - name = "acctest-dicom%d" + name = "dicom%d" workspace_id = azurerm_healthcare_workspace.test.id location = "%s" @@ -173,7 +173,7 @@ resource "azurerm_user_assigned_identity" "test" { } resource "azurerm_healthcare_dicom_service" "test" { - name = "acctest-dicom%d" + name = "dicom%d" workspace_id = azurerm_healthcare_workspace.test.id location = "%s" @@ -213,7 +213,7 @@ resource "azurerm_resource_group" "test" { } resource "azurerm_healthcare_workspace" "test" { - name = "acctestwk%d" + name = "wk%d" resource_group_name = azurerm_resource_group.test.name location = azurerm_resource_group.test.location } diff --git a/internal/services/healthcare/sdk/2021-01-11/collection/client.go b/internal/services/healthcare/sdk/2021-01-11/collection/client.go deleted file mode 100644 index 9c73b5b57183..000000000000 --- a/internal/services/healthcare/sdk/2021-01-11/collection/client.go +++ /dev/null @@ -1,15 +0,0 @@ -package collection - -import "github.com/Azure/go-autorest/autorest" - -type CollectionClient struct { - Client autorest.Client - baseUri string -} - -func NewCollectionClientWithBaseURI(endpoint string) CollectionClient { - return CollectionClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, - } -} diff --git a/internal/services/healthcare/sdk/2021-01-11/collection/constants.go b/internal/services/healthcare/sdk/2021-01-11/collection/constants.go deleted file mode 100644 index b26711c9a119..000000000000 --- a/internal/services/healthcare/sdk/2021-01-11/collection/constants.go +++ /dev/null @@ -1,210 +0,0 @@ -package collection - -import "strings" - -type CreatedByType string - -const ( - CreatedByTypeApplication CreatedByType = "Application" - CreatedByTypeKey CreatedByType = "Key" - CreatedByTypeManagedIdentity CreatedByType = "ManagedIdentity" - CreatedByTypeUser CreatedByType = "User" -) - -func PossibleValuesForCreatedByType() []string { - return []string{ - string(CreatedByTypeApplication), - string(CreatedByTypeKey), - string(CreatedByTypeManagedIdentity), - string(CreatedByTypeUser), - } -} - -func parseCreatedByType(input string) (*CreatedByType, error) { - vals := map[string]CreatedByType{ - "application": CreatedByTypeApplication, - "key": CreatedByTypeKey, - "managedidentity": CreatedByTypeManagedIdentity, - "user": CreatedByTypeUser, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := CreatedByType(input) - return &out, nil -} - -type Kind string - -const ( - KindFhir Kind = "fhir" - KindFhirNegativeRFour Kind = "fhir-R4" - KindFhirNegativeStuThree Kind = "fhir-Stu3" -) - -func PossibleValuesForKind() []string { - return []string{ - string(KindFhir), - string(KindFhirNegativeRFour), - string(KindFhirNegativeStuThree), - } -} - -func parseKind(input string) (*Kind, error) { - vals := map[string]Kind{ - "fhir": KindFhir, - "fhir-r4": KindFhirNegativeRFour, - "fhir-stu3": KindFhirNegativeStuThree, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := Kind(input) - return &out, nil -} - -type PrivateEndpointConnectionProvisioningState string - -const ( - PrivateEndpointConnectionProvisioningStateCreating PrivateEndpointConnectionProvisioningState = "Creating" - PrivateEndpointConnectionProvisioningStateDeleting PrivateEndpointConnectionProvisioningState = "Deleting" - PrivateEndpointConnectionProvisioningStateFailed PrivateEndpointConnectionProvisioningState = "Failed" - PrivateEndpointConnectionProvisioningStateSucceeded PrivateEndpointConnectionProvisioningState = "Succeeded" -) - -func PossibleValuesForPrivateEndpointConnectionProvisioningState() []string { - return []string{ - string(PrivateEndpointConnectionProvisioningStateCreating), - string(PrivateEndpointConnectionProvisioningStateDeleting), - string(PrivateEndpointConnectionProvisioningStateFailed), - string(PrivateEndpointConnectionProvisioningStateSucceeded), - } -} - -func parsePrivateEndpointConnectionProvisioningState(input string) (*PrivateEndpointConnectionProvisioningState, error) { - vals := map[string]PrivateEndpointConnectionProvisioningState{ - "creating": PrivateEndpointConnectionProvisioningStateCreating, - "deleting": PrivateEndpointConnectionProvisioningStateDeleting, - "failed": PrivateEndpointConnectionProvisioningStateFailed, - "succeeded": PrivateEndpointConnectionProvisioningStateSucceeded, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := PrivateEndpointConnectionProvisioningState(input) - return &out, nil -} - -type PrivateEndpointServiceConnectionStatus string - -const ( - PrivateEndpointServiceConnectionStatusApproved PrivateEndpointServiceConnectionStatus = "Approved" - PrivateEndpointServiceConnectionStatusPending PrivateEndpointServiceConnectionStatus = "Pending" - PrivateEndpointServiceConnectionStatusRejected PrivateEndpointServiceConnectionStatus = "Rejected" -) - -func PossibleValuesForPrivateEndpointServiceConnectionStatus() []string { - return []string{ - string(PrivateEndpointServiceConnectionStatusApproved), - string(PrivateEndpointServiceConnectionStatusPending), - string(PrivateEndpointServiceConnectionStatusRejected), - } -} - -func parsePrivateEndpointServiceConnectionStatus(input string) (*PrivateEndpointServiceConnectionStatus, error) { - vals := map[string]PrivateEndpointServiceConnectionStatus{ - "approved": PrivateEndpointServiceConnectionStatusApproved, - "pending": PrivateEndpointServiceConnectionStatusPending, - "rejected": PrivateEndpointServiceConnectionStatusRejected, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := PrivateEndpointServiceConnectionStatus(input) - return &out, nil -} - -type ProvisioningState string - -const ( - ProvisioningStateAccepted ProvisioningState = "Accepted" - ProvisioningStateCanceled ProvisioningState = "Canceled" - ProvisioningStateCreating ProvisioningState = "Creating" - ProvisioningStateDeleting ProvisioningState = "Deleting" - ProvisioningStateDeprovisioned ProvisioningState = "Deprovisioned" - ProvisioningStateFailed ProvisioningState = "Failed" - ProvisioningStateSucceeded ProvisioningState = "Succeeded" - ProvisioningStateUpdating ProvisioningState = "Updating" - ProvisioningStateVerifying ProvisioningState = "Verifying" -) - -func PossibleValuesForProvisioningState() []string { - return []string{ - string(ProvisioningStateAccepted), - string(ProvisioningStateCanceled), - string(ProvisioningStateCreating), - string(ProvisioningStateDeleting), - string(ProvisioningStateDeprovisioned), - string(ProvisioningStateFailed), - string(ProvisioningStateSucceeded), - string(ProvisioningStateUpdating), - string(ProvisioningStateVerifying), - } -} - -func parseProvisioningState(input string) (*ProvisioningState, error) { - vals := map[string]ProvisioningState{ - "accepted": ProvisioningStateAccepted, - "canceled": ProvisioningStateCanceled, - "creating": ProvisioningStateCreating, - "deleting": ProvisioningStateDeleting, - "deprovisioned": ProvisioningStateDeprovisioned, - "failed": ProvisioningStateFailed, - "succeeded": ProvisioningStateSucceeded, - "updating": ProvisioningStateUpdating, - "verifying": ProvisioningStateVerifying, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := ProvisioningState(input) - return &out, nil -} - -type PublicNetworkAccess string - -const ( - PublicNetworkAccessDisabled PublicNetworkAccess = "Disabled" - PublicNetworkAccessEnabled PublicNetworkAccess = "Enabled" -) - -func PossibleValuesForPublicNetworkAccess() []string { - return []string{ - string(PublicNetworkAccessDisabled), - string(PublicNetworkAccessEnabled), - } -} - -func parsePublicNetworkAccess(input string) (*PublicNetworkAccess, error) { - vals := map[string]PublicNetworkAccess{ - "disabled": PublicNetworkAccessDisabled, - "enabled": PublicNetworkAccessEnabled, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := PublicNetworkAccess(input) - return &out, nil -} diff --git a/internal/services/healthcare/sdk/2021-01-11/collection/method_serviceslist_autorest.go b/internal/services/healthcare/sdk/2021-01-11/collection/method_serviceslist_autorest.go deleted file mode 100644 index 43106463a451..000000000000 --- a/internal/services/healthcare/sdk/2021-01-11/collection/method_serviceslist_autorest.go +++ /dev/null @@ -1,184 +0,0 @@ -package collection - -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" -) - -type ServicesListResponse struct { - HttpResponse *http.Response - Model *[]ServicesDescription - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ServicesListResponse, error) -} - -type ServicesListCompleteResult struct { - Items []ServicesDescription -} - -func (r ServicesListResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ServicesListResponse) LoadMore(ctx context.Context) (resp ServicesListResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ServicesList ... -func (c CollectionClient) ServicesList(ctx context.Context, id commonids.SubscriptionId) (resp ServicesListResponse, err error) { - req, err := c.preparerForServicesList(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "collection.CollectionClient", "ServicesList", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "collection.CollectionClient", "ServicesList", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForServicesList(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "collection.CollectionClient", "ServicesList", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// ServicesListComplete retrieves all of the results into a single object -func (c CollectionClient) ServicesListComplete(ctx context.Context, id commonids.SubscriptionId) (ServicesListCompleteResult, error) { - return c.ServicesListCompleteMatchingPredicate(ctx, id, ServicesDescriptionPredicate{}) -} - -// ServicesListCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c CollectionClient) ServicesListCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate ServicesDescriptionPredicate) (resp ServicesListCompleteResult, err error) { - items := make([]ServicesDescription, 0) - - page, err := c.ServicesList(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 := ServicesListCompleteResult{ - Items: items, - } - return out, nil -} - -// preparerForServicesList prepares the ServicesList request. -func (c CollectionClient) preparerForServicesList(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.HealthcareApis/services", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForServicesListWithNextLink prepares the ServicesList request with the given nextLink token. -func (c CollectionClient) preparerForServicesListWithNextLink(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)) -} - -// responderForServicesList handles the response to the ServicesList request. The method always -// closes the http.Response Body. -func (c CollectionClient) responderForServicesList(resp *http.Response) (result ServicesListResponse, err error) { - type page struct { - Values []ServicesDescription `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 ServicesListResponse, err error) { - req, err := c.preparerForServicesListWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "collection.CollectionClient", "ServicesList", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "collection.CollectionClient", "ServicesList", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForServicesList(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "collection.CollectionClient", "ServicesList", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} diff --git a/internal/services/healthcare/sdk/2021-01-11/collection/method_serviceslistbyresourcegroup_autorest.go b/internal/services/healthcare/sdk/2021-01-11/collection/method_serviceslistbyresourcegroup_autorest.go deleted file mode 100644 index b57331bf1292..000000000000 --- a/internal/services/healthcare/sdk/2021-01-11/collection/method_serviceslistbyresourcegroup_autorest.go +++ /dev/null @@ -1,184 +0,0 @@ -package collection - -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" -) - -type ServicesListByResourceGroupResponse struct { - HttpResponse *http.Response - Model *[]ServicesDescription - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ServicesListByResourceGroupResponse, error) -} - -type ServicesListByResourceGroupCompleteResult struct { - Items []ServicesDescription -} - -func (r ServicesListByResourceGroupResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ServicesListByResourceGroupResponse) LoadMore(ctx context.Context) (resp ServicesListByResourceGroupResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ServicesListByResourceGroup ... -func (c CollectionClient) ServicesListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (resp ServicesListByResourceGroupResponse, err error) { - req, err := c.preparerForServicesListByResourceGroup(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "collection.CollectionClient", "ServicesListByResourceGroup", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "collection.CollectionClient", "ServicesListByResourceGroup", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForServicesListByResourceGroup(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "collection.CollectionClient", "ServicesListByResourceGroup", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// ServicesListByResourceGroupComplete retrieves all of the results into a single object -func (c CollectionClient) ServicesListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (ServicesListByResourceGroupCompleteResult, error) { - return c.ServicesListByResourceGroupCompleteMatchingPredicate(ctx, id, ServicesDescriptionPredicate{}) -} - -// ServicesListByResourceGroupCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c CollectionClient) ServicesListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate ServicesDescriptionPredicate) (resp ServicesListByResourceGroupCompleteResult, err error) { - items := make([]ServicesDescription, 0) - - page, err := c.ServicesListByResourceGroup(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 := ServicesListByResourceGroupCompleteResult{ - Items: items, - } - return out, nil -} - -// preparerForServicesListByResourceGroup prepares the ServicesListByResourceGroup request. -func (c CollectionClient) preparerForServicesListByResourceGroup(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.HealthcareApis/services", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForServicesListByResourceGroupWithNextLink prepares the ServicesListByResourceGroup request with the given nextLink token. -func (c CollectionClient) preparerForServicesListByResourceGroupWithNextLink(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)) -} - -// responderForServicesListByResourceGroup handles the response to the ServicesListByResourceGroup request. The method always -// closes the http.Response Body. -func (c CollectionClient) responderForServicesListByResourceGroup(resp *http.Response) (result ServicesListByResourceGroupResponse, err error) { - type page struct { - Values []ServicesDescription `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 ServicesListByResourceGroupResponse, err error) { - req, err := c.preparerForServicesListByResourceGroupWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "collection.CollectionClient", "ServicesListByResourceGroup", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "collection.CollectionClient", "ServicesListByResourceGroup", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForServicesListByResourceGroup(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "collection.CollectionClient", "ServicesListByResourceGroup", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} diff --git a/internal/services/healthcare/sdk/2021-01-11/collection/model_privateendpoint.go b/internal/services/healthcare/sdk/2021-01-11/collection/model_privateendpoint.go deleted file mode 100644 index 4fbaafd6baef..000000000000 --- a/internal/services/healthcare/sdk/2021-01-11/collection/model_privateendpoint.go +++ /dev/null @@ -1,5 +0,0 @@ -package collection - -type PrivateEndpoint struct { - Id *string `json:"id,omitempty"` -} diff --git a/internal/services/healthcare/sdk/2021-01-11/collection/model_privateendpointconnection.go b/internal/services/healthcare/sdk/2021-01-11/collection/model_privateendpointconnection.go deleted file mode 100644 index bb27ca23f744..000000000000 --- a/internal/services/healthcare/sdk/2021-01-11/collection/model_privateendpointconnection.go +++ /dev/null @@ -1,8 +0,0 @@ -package collection - -type PrivateEndpointConnection struct { - Id *string `json:"id,omitempty"` - Name *string `json:"name,omitempty"` - Properties *PrivateEndpointConnectionProperties `json:"properties,omitempty"` - Type *string `json:"type,omitempty"` -} diff --git a/internal/services/healthcare/sdk/2021-01-11/collection/model_privateendpointconnectionproperties.go b/internal/services/healthcare/sdk/2021-01-11/collection/model_privateendpointconnectionproperties.go deleted file mode 100644 index 4610ed7818db..000000000000 --- a/internal/services/healthcare/sdk/2021-01-11/collection/model_privateendpointconnectionproperties.go +++ /dev/null @@ -1,7 +0,0 @@ -package collection - -type PrivateEndpointConnectionProperties struct { - PrivateEndpoint *PrivateEndpoint `json:"privateEndpoint,omitempty"` - PrivateLinkServiceConnectionState PrivateLinkServiceConnectionState `json:"privateLinkServiceConnectionState"` - ProvisioningState *PrivateEndpointConnectionProvisioningState `json:"provisioningState,omitempty"` -} diff --git a/internal/services/healthcare/sdk/2021-01-11/collection/model_privatelinkserviceconnectionstate.go b/internal/services/healthcare/sdk/2021-01-11/collection/model_privatelinkserviceconnectionstate.go deleted file mode 100644 index fe6619d2e5b3..000000000000 --- a/internal/services/healthcare/sdk/2021-01-11/collection/model_privatelinkserviceconnectionstate.go +++ /dev/null @@ -1,7 +0,0 @@ -package collection - -type PrivateLinkServiceConnectionState struct { - ActionsRequired *string `json:"actionsRequired,omitempty"` - Description *string `json:"description,omitempty"` - Status *PrivateEndpointServiceConnectionStatus `json:"status,omitempty"` -} diff --git a/internal/services/healthcare/sdk/2021-01-11/collection/model_serviceaccesspolicyentry.go b/internal/services/healthcare/sdk/2021-01-11/collection/model_serviceaccesspolicyentry.go deleted file mode 100644 index 788b9abe36c4..000000000000 --- a/internal/services/healthcare/sdk/2021-01-11/collection/model_serviceaccesspolicyentry.go +++ /dev/null @@ -1,5 +0,0 @@ -package collection - -type ServiceAccessPolicyEntry struct { - ObjectId string `json:"objectId"` -} diff --git a/internal/services/healthcare/sdk/2021-01-11/collection/model_serviceacrconfigurationinfo.go b/internal/services/healthcare/sdk/2021-01-11/collection/model_serviceacrconfigurationinfo.go deleted file mode 100644 index e6aba5385d12..000000000000 --- a/internal/services/healthcare/sdk/2021-01-11/collection/model_serviceacrconfigurationinfo.go +++ /dev/null @@ -1,5 +0,0 @@ -package collection - -type ServiceAcrConfigurationInfo struct { - LoginServers *[]string `json:"loginServers,omitempty"` -} diff --git a/internal/services/healthcare/sdk/2021-01-11/collection/model_serviceauthenticationconfigurationinfo.go b/internal/services/healthcare/sdk/2021-01-11/collection/model_serviceauthenticationconfigurationinfo.go deleted file mode 100644 index 817440eddd27..000000000000 --- a/internal/services/healthcare/sdk/2021-01-11/collection/model_serviceauthenticationconfigurationinfo.go +++ /dev/null @@ -1,7 +0,0 @@ -package collection - -type ServiceAuthenticationConfigurationInfo struct { - Audience *string `json:"audience,omitempty"` - Authority *string `json:"authority,omitempty"` - SmartProxyEnabled *bool `json:"smartProxyEnabled,omitempty"` -} diff --git a/internal/services/healthcare/sdk/2021-01-11/collection/model_servicecorsconfigurationinfo.go b/internal/services/healthcare/sdk/2021-01-11/collection/model_servicecorsconfigurationinfo.go deleted file mode 100644 index c8c1e73b44ad..000000000000 --- a/internal/services/healthcare/sdk/2021-01-11/collection/model_servicecorsconfigurationinfo.go +++ /dev/null @@ -1,9 +0,0 @@ -package collection - -type ServiceCorsConfigurationInfo struct { - AllowCredentials *bool `json:"allowCredentials,omitempty"` - Headers *[]string `json:"headers,omitempty"` - MaxAge *int64 `json:"maxAge,omitempty"` - Methods *[]string `json:"methods,omitempty"` - Origins *[]string `json:"origins,omitempty"` -} diff --git a/internal/services/healthcare/sdk/2021-01-11/collection/model_servicecosmosdbconfigurationinfo.go b/internal/services/healthcare/sdk/2021-01-11/collection/model_servicecosmosdbconfigurationinfo.go deleted file mode 100644 index eec76c56a531..000000000000 --- a/internal/services/healthcare/sdk/2021-01-11/collection/model_servicecosmosdbconfigurationinfo.go +++ /dev/null @@ -1,6 +0,0 @@ -package collection - -type ServiceCosmosDbConfigurationInfo struct { - KeyVaultKeyUri *string `json:"keyVaultKeyUri,omitempty"` - OfferThroughput *int64 `json:"offerThroughput,omitempty"` -} diff --git a/internal/services/healthcare/sdk/2021-01-11/collection/model_serviceexportconfigurationinfo.go b/internal/services/healthcare/sdk/2021-01-11/collection/model_serviceexportconfigurationinfo.go deleted file mode 100644 index eee5a8843e2b..000000000000 --- a/internal/services/healthcare/sdk/2021-01-11/collection/model_serviceexportconfigurationinfo.go +++ /dev/null @@ -1,5 +0,0 @@ -package collection - -type ServiceExportConfigurationInfo struct { - StorageAccountName *string `json:"storageAccountName,omitempty"` -} diff --git a/internal/services/healthcare/sdk/2021-01-11/collection/model_servicesdescription.go b/internal/services/healthcare/sdk/2021-01-11/collection/model_servicesdescription.go deleted file mode 100644 index 0571a820794e..000000000000 --- a/internal/services/healthcare/sdk/2021-01-11/collection/model_servicesdescription.go +++ /dev/null @@ -1,18 +0,0 @@ -package collection - -import ( - "github.com/hashicorp/go-azure-helpers/resourcemanager/identity" -) - -type ServicesDescription struct { - Etag *string `json:"etag,omitempty"` - Id *string `json:"id,omitempty"` - Identity *identity.SystemAssigned `json:"identity,omitempty"` - Kind Kind `json:"kind"` - Location string `json:"location"` - Name *string `json:"name,omitempty"` - Properties *ServicesProperties `json:"properties,omitempty"` - SystemData *SystemData `json:"systemData,omitempty"` - Tags *map[string]string `json:"tags,omitempty"` - Type *string `json:"type,omitempty"` -} diff --git a/internal/services/healthcare/sdk/2021-01-11/collection/model_servicesproperties.go b/internal/services/healthcare/sdk/2021-01-11/collection/model_servicesproperties.go deleted file mode 100644 index aa60431aa653..000000000000 --- a/internal/services/healthcare/sdk/2021-01-11/collection/model_servicesproperties.go +++ /dev/null @@ -1,13 +0,0 @@ -package collection - -type ServicesProperties struct { - AccessPolicies *[]ServiceAccessPolicyEntry `json:"accessPolicies,omitempty"` - AcrConfiguration *ServiceAcrConfigurationInfo `json:"acrConfiguration,omitempty"` - AuthenticationConfiguration *ServiceAuthenticationConfigurationInfo `json:"authenticationConfiguration,omitempty"` - CorsConfiguration *ServiceCorsConfigurationInfo `json:"corsConfiguration,omitempty"` - CosmosDbConfiguration *ServiceCosmosDbConfigurationInfo `json:"cosmosDbConfiguration,omitempty"` - ExportConfiguration *ServiceExportConfigurationInfo `json:"exportConfiguration,omitempty"` - PrivateEndpointConnections *[]PrivateEndpointConnection `json:"privateEndpointConnections,omitempty"` - ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` - PublicNetworkAccess *PublicNetworkAccess `json:"publicNetworkAccess,omitempty"` -} diff --git a/internal/services/healthcare/sdk/2021-01-11/collection/model_systemdata.go b/internal/services/healthcare/sdk/2021-01-11/collection/model_systemdata.go deleted file mode 100644 index a8361db52cda..000000000000 --- a/internal/services/healthcare/sdk/2021-01-11/collection/model_systemdata.go +++ /dev/null @@ -1,40 +0,0 @@ -package collection - -import ( - "time" - - "github.com/hashicorp/go-azure-helpers/lang/dates" -) - -type SystemData struct { - CreatedAt *string `json:"createdAt,omitempty"` - CreatedBy *string `json:"createdBy,omitempty"` - CreatedByType *CreatedByType `json:"createdByType,omitempty"` - LastModifiedAt *string `json:"lastModifiedAt,omitempty"` - LastModifiedBy *string `json:"lastModifiedBy,omitempty"` - LastModifiedByType *CreatedByType `json:"lastModifiedByType,omitempty"` -} - -func (o SystemData) GetCreatedAtAsTime() (*time.Time, error) { - if o.CreatedAt == nil { - return nil, nil - } - return dates.ParseAsFormat(o.CreatedAt, "2006-01-02T15:04:05Z07:00") -} - -func (o SystemData) SetCreatedAtAsTime(input time.Time) { - formatted := input.Format("2006-01-02T15:04:05Z07:00") - o.CreatedAt = &formatted -} - -func (o SystemData) GetLastModifiedAtAsTime() (*time.Time, error) { - if o.LastModifiedAt == nil { - return nil, nil - } - return dates.ParseAsFormat(o.LastModifiedAt, "2006-01-02T15:04:05Z07:00") -} - -func (o SystemData) SetLastModifiedAtAsTime(input time.Time) { - formatted := input.Format("2006-01-02T15:04:05Z07:00") - o.LastModifiedAt = &formatted -} diff --git a/internal/services/healthcare/sdk/2021-01-11/collection/predicates.go b/internal/services/healthcare/sdk/2021-01-11/collection/predicates.go deleted file mode 100644 index b62be96254a8..000000000000 --- a/internal/services/healthcare/sdk/2021-01-11/collection/predicates.go +++ /dev/null @@ -1,34 +0,0 @@ -package collection - -type ServicesDescriptionPredicate struct { - Etag *string - Id *string - Location *string - Name *string - Type *string -} - -func (p ServicesDescriptionPredicate) Matches(input ServicesDescription) bool { - - if p.Etag != nil && (input.Etag == nil && *p.Etag != *input.Etag) { - return false - } - - if p.Id != nil && (input.Id == nil && *p.Id != *input.Id) { - return false - } - - if p.Location != nil && *p.Location != input.Location { - return false - } - - if p.Name != nil && (input.Name == nil && *p.Name != *input.Name) { - return false - } - - if p.Type != nil && (input.Type == nil && *p.Type != *input.Type) { - return false - } - - return true -} diff --git a/internal/services/healthcare/sdk/2021-01-11/collection/version.go b/internal/services/healthcare/sdk/2021-01-11/collection/version.go deleted file mode 100644 index 39cc3a1800db..000000000000 --- a/internal/services/healthcare/sdk/2021-01-11/collection/version.go +++ /dev/null @@ -1,9 +0,0 @@ -package collection - -import "fmt" - -const defaultApiVersion = "2021-01-11" - -func userAgent() string { - return fmt.Sprintf("pandora/collection/%s", defaultApiVersion) -} diff --git a/internal/services/healthcare/sdk/2021-01-11/privateendpointconnections/client.go b/internal/services/healthcare/sdk/2021-01-11/privateendpointconnections/client.go deleted file mode 100644 index adc4283affb2..000000000000 --- a/internal/services/healthcare/sdk/2021-01-11/privateendpointconnections/client.go +++ /dev/null @@ -1,15 +0,0 @@ -package privateendpointconnections - -import "github.com/Azure/go-autorest/autorest" - -type PrivateEndpointConnectionsClient struct { - Client autorest.Client - baseUri string -} - -func NewPrivateEndpointConnectionsClientWithBaseURI(endpoint string) PrivateEndpointConnectionsClient { - return PrivateEndpointConnectionsClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, - } -} diff --git a/internal/services/healthcare/sdk/2021-01-11/privateendpointconnections/constants.go b/internal/services/healthcare/sdk/2021-01-11/privateendpointconnections/constants.go deleted file mode 100644 index 32001a4a5e77..000000000000 --- a/internal/services/healthcare/sdk/2021-01-11/privateendpointconnections/constants.go +++ /dev/null @@ -1,102 +0,0 @@ -package privateendpointconnections - -import "strings" - -type CreatedByType string - -const ( - CreatedByTypeApplication CreatedByType = "Application" - CreatedByTypeKey CreatedByType = "Key" - CreatedByTypeManagedIdentity CreatedByType = "ManagedIdentity" - CreatedByTypeUser CreatedByType = "User" -) - -func PossibleValuesForCreatedByType() []string { - return []string{ - string(CreatedByTypeApplication), - string(CreatedByTypeKey), - string(CreatedByTypeManagedIdentity), - string(CreatedByTypeUser), - } -} - -func parseCreatedByType(input string) (*CreatedByType, error) { - vals := map[string]CreatedByType{ - "application": CreatedByTypeApplication, - "key": CreatedByTypeKey, - "managedidentity": CreatedByTypeManagedIdentity, - "user": CreatedByTypeUser, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := CreatedByType(input) - return &out, nil -} - -type PrivateEndpointConnectionProvisioningState string - -const ( - PrivateEndpointConnectionProvisioningStateCreating PrivateEndpointConnectionProvisioningState = "Creating" - PrivateEndpointConnectionProvisioningStateDeleting PrivateEndpointConnectionProvisioningState = "Deleting" - PrivateEndpointConnectionProvisioningStateFailed PrivateEndpointConnectionProvisioningState = "Failed" - PrivateEndpointConnectionProvisioningStateSucceeded PrivateEndpointConnectionProvisioningState = "Succeeded" -) - -func PossibleValuesForPrivateEndpointConnectionProvisioningState() []string { - return []string{ - string(PrivateEndpointConnectionProvisioningStateCreating), - string(PrivateEndpointConnectionProvisioningStateDeleting), - string(PrivateEndpointConnectionProvisioningStateFailed), - string(PrivateEndpointConnectionProvisioningStateSucceeded), - } -} - -func parsePrivateEndpointConnectionProvisioningState(input string) (*PrivateEndpointConnectionProvisioningState, error) { - vals := map[string]PrivateEndpointConnectionProvisioningState{ - "creating": PrivateEndpointConnectionProvisioningStateCreating, - "deleting": PrivateEndpointConnectionProvisioningStateDeleting, - "failed": PrivateEndpointConnectionProvisioningStateFailed, - "succeeded": PrivateEndpointConnectionProvisioningStateSucceeded, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := PrivateEndpointConnectionProvisioningState(input) - return &out, nil -} - -type PrivateEndpointServiceConnectionStatus string - -const ( - PrivateEndpointServiceConnectionStatusApproved PrivateEndpointServiceConnectionStatus = "Approved" - PrivateEndpointServiceConnectionStatusPending PrivateEndpointServiceConnectionStatus = "Pending" - PrivateEndpointServiceConnectionStatusRejected PrivateEndpointServiceConnectionStatus = "Rejected" -) - -func PossibleValuesForPrivateEndpointServiceConnectionStatus() []string { - return []string{ - string(PrivateEndpointServiceConnectionStatusApproved), - string(PrivateEndpointServiceConnectionStatusPending), - string(PrivateEndpointServiceConnectionStatusRejected), - } -} - -func parsePrivateEndpointServiceConnectionStatus(input string) (*PrivateEndpointServiceConnectionStatus, error) { - vals := map[string]PrivateEndpointServiceConnectionStatus{ - "approved": PrivateEndpointServiceConnectionStatusApproved, - "pending": PrivateEndpointServiceConnectionStatusPending, - "rejected": PrivateEndpointServiceConnectionStatusRejected, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := PrivateEndpointServiceConnectionStatus(input) - return &out, nil -} diff --git a/internal/services/healthcare/sdk/2021-01-11/privateendpointconnections/id_privateendpointconnection.go b/internal/services/healthcare/sdk/2021-01-11/privateendpointconnections/id_privateendpointconnection.go deleted file mode 100644 index f6e6cb11f4d1..000000000000 --- a/internal/services/healthcare/sdk/2021-01-11/privateendpointconnections/id_privateendpointconnection.go +++ /dev/null @@ -1,137 +0,0 @@ -package privateendpointconnections - -import ( - "fmt" - "strings" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -var _ resourceids.ResourceId = PrivateEndpointConnectionId{} - -// PrivateEndpointConnectionId is a struct representing the Resource ID for a Private Endpoint Connection -type PrivateEndpointConnectionId struct { - SubscriptionId string - ResourceGroupName string - ResourceName string - PrivateEndpointConnectionName string -} - -// NewPrivateEndpointConnectionID returns a new PrivateEndpointConnectionId struct -func NewPrivateEndpointConnectionID(subscriptionId string, resourceGroupName string, resourceName string, privateEndpointConnectionName string) PrivateEndpointConnectionId { - return PrivateEndpointConnectionId{ - SubscriptionId: subscriptionId, - ResourceGroupName: resourceGroupName, - ResourceName: resourceName, - PrivateEndpointConnectionName: privateEndpointConnectionName, - } -} - -// ParsePrivateEndpointConnectionID parses 'input' into a PrivateEndpointConnectionId -func ParsePrivateEndpointConnectionID(input string) (*PrivateEndpointConnectionId, error) { - parser := resourceids.NewParserFromResourceIdType(PrivateEndpointConnectionId{}) - parsed, err := parser.Parse(input, false) - if err != nil { - return nil, fmt.Errorf("parsing %q: %+v", input, err) - } - - var ok bool - id := PrivateEndpointConnectionId{} - - if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { - return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) - } - - if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { - return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) - } - - if id.ResourceName, ok = parsed.Parsed["resourceName"]; !ok { - return nil, fmt.Errorf("the segment 'resourceName' was not found in the resource id %q", input) - } - - if id.PrivateEndpointConnectionName, ok = parsed.Parsed["privateEndpointConnectionName"]; !ok { - return nil, fmt.Errorf("the segment 'privateEndpointConnectionName' was not found in the resource id %q", input) - } - - return &id, nil -} - -// ParsePrivateEndpointConnectionIDInsensitively parses 'input' case-insensitively into a PrivateEndpointConnectionId -// note: this method should only be used for API response data and not user input -func ParsePrivateEndpointConnectionIDInsensitively(input string) (*PrivateEndpointConnectionId, error) { - parser := resourceids.NewParserFromResourceIdType(PrivateEndpointConnectionId{}) - parsed, err := parser.Parse(input, true) - if err != nil { - return nil, fmt.Errorf("parsing %q: %+v", input, err) - } - - var ok bool - id := PrivateEndpointConnectionId{} - - if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { - return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) - } - - if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { - return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) - } - - if id.ResourceName, ok = parsed.Parsed["resourceName"]; !ok { - return nil, fmt.Errorf("the segment 'resourceName' was not found in the resource id %q", input) - } - - if id.PrivateEndpointConnectionName, ok = parsed.Parsed["privateEndpointConnectionName"]; !ok { - return nil, fmt.Errorf("the segment 'privateEndpointConnectionName' was not found in the resource id %q", input) - } - - return &id, nil -} - -// ValidatePrivateEndpointConnectionID checks that 'input' can be parsed as a Private Endpoint Connection ID -func ValidatePrivateEndpointConnectionID(input interface{}, key string) (warnings []string, errors []error) { - v, ok := input.(string) - if !ok { - errors = append(errors, fmt.Errorf("expected %q to be a string", key)) - return - } - - if _, err := ParsePrivateEndpointConnectionID(v); err != nil { - errors = append(errors, err) - } - - return -} - -// ID returns the formatted Private Endpoint Connection ID -func (id PrivateEndpointConnectionId) ID() string { - fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.HealthcareApis/services/%s/privateEndpointConnections/%s" - return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ResourceName, id.PrivateEndpointConnectionName) -} - -// Segments returns a slice of Resource ID Segments which comprise this Private Endpoint Connection ID -func (id PrivateEndpointConnectionId) Segments() []resourceids.Segment { - return []resourceids.Segment{ - resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), - resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), - resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), - resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), - resourceids.StaticSegment("staticProviders", "providers", "providers"), - resourceids.ResourceProviderSegment("staticMicrosoftHealthcareApis", "Microsoft.HealthcareApis", "Microsoft.HealthcareApis"), - resourceids.StaticSegment("staticServices", "services", "services"), - resourceids.UserSpecifiedSegment("resourceName", "resourceValue"), - resourceids.StaticSegment("staticPrivateEndpointConnections", "privateEndpointConnections", "privateEndpointConnections"), - resourceids.UserSpecifiedSegment("privateEndpointConnectionName", "privateEndpointConnectionValue"), - } -} - -// String returns a human-readable description of this Private Endpoint Connection ID -func (id PrivateEndpointConnectionId) String() string { - components := []string{ - fmt.Sprintf("Subscription: %q", id.SubscriptionId), - fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), - fmt.Sprintf("Resource Name: %q", id.ResourceName), - fmt.Sprintf("Private Endpoint Connection Name: %q", id.PrivateEndpointConnectionName), - } - return fmt.Sprintf("Private Endpoint Connection (%s)", strings.Join(components, "\n")) -} diff --git a/internal/services/healthcare/sdk/2021-01-11/privateendpointconnections/id_privateendpointconnection_test.go b/internal/services/healthcare/sdk/2021-01-11/privateendpointconnections/id_privateendpointconnection_test.go deleted file mode 100644 index 7876560ae7a7..000000000000 --- a/internal/services/healthcare/sdk/2021-01-11/privateendpointconnections/id_privateendpointconnection_test.go +++ /dev/null @@ -1,324 +0,0 @@ -package privateendpointconnections - -import ( - "testing" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -var _ resourceids.ResourceId = PrivateEndpointConnectionId{} - -func TestNewPrivateEndpointConnectionID(t *testing.T) { - id := NewPrivateEndpointConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "resourceValue", "privateEndpointConnectionValue") - - if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { - t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") - } - - if id.ResourceGroupName != "example-resource-group" { - t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") - } - - if id.ResourceName != "resourceValue" { - t.Fatalf("Expected %q but got %q for Segment 'ResourceName'", id.ResourceName, "resourceValue") - } - - if id.PrivateEndpointConnectionName != "privateEndpointConnectionValue" { - t.Fatalf("Expected %q but got %q for Segment 'PrivateEndpointConnectionName'", id.PrivateEndpointConnectionName, "privateEndpointConnectionValue") - } -} - -func TestFormatPrivateEndpointConnectionID(t *testing.T) { - actual := NewPrivateEndpointConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "resourceValue", "privateEndpointConnectionValue").ID() - expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/services/resourceValue/privateEndpointConnections/privateEndpointConnectionValue" - if actual != expected { - t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) - } -} - -func TestParsePrivateEndpointConnectionID(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *PrivateEndpointConnectionId - }{ - { - // Incomplete URI - Input: "", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/services", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/services/resourceValue", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/services/resourceValue/privateEndpointConnections", - Error: true, - }, - { - // Valid URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/services/resourceValue/privateEndpointConnections/privateEndpointConnectionValue", - Expected: &PrivateEndpointConnectionId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "example-resource-group", - ResourceName: "resourceValue", - PrivateEndpointConnectionName: "privateEndpointConnectionValue", - }, - }, - { - // Invalid (Valid Uri with Extra segment) - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/services/resourceValue/privateEndpointConnections/privateEndpointConnectionValue/extra", - Error: true, - }, - } - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := ParsePrivateEndpointConnectionID(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expect a value but got an error: %+v", err) - } - if v.Error { - t.Fatal("Expect an error but didn't get one") - } - - if actual.SubscriptionId != v.Expected.SubscriptionId { - t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) - } - - if actual.ResourceGroupName != v.Expected.ResourceGroupName { - t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) - } - - if actual.ResourceName != v.Expected.ResourceName { - t.Fatalf("Expected %q but got %q for ResourceName", v.Expected.ResourceName, actual.ResourceName) - } - - if actual.PrivateEndpointConnectionName != v.Expected.PrivateEndpointConnectionName { - t.Fatalf("Expected %q but got %q for PrivateEndpointConnectionName", v.Expected.PrivateEndpointConnectionName, actual.PrivateEndpointConnectionName) - } - - } -} - -func TestParsePrivateEndpointConnectionIDInsensitively(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *PrivateEndpointConnectionId - }{ - { - // Incomplete URI - Input: "", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hEaLtHcArEaPiS", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/services", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hEaLtHcArEaPiS/sErViCeS", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/services/resourceValue", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hEaLtHcArEaPiS/sErViCeS/rEsOuRcEvAlUe", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/services/resourceValue/privateEndpointConnections", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hEaLtHcArEaPiS/sErViCeS/rEsOuRcEvAlUe/pRiVaTeEnDpOiNtCoNnEcTiOnS", - Error: true, - }, - { - // Valid URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/services/resourceValue/privateEndpointConnections/privateEndpointConnectionValue", - Expected: &PrivateEndpointConnectionId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "example-resource-group", - ResourceName: "resourceValue", - PrivateEndpointConnectionName: "privateEndpointConnectionValue", - }, - }, - { - // Invalid (Valid Uri with Extra segment) - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/services/resourceValue/privateEndpointConnections/privateEndpointConnectionValue/extra", - Error: true, - }, - { - // Valid URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hEaLtHcArEaPiS/sErViCeS/rEsOuRcEvAlUe/pRiVaTeEnDpOiNtCoNnEcTiOnS/pRiVaTeEnDpOiNtCoNnEcTiOnVaLuE", - Expected: &PrivateEndpointConnectionId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", - ResourceName: "rEsOuRcEvAlUe", - PrivateEndpointConnectionName: "pRiVaTeEnDpOiNtCoNnEcTiOnVaLuE", - }, - }, - { - // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hEaLtHcArEaPiS/sErViCeS/rEsOuRcEvAlUe/pRiVaTeEnDpOiNtCoNnEcTiOnS/pRiVaTeEnDpOiNtCoNnEcTiOnVaLuE/extra", - Error: true, - }, - } - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := ParsePrivateEndpointConnectionIDInsensitively(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expect a value but got an error: %+v", err) - } - if v.Error { - t.Fatal("Expect an error but didn't get one") - } - - if actual.SubscriptionId != v.Expected.SubscriptionId { - t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) - } - - if actual.ResourceGroupName != v.Expected.ResourceGroupName { - t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) - } - - if actual.ResourceName != v.Expected.ResourceName { - t.Fatalf("Expected %q but got %q for ResourceName", v.Expected.ResourceName, actual.ResourceName) - } - - if actual.PrivateEndpointConnectionName != v.Expected.PrivateEndpointConnectionName { - t.Fatalf("Expected %q but got %q for PrivateEndpointConnectionName", v.Expected.PrivateEndpointConnectionName, actual.PrivateEndpointConnectionName) - } - - } -} - -func TestSegmentsForPrivateEndpointConnectionId(t *testing.T) { - segments := PrivateEndpointConnectionId{}.Segments() - if len(segments) == 0 { - t.Fatalf("PrivateEndpointConnectionId has no segments") - } - - uniqueNames := make(map[string]struct{}, 0) - for _, segment := range segments { - uniqueNames[segment.Name] = struct{}{} - } - if len(uniqueNames) != len(segments) { - t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) - } -} diff --git a/internal/services/healthcare/sdk/2021-01-11/privateendpointconnections/id_service.go b/internal/services/healthcare/sdk/2021-01-11/privateendpointconnections/id_service.go deleted file mode 100644 index cb8692be3199..000000000000 --- a/internal/services/healthcare/sdk/2021-01-11/privateendpointconnections/id_service.go +++ /dev/null @@ -1,124 +0,0 @@ -package privateendpointconnections - -import ( - "fmt" - "strings" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -var _ resourceids.ResourceId = ServiceId{} - -// ServiceId is a struct representing the Resource ID for a Service -type ServiceId struct { - SubscriptionId string - ResourceGroupName string - ResourceName string -} - -// NewServiceID returns a new ServiceId struct -func NewServiceID(subscriptionId string, resourceGroupName string, resourceName string) ServiceId { - return ServiceId{ - SubscriptionId: subscriptionId, - ResourceGroupName: resourceGroupName, - ResourceName: resourceName, - } -} - -// ParseServiceID parses 'input' into a ServiceId -func ParseServiceID(input string) (*ServiceId, error) { - parser := resourceids.NewParserFromResourceIdType(ServiceId{}) - parsed, err := parser.Parse(input, false) - if err != nil { - return nil, fmt.Errorf("parsing %q: %+v", input, err) - } - - var ok bool - id := ServiceId{} - - if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { - return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) - } - - if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { - return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) - } - - if id.ResourceName, ok = parsed.Parsed["resourceName"]; !ok { - return nil, fmt.Errorf("the segment 'resourceName' was not found in the resource id %q", input) - } - - return &id, nil -} - -// ParseServiceIDInsensitively parses 'input' case-insensitively into a ServiceId -// note: this method should only be used for API response data and not user input -func ParseServiceIDInsensitively(input string) (*ServiceId, error) { - parser := resourceids.NewParserFromResourceIdType(ServiceId{}) - parsed, err := parser.Parse(input, true) - if err != nil { - return nil, fmt.Errorf("parsing %q: %+v", input, err) - } - - var ok bool - id := ServiceId{} - - if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { - return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) - } - - if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { - return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) - } - - if id.ResourceName, ok = parsed.Parsed["resourceName"]; !ok { - return nil, fmt.Errorf("the segment 'resourceName' was not found in the resource id %q", input) - } - - return &id, nil -} - -// ValidateServiceID checks that 'input' can be parsed as a Service ID -func ValidateServiceID(input interface{}, key string) (warnings []string, errors []error) { - v, ok := input.(string) - if !ok { - errors = append(errors, fmt.Errorf("expected %q to be a string", key)) - return - } - - if _, err := ParseServiceID(v); err != nil { - errors = append(errors, err) - } - - return -} - -// ID returns the formatted Service ID -func (id ServiceId) ID() string { - fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.HealthcareApis/services/%s" - return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ResourceName) -} - -// Segments returns a slice of Resource ID Segments which comprise this Service ID -func (id ServiceId) Segments() []resourceids.Segment { - return []resourceids.Segment{ - resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), - resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), - resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), - resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), - resourceids.StaticSegment("staticProviders", "providers", "providers"), - resourceids.ResourceProviderSegment("staticMicrosoftHealthcareApis", "Microsoft.HealthcareApis", "Microsoft.HealthcareApis"), - resourceids.StaticSegment("staticServices", "services", "services"), - resourceids.UserSpecifiedSegment("resourceName", "resourceValue"), - } -} - -// String returns a human-readable description of this Service ID -func (id ServiceId) String() string { - components := []string{ - fmt.Sprintf("Subscription: %q", id.SubscriptionId), - fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), - fmt.Sprintf("Resource Name: %q", id.ResourceName), - } - return fmt.Sprintf("Service (%s)", strings.Join(components, "\n")) -} diff --git a/internal/services/healthcare/sdk/2021-01-11/privateendpointconnections/id_service_test.go b/internal/services/healthcare/sdk/2021-01-11/privateendpointconnections/id_service_test.go deleted file mode 100644 index d879c6948696..000000000000 --- a/internal/services/healthcare/sdk/2021-01-11/privateendpointconnections/id_service_test.go +++ /dev/null @@ -1,279 +0,0 @@ -package privateendpointconnections - -import ( - "testing" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -var _ resourceids.ResourceId = ServiceId{} - -func TestNewServiceID(t *testing.T) { - id := NewServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "resourceValue") - - if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { - t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") - } - - if id.ResourceGroupName != "example-resource-group" { - t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") - } - - if id.ResourceName != "resourceValue" { - t.Fatalf("Expected %q but got %q for Segment 'ResourceName'", id.ResourceName, "resourceValue") - } -} - -func TestFormatServiceID(t *testing.T) { - actual := NewServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "resourceValue").ID() - expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/services/resourceValue" - if actual != expected { - t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) - } -} - -func TestParseServiceID(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *ServiceId - }{ - { - // Incomplete URI - Input: "", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/services", - Error: true, - }, - { - // Valid URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/services/resourceValue", - Expected: &ServiceId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "example-resource-group", - ResourceName: "resourceValue", - }, - }, - { - // Invalid (Valid Uri with Extra segment) - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/services/resourceValue/extra", - Error: true, - }, - } - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := ParseServiceID(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expect a value but got an error: %+v", err) - } - if v.Error { - t.Fatal("Expect an error but didn't get one") - } - - if actual.SubscriptionId != v.Expected.SubscriptionId { - t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) - } - - if actual.ResourceGroupName != v.Expected.ResourceGroupName { - t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) - } - - if actual.ResourceName != v.Expected.ResourceName { - t.Fatalf("Expected %q but got %q for ResourceName", v.Expected.ResourceName, actual.ResourceName) - } - - } -} - -func TestParseServiceIDInsensitively(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *ServiceId - }{ - { - // Incomplete URI - Input: "", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hEaLtHcArEaPiS", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/services", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hEaLtHcArEaPiS/sErViCeS", - Error: true, - }, - { - // Valid URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/services/resourceValue", - Expected: &ServiceId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "example-resource-group", - ResourceName: "resourceValue", - }, - }, - { - // Invalid (Valid Uri with Extra segment) - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/services/resourceValue/extra", - Error: true, - }, - { - // Valid URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hEaLtHcArEaPiS/sErViCeS/rEsOuRcEvAlUe", - Expected: &ServiceId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", - ResourceName: "rEsOuRcEvAlUe", - }, - }, - { - // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hEaLtHcArEaPiS/sErViCeS/rEsOuRcEvAlUe/extra", - Error: true, - }, - } - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := ParseServiceIDInsensitively(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expect a value but got an error: %+v", err) - } - if v.Error { - t.Fatal("Expect an error but didn't get one") - } - - if actual.SubscriptionId != v.Expected.SubscriptionId { - t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) - } - - if actual.ResourceGroupName != v.Expected.ResourceGroupName { - t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) - } - - if actual.ResourceName != v.Expected.ResourceName { - t.Fatalf("Expected %q but got %q for ResourceName", v.Expected.ResourceName, actual.ResourceName) - } - - } -} - -func TestSegmentsForServiceId(t *testing.T) { - segments := ServiceId{}.Segments() - if len(segments) == 0 { - t.Fatalf("ServiceId has no segments") - } - - uniqueNames := make(map[string]struct{}, 0) - for _, segment := range segments { - uniqueNames[segment.Name] = struct{}{} - } - if len(uniqueNames) != len(segments) { - t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) - } -} diff --git a/internal/services/healthcare/sdk/2021-01-11/privateendpointconnections/method_createorupdate_autorest.go b/internal/services/healthcare/sdk/2021-01-11/privateendpointconnections/method_createorupdate_autorest.go deleted file mode 100644 index 986cb8f4f626..000000000000 --- a/internal/services/healthcare/sdk/2021-01-11/privateendpointconnections/method_createorupdate_autorest.go +++ /dev/null @@ -1,75 +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" -) - -type CreateOrUpdateResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// CreateOrUpdate ... -func (c PrivateEndpointConnectionsClient) CreateOrUpdate(ctx context.Context, id PrivateEndpointConnectionId, input PrivateEndpointConnection) (result CreateOrUpdateResponse, err error) { - req, err := c.preparerForCreateOrUpdate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "privateendpointconnections.PrivateEndpointConnectionsClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result, err = c.senderForCreateOrUpdate(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "privateendpointconnections.PrivateEndpointConnectionsClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed -func (c PrivateEndpointConnectionsClient) CreateOrUpdateThenPoll(ctx context.Context, id PrivateEndpointConnectionId, input PrivateEndpointConnection) 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 PrivateEndpointConnectionsClient) preparerForCreateOrUpdate(ctx context.Context, id PrivateEndpointConnectionId, input PrivateEndpointConnection) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForCreateOrUpdate sends the CreateOrUpdate request. The method will close the -// http.Response Body if it receives an error. -func (c PrivateEndpointConnectionsClient) senderForCreateOrUpdate(ctx context.Context, req *http.Request) (future CreateOrUpdateResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - future.Poller, err = polling.NewLongRunningPollerFromResponse(ctx, resp, c.Client) - return -} diff --git a/internal/services/healthcare/sdk/2021-01-11/privateendpointconnections/method_delete_autorest.go b/internal/services/healthcare/sdk/2021-01-11/privateendpointconnections/method_delete_autorest.go deleted file mode 100644 index 3c4a86df694f..000000000000 --- a/internal/services/healthcare/sdk/2021-01-11/privateendpointconnections/method_delete_autorest.go +++ /dev/null @@ -1,74 +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" -) - -type DeleteResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// Delete ... -func (c PrivateEndpointConnectionsClient) Delete(ctx context.Context, id PrivateEndpointConnectionId) (result DeleteResponse, err error) { - req, err := c.preparerForDelete(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "privateendpointconnections.PrivateEndpointConnectionsClient", "Delete", nil, "Failure preparing request") - return - } - - result, err = c.senderForDelete(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "privateendpointconnections.PrivateEndpointConnectionsClient", "Delete", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// DeleteThenPoll performs Delete then polls until it's completed -func (c PrivateEndpointConnectionsClient) DeleteThenPoll(ctx context.Context, id PrivateEndpointConnectionId) error { - result, err := c.Delete(ctx, id) - if err != nil { - return fmt.Errorf("performing Delete: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after Delete: %+v", err) - } - - return nil -} - -// preparerForDelete prepares the Delete request. -func (c PrivateEndpointConnectionsClient) preparerForDelete(ctx context.Context, id PrivateEndpointConnectionId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForDelete sends the Delete request. The method will close the -// http.Response Body if it receives an error. -func (c PrivateEndpointConnectionsClient) senderForDelete(ctx context.Context, req *http.Request) (future DeleteResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - future.Poller, err = polling.NewLongRunningPollerFromResponse(ctx, resp, c.Client) - return -} diff --git a/internal/services/healthcare/sdk/2021-01-11/privateendpointconnections/method_get_autorest.go b/internal/services/healthcare/sdk/2021-01-11/privateendpointconnections/method_get_autorest.go deleted file mode 100644 index 349a61376bc5..000000000000 --- a/internal/services/healthcare/sdk/2021-01-11/privateendpointconnections/method_get_autorest.go +++ /dev/null @@ -1,64 +0,0 @@ -package privateendpointconnections - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -type GetResponse struct { - HttpResponse *http.Response - Model *PrivateEndpointConnectionDescription -} - -// Get ... -func (c PrivateEndpointConnectionsClient) Get(ctx context.Context, id PrivateEndpointConnectionId) (result GetResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "privateendpointconnections.PrivateEndpointConnectionsClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "privateendpointconnections.PrivateEndpointConnectionsClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "privateendpointconnections.PrivateEndpointConnectionsClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c PrivateEndpointConnectionsClient) preparerForGet(ctx context.Context, id PrivateEndpointConnectionId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGet handles the response to the Get request. The method always -// closes the http.Response Body. -func (c PrivateEndpointConnectionsClient) responderForGet(resp *http.Response) (result GetResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - return -} diff --git a/internal/services/healthcare/sdk/2021-01-11/privateendpointconnections/method_listbyservice_autorest.go b/internal/services/healthcare/sdk/2021-01-11/privateendpointconnections/method_listbyservice_autorest.go deleted file mode 100644 index a908376bfddb..000000000000 --- a/internal/services/healthcare/sdk/2021-01-11/privateendpointconnections/method_listbyservice_autorest.go +++ /dev/null @@ -1,65 +0,0 @@ -package privateendpointconnections - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -type ListByServiceResponse struct { - HttpResponse *http.Response - Model *PrivateEndpointConnectionListResultDescription -} - -// ListByService ... -func (c PrivateEndpointConnectionsClient) ListByService(ctx context.Context, id ServiceId) (result ListByServiceResponse, err error) { - req, err := c.preparerForListByService(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "privateendpointconnections.PrivateEndpointConnectionsClient", "ListByService", 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", "ListByService", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByService(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "privateendpointconnections.PrivateEndpointConnectionsClient", "ListByService", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForListByService prepares the ListByService request. -func (c PrivateEndpointConnectionsClient) 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/privateEndpointConnections", 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 PrivateEndpointConnectionsClient) responderForListByService(resp *http.Response) (result ListByServiceResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - return -} diff --git a/internal/services/healthcare/sdk/2021-01-11/privateendpointconnections/model_privateendpoint.go b/internal/services/healthcare/sdk/2021-01-11/privateendpointconnections/model_privateendpoint.go deleted file mode 100644 index 33ffc888d58a..000000000000 --- a/internal/services/healthcare/sdk/2021-01-11/privateendpointconnections/model_privateendpoint.go +++ /dev/null @@ -1,5 +0,0 @@ -package privateendpointconnections - -type PrivateEndpoint struct { - Id *string `json:"id,omitempty"` -} diff --git a/internal/services/healthcare/sdk/2021-01-11/privateendpointconnections/model_privateendpointconnection.go b/internal/services/healthcare/sdk/2021-01-11/privateendpointconnections/model_privateendpointconnection.go deleted file mode 100644 index 597d3e71746a..000000000000 --- a/internal/services/healthcare/sdk/2021-01-11/privateendpointconnections/model_privateendpointconnection.go +++ /dev/null @@ -1,8 +0,0 @@ -package privateendpointconnections - -type PrivateEndpointConnection struct { - Id *string `json:"id,omitempty"` - Name *string `json:"name,omitempty"` - Properties *PrivateEndpointConnectionProperties `json:"properties,omitempty"` - Type *string `json:"type,omitempty"` -} diff --git a/internal/services/healthcare/sdk/2021-01-11/privateendpointconnections/model_privateendpointconnectiondescription.go b/internal/services/healthcare/sdk/2021-01-11/privateendpointconnections/model_privateendpointconnectiondescription.go deleted file mode 100644 index 95543c352044..000000000000 --- a/internal/services/healthcare/sdk/2021-01-11/privateendpointconnections/model_privateendpointconnectiondescription.go +++ /dev/null @@ -1,9 +0,0 @@ -package privateendpointconnections - -type PrivateEndpointConnectionDescription struct { - Id *string `json:"id,omitempty"` - Name *string `json:"name,omitempty"` - Properties *PrivateEndpointConnectionProperties `json:"properties,omitempty"` - SystemData *SystemData `json:"systemData,omitempty"` - Type *string `json:"type,omitempty"` -} diff --git a/internal/services/healthcare/sdk/2021-01-11/privateendpointconnections/model_privateendpointconnectionlistresultdescription.go b/internal/services/healthcare/sdk/2021-01-11/privateendpointconnections/model_privateendpointconnectionlistresultdescription.go deleted file mode 100644 index 579bed999b3d..000000000000 --- a/internal/services/healthcare/sdk/2021-01-11/privateendpointconnections/model_privateendpointconnectionlistresultdescription.go +++ /dev/null @@ -1,5 +0,0 @@ -package privateendpointconnections - -type PrivateEndpointConnectionListResultDescription struct { - Value *[]PrivateEndpointConnectionDescription `json:"value,omitempty"` -} diff --git a/internal/services/healthcare/sdk/2021-01-11/privateendpointconnections/model_privateendpointconnectionproperties.go b/internal/services/healthcare/sdk/2021-01-11/privateendpointconnections/model_privateendpointconnectionproperties.go deleted file mode 100644 index 252bd91cbe86..000000000000 --- a/internal/services/healthcare/sdk/2021-01-11/privateendpointconnections/model_privateendpointconnectionproperties.go +++ /dev/null @@ -1,7 +0,0 @@ -package privateendpointconnections - -type PrivateEndpointConnectionProperties struct { - PrivateEndpoint *PrivateEndpoint `json:"privateEndpoint,omitempty"` - PrivateLinkServiceConnectionState PrivateLinkServiceConnectionState `json:"privateLinkServiceConnectionState"` - ProvisioningState *PrivateEndpointConnectionProvisioningState `json:"provisioningState,omitempty"` -} diff --git a/internal/services/healthcare/sdk/2021-01-11/privateendpointconnections/model_privatelinkserviceconnectionstate.go b/internal/services/healthcare/sdk/2021-01-11/privateendpointconnections/model_privatelinkserviceconnectionstate.go deleted file mode 100644 index def138656add..000000000000 --- a/internal/services/healthcare/sdk/2021-01-11/privateendpointconnections/model_privatelinkserviceconnectionstate.go +++ /dev/null @@ -1,7 +0,0 @@ -package privateendpointconnections - -type PrivateLinkServiceConnectionState struct { - ActionsRequired *string `json:"actionsRequired,omitempty"` - Description *string `json:"description,omitempty"` - Status *PrivateEndpointServiceConnectionStatus `json:"status,omitempty"` -} diff --git a/internal/services/healthcare/sdk/2021-01-11/privateendpointconnections/model_systemdata.go b/internal/services/healthcare/sdk/2021-01-11/privateendpointconnections/model_systemdata.go deleted file mode 100644 index 3d46829edeb6..000000000000 --- a/internal/services/healthcare/sdk/2021-01-11/privateendpointconnections/model_systemdata.go +++ /dev/null @@ -1,40 +0,0 @@ -package privateendpointconnections - -import ( - "time" - - "github.com/hashicorp/go-azure-helpers/lang/dates" -) - -type SystemData struct { - CreatedAt *string `json:"createdAt,omitempty"` - CreatedBy *string `json:"createdBy,omitempty"` - CreatedByType *CreatedByType `json:"createdByType,omitempty"` - LastModifiedAt *string `json:"lastModifiedAt,omitempty"` - LastModifiedBy *string `json:"lastModifiedBy,omitempty"` - LastModifiedByType *CreatedByType `json:"lastModifiedByType,omitempty"` -} - -func (o SystemData) GetCreatedAtAsTime() (*time.Time, error) { - if o.CreatedAt == nil { - return nil, nil - } - return dates.ParseAsFormat(o.CreatedAt, "2006-01-02T15:04:05Z07:00") -} - -func (o SystemData) SetCreatedAtAsTime(input time.Time) { - formatted := input.Format("2006-01-02T15:04:05Z07:00") - o.CreatedAt = &formatted -} - -func (o SystemData) GetLastModifiedAtAsTime() (*time.Time, error) { - if o.LastModifiedAt == nil { - return nil, nil - } - return dates.ParseAsFormat(o.LastModifiedAt, "2006-01-02T15:04:05Z07:00") -} - -func (o SystemData) SetLastModifiedAtAsTime(input time.Time) { - formatted := input.Format("2006-01-02T15:04:05Z07:00") - o.LastModifiedAt = &formatted -} diff --git a/internal/services/healthcare/sdk/2021-01-11/privateendpointconnections/version.go b/internal/services/healthcare/sdk/2021-01-11/privateendpointconnections/version.go deleted file mode 100644 index c19b0ce1a43e..000000000000 --- a/internal/services/healthcare/sdk/2021-01-11/privateendpointconnections/version.go +++ /dev/null @@ -1,9 +0,0 @@ -package privateendpointconnections - -import "fmt" - -const defaultApiVersion = "2021-01-11" - -func userAgent() string { - return fmt.Sprintf("pandora/privateendpointconnections/%s", defaultApiVersion) -} diff --git a/internal/services/healthcare/sdk/2021-01-11/privatelinkresources/client.go b/internal/services/healthcare/sdk/2021-01-11/privatelinkresources/client.go deleted file mode 100644 index 3ccc015d4fe1..000000000000 --- a/internal/services/healthcare/sdk/2021-01-11/privatelinkresources/client.go +++ /dev/null @@ -1,15 +0,0 @@ -package privatelinkresources - -import "github.com/Azure/go-autorest/autorest" - -type PrivateLinkResourcesClient struct { - Client autorest.Client - baseUri string -} - -func NewPrivateLinkResourcesClientWithBaseURI(endpoint string) PrivateLinkResourcesClient { - return PrivateLinkResourcesClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, - } -} diff --git a/internal/services/healthcare/sdk/2021-01-11/privatelinkresources/constants.go b/internal/services/healthcare/sdk/2021-01-11/privatelinkresources/constants.go deleted file mode 100644 index 8b7848581899..000000000000 --- a/internal/services/healthcare/sdk/2021-01-11/privatelinkresources/constants.go +++ /dev/null @@ -1,37 +0,0 @@ -package privatelinkresources - -import "strings" - -type CreatedByType string - -const ( - CreatedByTypeApplication CreatedByType = "Application" - CreatedByTypeKey CreatedByType = "Key" - CreatedByTypeManagedIdentity CreatedByType = "ManagedIdentity" - CreatedByTypeUser CreatedByType = "User" -) - -func PossibleValuesForCreatedByType() []string { - return []string{ - string(CreatedByTypeApplication), - string(CreatedByTypeKey), - string(CreatedByTypeManagedIdentity), - string(CreatedByTypeUser), - } -} - -func parseCreatedByType(input string) (*CreatedByType, error) { - vals := map[string]CreatedByType{ - "application": CreatedByTypeApplication, - "key": CreatedByTypeKey, - "managedidentity": CreatedByTypeManagedIdentity, - "user": CreatedByTypeUser, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := CreatedByType(input) - return &out, nil -} diff --git a/internal/services/healthcare/sdk/2021-01-11/privatelinkresources/id_privatelinkresource.go b/internal/services/healthcare/sdk/2021-01-11/privatelinkresources/id_privatelinkresource.go deleted file mode 100644 index 4a716efea2d6..000000000000 --- a/internal/services/healthcare/sdk/2021-01-11/privatelinkresources/id_privatelinkresource.go +++ /dev/null @@ -1,137 +0,0 @@ -package privatelinkresources - -import ( - "fmt" - "strings" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -var _ resourceids.ResourceId = PrivateLinkResourceId{} - -// PrivateLinkResourceId is a struct representing the Resource ID for a Private Link Resource -type PrivateLinkResourceId struct { - SubscriptionId string - ResourceGroupName string - ResourceName string - GroupName string -} - -// NewPrivateLinkResourceID returns a new PrivateLinkResourceId struct -func NewPrivateLinkResourceID(subscriptionId string, resourceGroupName string, resourceName string, groupName string) PrivateLinkResourceId { - return PrivateLinkResourceId{ - SubscriptionId: subscriptionId, - ResourceGroupName: resourceGroupName, - ResourceName: resourceName, - GroupName: groupName, - } -} - -// ParsePrivateLinkResourceID parses 'input' into a PrivateLinkResourceId -func ParsePrivateLinkResourceID(input string) (*PrivateLinkResourceId, error) { - parser := resourceids.NewParserFromResourceIdType(PrivateLinkResourceId{}) - parsed, err := parser.Parse(input, false) - if err != nil { - return nil, fmt.Errorf("parsing %q: %+v", input, err) - } - - var ok bool - id := PrivateLinkResourceId{} - - if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { - return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) - } - - if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { - return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) - } - - if id.ResourceName, ok = parsed.Parsed["resourceName"]; !ok { - return nil, fmt.Errorf("the segment 'resourceName' was not found in the resource id %q", input) - } - - if id.GroupName, ok = parsed.Parsed["groupName"]; !ok { - return nil, fmt.Errorf("the segment 'groupName' was not found in the resource id %q", input) - } - - return &id, nil -} - -// ParsePrivateLinkResourceIDInsensitively parses 'input' case-insensitively into a PrivateLinkResourceId -// note: this method should only be used for API response data and not user input -func ParsePrivateLinkResourceIDInsensitively(input string) (*PrivateLinkResourceId, error) { - parser := resourceids.NewParserFromResourceIdType(PrivateLinkResourceId{}) - parsed, err := parser.Parse(input, true) - if err != nil { - return nil, fmt.Errorf("parsing %q: %+v", input, err) - } - - var ok bool - id := PrivateLinkResourceId{} - - if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { - return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) - } - - if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { - return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) - } - - if id.ResourceName, ok = parsed.Parsed["resourceName"]; !ok { - return nil, fmt.Errorf("the segment 'resourceName' was not found in the resource id %q", input) - } - - if id.GroupName, ok = parsed.Parsed["groupName"]; !ok { - return nil, fmt.Errorf("the segment 'groupName' was not found in the resource id %q", input) - } - - return &id, nil -} - -// ValidatePrivateLinkResourceID checks that 'input' can be parsed as a Private Link Resource ID -func ValidatePrivateLinkResourceID(input interface{}, key string) (warnings []string, errors []error) { - v, ok := input.(string) - if !ok { - errors = append(errors, fmt.Errorf("expected %q to be a string", key)) - return - } - - if _, err := ParsePrivateLinkResourceID(v); err != nil { - errors = append(errors, err) - } - - return -} - -// ID returns the formatted Private Link Resource ID -func (id PrivateLinkResourceId) ID() string { - fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.HealthcareApis/services/%s/privateLinkResources/%s" - return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ResourceName, id.GroupName) -} - -// Segments returns a slice of Resource ID Segments which comprise this Private Link Resource ID -func (id PrivateLinkResourceId) Segments() []resourceids.Segment { - return []resourceids.Segment{ - resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), - resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), - resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), - resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), - resourceids.StaticSegment("staticProviders", "providers", "providers"), - resourceids.ResourceProviderSegment("staticMicrosoftHealthcareApis", "Microsoft.HealthcareApis", "Microsoft.HealthcareApis"), - resourceids.StaticSegment("staticServices", "services", "services"), - resourceids.UserSpecifiedSegment("resourceName", "resourceValue"), - resourceids.StaticSegment("staticPrivateLinkResources", "privateLinkResources", "privateLinkResources"), - resourceids.UserSpecifiedSegment("groupName", "groupValue"), - } -} - -// String returns a human-readable description of this Private Link Resource ID -func (id PrivateLinkResourceId) String() string { - components := []string{ - fmt.Sprintf("Subscription: %q", id.SubscriptionId), - fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), - fmt.Sprintf("Resource Name: %q", id.ResourceName), - fmt.Sprintf("Group Name: %q", id.GroupName), - } - return fmt.Sprintf("Private Link Resource (%s)", strings.Join(components, "\n")) -} diff --git a/internal/services/healthcare/sdk/2021-01-11/privatelinkresources/id_privatelinkresource_test.go b/internal/services/healthcare/sdk/2021-01-11/privatelinkresources/id_privatelinkresource_test.go deleted file mode 100644 index a7334abc33b5..000000000000 --- a/internal/services/healthcare/sdk/2021-01-11/privatelinkresources/id_privatelinkresource_test.go +++ /dev/null @@ -1,324 +0,0 @@ -package privatelinkresources - -import ( - "testing" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -var _ resourceids.ResourceId = PrivateLinkResourceId{} - -func TestNewPrivateLinkResourceID(t *testing.T) { - id := NewPrivateLinkResourceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "resourceValue", "groupValue") - - if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { - t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") - } - - if id.ResourceGroupName != "example-resource-group" { - t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") - } - - if id.ResourceName != "resourceValue" { - t.Fatalf("Expected %q but got %q for Segment 'ResourceName'", id.ResourceName, "resourceValue") - } - - if id.GroupName != "groupValue" { - t.Fatalf("Expected %q but got %q for Segment 'GroupName'", id.GroupName, "groupValue") - } -} - -func TestFormatPrivateLinkResourceID(t *testing.T) { - actual := NewPrivateLinkResourceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "resourceValue", "groupValue").ID() - expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/services/resourceValue/privateLinkResources/groupValue" - if actual != expected { - t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) - } -} - -func TestParsePrivateLinkResourceID(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *PrivateLinkResourceId - }{ - { - // Incomplete URI - Input: "", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/services", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/services/resourceValue", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/services/resourceValue/privateLinkResources", - Error: true, - }, - { - // Valid URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/services/resourceValue/privateLinkResources/groupValue", - Expected: &PrivateLinkResourceId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "example-resource-group", - ResourceName: "resourceValue", - GroupName: "groupValue", - }, - }, - { - // Invalid (Valid Uri with Extra segment) - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/services/resourceValue/privateLinkResources/groupValue/extra", - Error: true, - }, - } - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := ParsePrivateLinkResourceID(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expect a value but got an error: %+v", err) - } - if v.Error { - t.Fatal("Expect an error but didn't get one") - } - - if actual.SubscriptionId != v.Expected.SubscriptionId { - t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) - } - - if actual.ResourceGroupName != v.Expected.ResourceGroupName { - t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) - } - - if actual.ResourceName != v.Expected.ResourceName { - t.Fatalf("Expected %q but got %q for ResourceName", v.Expected.ResourceName, actual.ResourceName) - } - - if actual.GroupName != v.Expected.GroupName { - t.Fatalf("Expected %q but got %q for GroupName", v.Expected.GroupName, actual.GroupName) - } - - } -} - -func TestParsePrivateLinkResourceIDInsensitively(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *PrivateLinkResourceId - }{ - { - // Incomplete URI - Input: "", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hEaLtHcArEaPiS", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/services", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hEaLtHcArEaPiS/sErViCeS", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/services/resourceValue", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hEaLtHcArEaPiS/sErViCeS/rEsOuRcEvAlUe", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/services/resourceValue/privateLinkResources", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hEaLtHcArEaPiS/sErViCeS/rEsOuRcEvAlUe/pRiVaTeLiNkReSoUrCeS", - Error: true, - }, - { - // Valid URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/services/resourceValue/privateLinkResources/groupValue", - Expected: &PrivateLinkResourceId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "example-resource-group", - ResourceName: "resourceValue", - GroupName: "groupValue", - }, - }, - { - // Invalid (Valid Uri with Extra segment) - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/services/resourceValue/privateLinkResources/groupValue/extra", - Error: true, - }, - { - // Valid URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hEaLtHcArEaPiS/sErViCeS/rEsOuRcEvAlUe/pRiVaTeLiNkReSoUrCeS/gRoUpVaLuE", - Expected: &PrivateLinkResourceId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", - ResourceName: "rEsOuRcEvAlUe", - GroupName: "gRoUpVaLuE", - }, - }, - { - // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hEaLtHcArEaPiS/sErViCeS/rEsOuRcEvAlUe/pRiVaTeLiNkReSoUrCeS/gRoUpVaLuE/extra", - Error: true, - }, - } - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := ParsePrivateLinkResourceIDInsensitively(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expect a value but got an error: %+v", err) - } - if v.Error { - t.Fatal("Expect an error but didn't get one") - } - - if actual.SubscriptionId != v.Expected.SubscriptionId { - t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) - } - - if actual.ResourceGroupName != v.Expected.ResourceGroupName { - t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) - } - - if actual.ResourceName != v.Expected.ResourceName { - t.Fatalf("Expected %q but got %q for ResourceName", v.Expected.ResourceName, actual.ResourceName) - } - - if actual.GroupName != v.Expected.GroupName { - t.Fatalf("Expected %q but got %q for GroupName", v.Expected.GroupName, actual.GroupName) - } - - } -} - -func TestSegmentsForPrivateLinkResourceId(t *testing.T) { - segments := PrivateLinkResourceId{}.Segments() - if len(segments) == 0 { - t.Fatalf("PrivateLinkResourceId has no segments") - } - - uniqueNames := make(map[string]struct{}, 0) - for _, segment := range segments { - uniqueNames[segment.Name] = struct{}{} - } - if len(uniqueNames) != len(segments) { - t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) - } -} diff --git a/internal/services/healthcare/sdk/2021-01-11/privatelinkresources/id_service.go b/internal/services/healthcare/sdk/2021-01-11/privatelinkresources/id_service.go deleted file mode 100644 index f87dd953cbc0..000000000000 --- a/internal/services/healthcare/sdk/2021-01-11/privatelinkresources/id_service.go +++ /dev/null @@ -1,124 +0,0 @@ -package privatelinkresources - -import ( - "fmt" - "strings" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -var _ resourceids.ResourceId = ServiceId{} - -// ServiceId is a struct representing the Resource ID for a Service -type ServiceId struct { - SubscriptionId string - ResourceGroupName string - ResourceName string -} - -// NewServiceID returns a new ServiceId struct -func NewServiceID(subscriptionId string, resourceGroupName string, resourceName string) ServiceId { - return ServiceId{ - SubscriptionId: subscriptionId, - ResourceGroupName: resourceGroupName, - ResourceName: resourceName, - } -} - -// ParseServiceID parses 'input' into a ServiceId -func ParseServiceID(input string) (*ServiceId, error) { - parser := resourceids.NewParserFromResourceIdType(ServiceId{}) - parsed, err := parser.Parse(input, false) - if err != nil { - return nil, fmt.Errorf("parsing %q: %+v", input, err) - } - - var ok bool - id := ServiceId{} - - if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { - return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) - } - - if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { - return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) - } - - if id.ResourceName, ok = parsed.Parsed["resourceName"]; !ok { - return nil, fmt.Errorf("the segment 'resourceName' was not found in the resource id %q", input) - } - - return &id, nil -} - -// ParseServiceIDInsensitively parses 'input' case-insensitively into a ServiceId -// note: this method should only be used for API response data and not user input -func ParseServiceIDInsensitively(input string) (*ServiceId, error) { - parser := resourceids.NewParserFromResourceIdType(ServiceId{}) - parsed, err := parser.Parse(input, true) - if err != nil { - return nil, fmt.Errorf("parsing %q: %+v", input, err) - } - - var ok bool - id := ServiceId{} - - if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { - return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) - } - - if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { - return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) - } - - if id.ResourceName, ok = parsed.Parsed["resourceName"]; !ok { - return nil, fmt.Errorf("the segment 'resourceName' was not found in the resource id %q", input) - } - - return &id, nil -} - -// ValidateServiceID checks that 'input' can be parsed as a Service ID -func ValidateServiceID(input interface{}, key string) (warnings []string, errors []error) { - v, ok := input.(string) - if !ok { - errors = append(errors, fmt.Errorf("expected %q to be a string", key)) - return - } - - if _, err := ParseServiceID(v); err != nil { - errors = append(errors, err) - } - - return -} - -// ID returns the formatted Service ID -func (id ServiceId) ID() string { - fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.HealthcareApis/services/%s" - return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ResourceName) -} - -// Segments returns a slice of Resource ID Segments which comprise this Service ID -func (id ServiceId) Segments() []resourceids.Segment { - return []resourceids.Segment{ - resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), - resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), - resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), - resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), - resourceids.StaticSegment("staticProviders", "providers", "providers"), - resourceids.ResourceProviderSegment("staticMicrosoftHealthcareApis", "Microsoft.HealthcareApis", "Microsoft.HealthcareApis"), - resourceids.StaticSegment("staticServices", "services", "services"), - resourceids.UserSpecifiedSegment("resourceName", "resourceValue"), - } -} - -// String returns a human-readable description of this Service ID -func (id ServiceId) String() string { - components := []string{ - fmt.Sprintf("Subscription: %q", id.SubscriptionId), - fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), - fmt.Sprintf("Resource Name: %q", id.ResourceName), - } - return fmt.Sprintf("Service (%s)", strings.Join(components, "\n")) -} diff --git a/internal/services/healthcare/sdk/2021-01-11/privatelinkresources/id_service_test.go b/internal/services/healthcare/sdk/2021-01-11/privatelinkresources/id_service_test.go deleted file mode 100644 index 32a385125ba0..000000000000 --- a/internal/services/healthcare/sdk/2021-01-11/privatelinkresources/id_service_test.go +++ /dev/null @@ -1,279 +0,0 @@ -package privatelinkresources - -import ( - "testing" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -var _ resourceids.ResourceId = ServiceId{} - -func TestNewServiceID(t *testing.T) { - id := NewServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "resourceValue") - - if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { - t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") - } - - if id.ResourceGroupName != "example-resource-group" { - t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") - } - - if id.ResourceName != "resourceValue" { - t.Fatalf("Expected %q but got %q for Segment 'ResourceName'", id.ResourceName, "resourceValue") - } -} - -func TestFormatServiceID(t *testing.T) { - actual := NewServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "resourceValue").ID() - expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/services/resourceValue" - if actual != expected { - t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) - } -} - -func TestParseServiceID(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *ServiceId - }{ - { - // Incomplete URI - Input: "", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/services", - Error: true, - }, - { - // Valid URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/services/resourceValue", - Expected: &ServiceId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "example-resource-group", - ResourceName: "resourceValue", - }, - }, - { - // Invalid (Valid Uri with Extra segment) - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/services/resourceValue/extra", - Error: true, - }, - } - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := ParseServiceID(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expect a value but got an error: %+v", err) - } - if v.Error { - t.Fatal("Expect an error but didn't get one") - } - - if actual.SubscriptionId != v.Expected.SubscriptionId { - t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) - } - - if actual.ResourceGroupName != v.Expected.ResourceGroupName { - t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) - } - - if actual.ResourceName != v.Expected.ResourceName { - t.Fatalf("Expected %q but got %q for ResourceName", v.Expected.ResourceName, actual.ResourceName) - } - - } -} - -func TestParseServiceIDInsensitively(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *ServiceId - }{ - { - // Incomplete URI - Input: "", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hEaLtHcArEaPiS", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/services", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hEaLtHcArEaPiS/sErViCeS", - Error: true, - }, - { - // Valid URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/services/resourceValue", - Expected: &ServiceId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "example-resource-group", - ResourceName: "resourceValue", - }, - }, - { - // Invalid (Valid Uri with Extra segment) - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/services/resourceValue/extra", - Error: true, - }, - { - // Valid URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hEaLtHcArEaPiS/sErViCeS/rEsOuRcEvAlUe", - Expected: &ServiceId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", - ResourceName: "rEsOuRcEvAlUe", - }, - }, - { - // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hEaLtHcArEaPiS/sErViCeS/rEsOuRcEvAlUe/extra", - Error: true, - }, - } - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := ParseServiceIDInsensitively(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expect a value but got an error: %+v", err) - } - if v.Error { - t.Fatal("Expect an error but didn't get one") - } - - if actual.SubscriptionId != v.Expected.SubscriptionId { - t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) - } - - if actual.ResourceGroupName != v.Expected.ResourceGroupName { - t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) - } - - if actual.ResourceName != v.Expected.ResourceName { - t.Fatalf("Expected %q but got %q for ResourceName", v.Expected.ResourceName, actual.ResourceName) - } - - } -} - -func TestSegmentsForServiceId(t *testing.T) { - segments := ServiceId{}.Segments() - if len(segments) == 0 { - t.Fatalf("ServiceId has no segments") - } - - uniqueNames := make(map[string]struct{}, 0) - for _, segment := range segments { - uniqueNames[segment.Name] = struct{}{} - } - if len(uniqueNames) != len(segments) { - t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) - } -} diff --git a/internal/services/healthcare/sdk/2021-01-11/privatelinkresources/method_get_autorest.go b/internal/services/healthcare/sdk/2021-01-11/privatelinkresources/method_get_autorest.go deleted file mode 100644 index 097c32ab3809..000000000000 --- a/internal/services/healthcare/sdk/2021-01-11/privatelinkresources/method_get_autorest.go +++ /dev/null @@ -1,64 +0,0 @@ -package privatelinkresources - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -type GetResponse struct { - HttpResponse *http.Response - Model *PrivateLinkResourceDescription -} - -// Get ... -func (c PrivateLinkResourcesClient) Get(ctx context.Context, id PrivateLinkResourceId) (result GetResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "privatelinkresources.PrivateLinkResourcesClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "privatelinkresources.PrivateLinkResourcesClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "privatelinkresources.PrivateLinkResourcesClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c PrivateLinkResourcesClient) preparerForGet(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)) -} - -// responderForGet handles the response to the Get request. The method always -// closes the http.Response Body. -func (c PrivateLinkResourcesClient) responderForGet(resp *http.Response) (result GetResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - return -} diff --git a/internal/services/healthcare/sdk/2021-01-11/privatelinkresources/method_listbyservice_autorest.go b/internal/services/healthcare/sdk/2021-01-11/privatelinkresources/method_listbyservice_autorest.go deleted file mode 100644 index a13255a4d1bb..000000000000 --- a/internal/services/healthcare/sdk/2021-01-11/privatelinkresources/method_listbyservice_autorest.go +++ /dev/null @@ -1,65 +0,0 @@ -package privatelinkresources - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -type ListByServiceResponse struct { - HttpResponse *http.Response - Model *PrivateLinkResourceListResultDescription -} - -// ListByService ... -func (c PrivateLinkResourcesClient) ListByService(ctx context.Context, id ServiceId) (result ListByServiceResponse, err error) { - req, err := c.preparerForListByService(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "privatelinkresources.PrivateLinkResourcesClient", "ListByService", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "privatelinkresources.PrivateLinkResourcesClient", "ListByService", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByService(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "privatelinkresources.PrivateLinkResourcesClient", "ListByService", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForListByService prepares the ListByService request. -func (c PrivateLinkResourcesClient) 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/privateLinkResources", 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 PrivateLinkResourcesClient) responderForListByService(resp *http.Response) (result ListByServiceResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - return -} diff --git a/internal/services/healthcare/sdk/2021-01-11/privatelinkresources/model_privatelinkresourcedescription.go b/internal/services/healthcare/sdk/2021-01-11/privatelinkresources/model_privatelinkresourcedescription.go deleted file mode 100644 index cd11d5179a60..000000000000 --- a/internal/services/healthcare/sdk/2021-01-11/privatelinkresources/model_privatelinkresourcedescription.go +++ /dev/null @@ -1,9 +0,0 @@ -package privatelinkresources - -type PrivateLinkResourceDescription struct { - Id *string `json:"id,omitempty"` - Name *string `json:"name,omitempty"` - Properties *PrivateLinkResourceProperties `json:"properties,omitempty"` - SystemData *SystemData `json:"systemData,omitempty"` - Type *string `json:"type,omitempty"` -} diff --git a/internal/services/healthcare/sdk/2021-01-11/privatelinkresources/model_privatelinkresourcelistresultdescription.go b/internal/services/healthcare/sdk/2021-01-11/privatelinkresources/model_privatelinkresourcelistresultdescription.go deleted file mode 100644 index 9bf0baa227c8..000000000000 --- a/internal/services/healthcare/sdk/2021-01-11/privatelinkresources/model_privatelinkresourcelistresultdescription.go +++ /dev/null @@ -1,5 +0,0 @@ -package privatelinkresources - -type PrivateLinkResourceListResultDescription struct { - Value *[]PrivateLinkResourceDescription `json:"value,omitempty"` -} diff --git a/internal/services/healthcare/sdk/2021-01-11/privatelinkresources/model_privatelinkresourceproperties.go b/internal/services/healthcare/sdk/2021-01-11/privatelinkresources/model_privatelinkresourceproperties.go deleted file mode 100644 index 51bc838c1fbd..000000000000 --- a/internal/services/healthcare/sdk/2021-01-11/privatelinkresources/model_privatelinkresourceproperties.go +++ /dev/null @@ -1,7 +0,0 @@ -package privatelinkresources - -type PrivateLinkResourceProperties struct { - GroupId *string `json:"groupId,omitempty"` - RequiredMembers *[]string `json:"requiredMembers,omitempty"` - RequiredZoneNames *[]string `json:"requiredZoneNames,omitempty"` -} diff --git a/internal/services/healthcare/sdk/2021-01-11/privatelinkresources/model_systemdata.go b/internal/services/healthcare/sdk/2021-01-11/privatelinkresources/model_systemdata.go deleted file mode 100644 index f9327b762df1..000000000000 --- a/internal/services/healthcare/sdk/2021-01-11/privatelinkresources/model_systemdata.go +++ /dev/null @@ -1,40 +0,0 @@ -package privatelinkresources - -import ( - "time" - - "github.com/hashicorp/go-azure-helpers/lang/dates" -) - -type SystemData struct { - CreatedAt *string `json:"createdAt,omitempty"` - CreatedBy *string `json:"createdBy,omitempty"` - CreatedByType *CreatedByType `json:"createdByType,omitempty"` - LastModifiedAt *string `json:"lastModifiedAt,omitempty"` - LastModifiedBy *string `json:"lastModifiedBy,omitempty"` - LastModifiedByType *CreatedByType `json:"lastModifiedByType,omitempty"` -} - -func (o SystemData) GetCreatedAtAsTime() (*time.Time, error) { - if o.CreatedAt == nil { - return nil, nil - } - return dates.ParseAsFormat(o.CreatedAt, "2006-01-02T15:04:05Z07:00") -} - -func (o SystemData) SetCreatedAtAsTime(input time.Time) { - formatted := input.Format("2006-01-02T15:04:05Z07:00") - o.CreatedAt = &formatted -} - -func (o SystemData) GetLastModifiedAtAsTime() (*time.Time, error) { - if o.LastModifiedAt == nil { - return nil, nil - } - return dates.ParseAsFormat(o.LastModifiedAt, "2006-01-02T15:04:05Z07:00") -} - -func (o SystemData) SetLastModifiedAtAsTime(input time.Time) { - formatted := input.Format("2006-01-02T15:04:05Z07:00") - o.LastModifiedAt = &formatted -} diff --git a/internal/services/healthcare/sdk/2021-01-11/privatelinkresources/version.go b/internal/services/healthcare/sdk/2021-01-11/privatelinkresources/version.go deleted file mode 100644 index 7a2bb306bb9a..000000000000 --- a/internal/services/healthcare/sdk/2021-01-11/privatelinkresources/version.go +++ /dev/null @@ -1,9 +0,0 @@ -package privatelinkresources - -import "fmt" - -const defaultApiVersion = "2021-01-11" - -func userAgent() string { - return fmt.Sprintf("pandora/privatelinkresources/%s", defaultApiVersion) -} diff --git a/internal/services/healthcare/sdk/2021-01-11/proxy/client.go b/internal/services/healthcare/sdk/2021-01-11/proxy/client.go deleted file mode 100644 index 6acefce56ad5..000000000000 --- a/internal/services/healthcare/sdk/2021-01-11/proxy/client.go +++ /dev/null @@ -1,15 +0,0 @@ -package proxy - -import "github.com/Azure/go-autorest/autorest" - -type ProxyClient struct { - Client autorest.Client - baseUri string -} - -func NewProxyClientWithBaseURI(endpoint string) ProxyClient { - return ProxyClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, - } -} diff --git a/internal/services/healthcare/sdk/2021-01-11/proxy/constants.go b/internal/services/healthcare/sdk/2021-01-11/proxy/constants.go deleted file mode 100644 index 6e0c4744ebfc..000000000000 --- a/internal/services/healthcare/sdk/2021-01-11/proxy/constants.go +++ /dev/null @@ -1,31 +0,0 @@ -package proxy - -import "strings" - -type ServiceNameUnavailabilityReason string - -const ( - ServiceNameUnavailabilityReasonAlreadyExists ServiceNameUnavailabilityReason = "AlreadyExists" - ServiceNameUnavailabilityReasonInvalid ServiceNameUnavailabilityReason = "Invalid" -) - -func PossibleValuesForServiceNameUnavailabilityReason() []string { - return []string{ - string(ServiceNameUnavailabilityReasonAlreadyExists), - string(ServiceNameUnavailabilityReasonInvalid), - } -} - -func parseServiceNameUnavailabilityReason(input string) (*ServiceNameUnavailabilityReason, error) { - vals := map[string]ServiceNameUnavailabilityReason{ - "alreadyexists": ServiceNameUnavailabilityReasonAlreadyExists, - "invalid": ServiceNameUnavailabilityReasonInvalid, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := ServiceNameUnavailabilityReason(input) - return &out, nil -} diff --git a/internal/services/healthcare/sdk/2021-01-11/proxy/method_serviceschecknameavailability_autorest.go b/internal/services/healthcare/sdk/2021-01-11/proxy/method_serviceschecknameavailability_autorest.go deleted file mode 100644 index b44d479fa8e6..000000000000 --- a/internal/services/healthcare/sdk/2021-01-11/proxy/method_serviceschecknameavailability_autorest.go +++ /dev/null @@ -1,67 +0,0 @@ -package proxy - -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" -) - -type ServicesCheckNameAvailabilityResponse struct { - HttpResponse *http.Response - Model *ServicesNameAvailabilityInfo -} - -// ServicesCheckNameAvailability ... -func (c ProxyClient) ServicesCheckNameAvailability(ctx context.Context, id commonids.SubscriptionId, input CheckNameAvailabilityParameters) (result ServicesCheckNameAvailabilityResponse, err error) { - req, err := c.preparerForServicesCheckNameAvailability(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "proxy.ProxyClient", "ServicesCheckNameAvailability", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "proxy.ProxyClient", "ServicesCheckNameAvailability", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForServicesCheckNameAvailability(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "proxy.ProxyClient", "ServicesCheckNameAvailability", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForServicesCheckNameAvailability prepares the ServicesCheckNameAvailability request. -func (c ProxyClient) preparerForServicesCheckNameAvailability(ctx context.Context, id commonids.SubscriptionId, input CheckNameAvailabilityParameters) (*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.HealthcareApis/checkNameAvailability", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForServicesCheckNameAvailability handles the response to the ServicesCheckNameAvailability request. The method always -// closes the http.Response Body. -func (c ProxyClient) responderForServicesCheckNameAvailability(resp *http.Response) (result ServicesCheckNameAvailabilityResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - return -} diff --git a/internal/services/healthcare/sdk/2021-01-11/proxy/model_checknameavailabilityparameters.go b/internal/services/healthcare/sdk/2021-01-11/proxy/model_checknameavailabilityparameters.go deleted file mode 100644 index 0759b12e6f95..000000000000 --- a/internal/services/healthcare/sdk/2021-01-11/proxy/model_checknameavailabilityparameters.go +++ /dev/null @@ -1,6 +0,0 @@ -package proxy - -type CheckNameAvailabilityParameters struct { - Name string `json:"name"` - Type string `json:"type"` -} diff --git a/internal/services/healthcare/sdk/2021-01-11/proxy/model_servicesnameavailabilityinfo.go b/internal/services/healthcare/sdk/2021-01-11/proxy/model_servicesnameavailabilityinfo.go deleted file mode 100644 index 1a5e4c9f2cfa..000000000000 --- a/internal/services/healthcare/sdk/2021-01-11/proxy/model_servicesnameavailabilityinfo.go +++ /dev/null @@ -1,7 +0,0 @@ -package proxy - -type ServicesNameAvailabilityInfo struct { - Message *string `json:"message,omitempty"` - NameAvailable *bool `json:"nameAvailable,omitempty"` - Reason *ServiceNameUnavailabilityReason `json:"reason,omitempty"` -} diff --git a/internal/services/healthcare/sdk/2021-01-11/proxy/version.go b/internal/services/healthcare/sdk/2021-01-11/proxy/version.go deleted file mode 100644 index 4f789019480e..000000000000 --- a/internal/services/healthcare/sdk/2021-01-11/proxy/version.go +++ /dev/null @@ -1,9 +0,0 @@ -package proxy - -import "fmt" - -const defaultApiVersion = "2021-01-11" - -func userAgent() string { - return fmt.Sprintf("pandora/proxy/%s", defaultApiVersion) -} diff --git a/internal/services/healthcare/sdk/2021-01-11/resource/client.go b/internal/services/healthcare/sdk/2021-01-11/resource/client.go deleted file mode 100644 index d9f8bbb20ce1..000000000000 --- a/internal/services/healthcare/sdk/2021-01-11/resource/client.go +++ /dev/null @@ -1,15 +0,0 @@ -package resource - -import "github.com/Azure/go-autorest/autorest" - -type ResourceClient struct { - Client autorest.Client - baseUri string -} - -func NewResourceClientWithBaseURI(endpoint string) ResourceClient { - return ResourceClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, - } -} diff --git a/internal/services/healthcare/sdk/2021-01-11/resource/constants.go b/internal/services/healthcare/sdk/2021-01-11/resource/constants.go deleted file mode 100644 index cf424b1eea1a..000000000000 --- a/internal/services/healthcare/sdk/2021-01-11/resource/constants.go +++ /dev/null @@ -1,210 +0,0 @@ -package resource - -import "strings" - -type CreatedByType string - -const ( - CreatedByTypeApplication CreatedByType = "Application" - CreatedByTypeKey CreatedByType = "Key" - CreatedByTypeManagedIdentity CreatedByType = "ManagedIdentity" - CreatedByTypeUser CreatedByType = "User" -) - -func PossibleValuesForCreatedByType() []string { - return []string{ - string(CreatedByTypeApplication), - string(CreatedByTypeKey), - string(CreatedByTypeManagedIdentity), - string(CreatedByTypeUser), - } -} - -func parseCreatedByType(input string) (*CreatedByType, error) { - vals := map[string]CreatedByType{ - "application": CreatedByTypeApplication, - "key": CreatedByTypeKey, - "managedidentity": CreatedByTypeManagedIdentity, - "user": CreatedByTypeUser, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := CreatedByType(input) - return &out, nil -} - -type Kind string - -const ( - KindFhir Kind = "fhir" - KindFhirNegativeRFour Kind = "fhir-R4" - KindFhirNegativeStuThree Kind = "fhir-Stu3" -) - -func PossibleValuesForKind() []string { - return []string{ - string(KindFhir), - string(KindFhirNegativeRFour), - string(KindFhirNegativeStuThree), - } -} - -func parseKind(input string) (*Kind, error) { - vals := map[string]Kind{ - "fhir": KindFhir, - "fhir-r4": KindFhirNegativeRFour, - "fhir-stu3": KindFhirNegativeStuThree, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := Kind(input) - return &out, nil -} - -type PrivateEndpointConnectionProvisioningState string - -const ( - PrivateEndpointConnectionProvisioningStateCreating PrivateEndpointConnectionProvisioningState = "Creating" - PrivateEndpointConnectionProvisioningStateDeleting PrivateEndpointConnectionProvisioningState = "Deleting" - PrivateEndpointConnectionProvisioningStateFailed PrivateEndpointConnectionProvisioningState = "Failed" - PrivateEndpointConnectionProvisioningStateSucceeded PrivateEndpointConnectionProvisioningState = "Succeeded" -) - -func PossibleValuesForPrivateEndpointConnectionProvisioningState() []string { - return []string{ - string(PrivateEndpointConnectionProvisioningStateCreating), - string(PrivateEndpointConnectionProvisioningStateDeleting), - string(PrivateEndpointConnectionProvisioningStateFailed), - string(PrivateEndpointConnectionProvisioningStateSucceeded), - } -} - -func parsePrivateEndpointConnectionProvisioningState(input string) (*PrivateEndpointConnectionProvisioningState, error) { - vals := map[string]PrivateEndpointConnectionProvisioningState{ - "creating": PrivateEndpointConnectionProvisioningStateCreating, - "deleting": PrivateEndpointConnectionProvisioningStateDeleting, - "failed": PrivateEndpointConnectionProvisioningStateFailed, - "succeeded": PrivateEndpointConnectionProvisioningStateSucceeded, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := PrivateEndpointConnectionProvisioningState(input) - return &out, nil -} - -type PrivateEndpointServiceConnectionStatus string - -const ( - PrivateEndpointServiceConnectionStatusApproved PrivateEndpointServiceConnectionStatus = "Approved" - PrivateEndpointServiceConnectionStatusPending PrivateEndpointServiceConnectionStatus = "Pending" - PrivateEndpointServiceConnectionStatusRejected PrivateEndpointServiceConnectionStatus = "Rejected" -) - -func PossibleValuesForPrivateEndpointServiceConnectionStatus() []string { - return []string{ - string(PrivateEndpointServiceConnectionStatusApproved), - string(PrivateEndpointServiceConnectionStatusPending), - string(PrivateEndpointServiceConnectionStatusRejected), - } -} - -func parsePrivateEndpointServiceConnectionStatus(input string) (*PrivateEndpointServiceConnectionStatus, error) { - vals := map[string]PrivateEndpointServiceConnectionStatus{ - "approved": PrivateEndpointServiceConnectionStatusApproved, - "pending": PrivateEndpointServiceConnectionStatusPending, - "rejected": PrivateEndpointServiceConnectionStatusRejected, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := PrivateEndpointServiceConnectionStatus(input) - return &out, nil -} - -type ProvisioningState string - -const ( - ProvisioningStateAccepted ProvisioningState = "Accepted" - ProvisioningStateCanceled ProvisioningState = "Canceled" - ProvisioningStateCreating ProvisioningState = "Creating" - ProvisioningStateDeleting ProvisioningState = "Deleting" - ProvisioningStateDeprovisioned ProvisioningState = "Deprovisioned" - ProvisioningStateFailed ProvisioningState = "Failed" - ProvisioningStateSucceeded ProvisioningState = "Succeeded" - ProvisioningStateUpdating ProvisioningState = "Updating" - ProvisioningStateVerifying ProvisioningState = "Verifying" -) - -func PossibleValuesForProvisioningState() []string { - return []string{ - string(ProvisioningStateAccepted), - string(ProvisioningStateCanceled), - string(ProvisioningStateCreating), - string(ProvisioningStateDeleting), - string(ProvisioningStateDeprovisioned), - string(ProvisioningStateFailed), - string(ProvisioningStateSucceeded), - string(ProvisioningStateUpdating), - string(ProvisioningStateVerifying), - } -} - -func parseProvisioningState(input string) (*ProvisioningState, error) { - vals := map[string]ProvisioningState{ - "accepted": ProvisioningStateAccepted, - "canceled": ProvisioningStateCanceled, - "creating": ProvisioningStateCreating, - "deleting": ProvisioningStateDeleting, - "deprovisioned": ProvisioningStateDeprovisioned, - "failed": ProvisioningStateFailed, - "succeeded": ProvisioningStateSucceeded, - "updating": ProvisioningStateUpdating, - "verifying": ProvisioningStateVerifying, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := ProvisioningState(input) - return &out, nil -} - -type PublicNetworkAccess string - -const ( - PublicNetworkAccessDisabled PublicNetworkAccess = "Disabled" - PublicNetworkAccessEnabled PublicNetworkAccess = "Enabled" -) - -func PossibleValuesForPublicNetworkAccess() []string { - return []string{ - string(PublicNetworkAccessDisabled), - string(PublicNetworkAccessEnabled), - } -} - -func parsePublicNetworkAccess(input string) (*PublicNetworkAccess, error) { - vals := map[string]PublicNetworkAccess{ - "disabled": PublicNetworkAccessDisabled, - "enabled": PublicNetworkAccessEnabled, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := PublicNetworkAccess(input) - return &out, nil -} diff --git a/internal/services/healthcare/sdk/2021-01-11/resource/id_service.go b/internal/services/healthcare/sdk/2021-01-11/resource/id_service.go deleted file mode 100644 index 89356f6a5a16..000000000000 --- a/internal/services/healthcare/sdk/2021-01-11/resource/id_service.go +++ /dev/null @@ -1,124 +0,0 @@ -package resource - -import ( - "fmt" - "strings" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -var _ resourceids.ResourceId = ServiceId{} - -// ServiceId is a struct representing the Resource ID for a Service -type ServiceId struct { - SubscriptionId string - ResourceGroupName string - ResourceName string -} - -// NewServiceID returns a new ServiceId struct -func NewServiceID(subscriptionId string, resourceGroupName string, resourceName string) ServiceId { - return ServiceId{ - SubscriptionId: subscriptionId, - ResourceGroupName: resourceGroupName, - ResourceName: resourceName, - } -} - -// ParseServiceID parses 'input' into a ServiceId -func ParseServiceID(input string) (*ServiceId, error) { - parser := resourceids.NewParserFromResourceIdType(ServiceId{}) - parsed, err := parser.Parse(input, false) - if err != nil { - return nil, fmt.Errorf("parsing %q: %+v", input, err) - } - - var ok bool - id := ServiceId{} - - if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { - return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) - } - - if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { - return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) - } - - if id.ResourceName, ok = parsed.Parsed["resourceName"]; !ok { - return nil, fmt.Errorf("the segment 'resourceName' was not found in the resource id %q", input) - } - - return &id, nil -} - -// ParseServiceIDInsensitively parses 'input' case-insensitively into a ServiceId -// note: this method should only be used for API response data and not user input -func ParseServiceIDInsensitively(input string) (*ServiceId, error) { - parser := resourceids.NewParserFromResourceIdType(ServiceId{}) - parsed, err := parser.Parse(input, true) - if err != nil { - return nil, fmt.Errorf("parsing %q: %+v", input, err) - } - - var ok bool - id := ServiceId{} - - if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { - return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) - } - - if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { - return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) - } - - if id.ResourceName, ok = parsed.Parsed["resourceName"]; !ok { - return nil, fmt.Errorf("the segment 'resourceName' was not found in the resource id %q", input) - } - - return &id, nil -} - -// ValidateServiceID checks that 'input' can be parsed as a Service ID -func ValidateServiceID(input interface{}, key string) (warnings []string, errors []error) { - v, ok := input.(string) - if !ok { - errors = append(errors, fmt.Errorf("expected %q to be a string", key)) - return - } - - if _, err := ParseServiceID(v); err != nil { - errors = append(errors, err) - } - - return -} - -// ID returns the formatted Service ID -func (id ServiceId) ID() string { - fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.HealthcareApis/services/%s" - return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ResourceName) -} - -// Segments returns a slice of Resource ID Segments which comprise this Service ID -func (id ServiceId) Segments() []resourceids.Segment { - return []resourceids.Segment{ - resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), - resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), - resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), - resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), - resourceids.StaticSegment("staticProviders", "providers", "providers"), - resourceids.ResourceProviderSegment("staticMicrosoftHealthcareApis", "Microsoft.HealthcareApis", "Microsoft.HealthcareApis"), - resourceids.StaticSegment("staticServices", "services", "services"), - resourceids.UserSpecifiedSegment("resourceName", "resourceValue"), - } -} - -// String returns a human-readable description of this Service ID -func (id ServiceId) String() string { - components := []string{ - fmt.Sprintf("Subscription: %q", id.SubscriptionId), - fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), - fmt.Sprintf("Resource Name: %q", id.ResourceName), - } - return fmt.Sprintf("Service (%s)", strings.Join(components, "\n")) -} diff --git a/internal/services/healthcare/sdk/2021-01-11/resource/id_service_test.go b/internal/services/healthcare/sdk/2021-01-11/resource/id_service_test.go deleted file mode 100644 index d10df20a6de0..000000000000 --- a/internal/services/healthcare/sdk/2021-01-11/resource/id_service_test.go +++ /dev/null @@ -1,279 +0,0 @@ -package resource - -import ( - "testing" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -var _ resourceids.ResourceId = ServiceId{} - -func TestNewServiceID(t *testing.T) { - id := NewServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "resourceValue") - - if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { - t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") - } - - if id.ResourceGroupName != "example-resource-group" { - t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") - } - - if id.ResourceName != "resourceValue" { - t.Fatalf("Expected %q but got %q for Segment 'ResourceName'", id.ResourceName, "resourceValue") - } -} - -func TestFormatServiceID(t *testing.T) { - actual := NewServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "resourceValue").ID() - expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/services/resourceValue" - if actual != expected { - t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) - } -} - -func TestParseServiceID(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *ServiceId - }{ - { - // Incomplete URI - Input: "", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/services", - Error: true, - }, - { - // Valid URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/services/resourceValue", - Expected: &ServiceId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "example-resource-group", - ResourceName: "resourceValue", - }, - }, - { - // Invalid (Valid Uri with Extra segment) - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/services/resourceValue/extra", - Error: true, - }, - } - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := ParseServiceID(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expect a value but got an error: %+v", err) - } - if v.Error { - t.Fatal("Expect an error but didn't get one") - } - - if actual.SubscriptionId != v.Expected.SubscriptionId { - t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) - } - - if actual.ResourceGroupName != v.Expected.ResourceGroupName { - t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) - } - - if actual.ResourceName != v.Expected.ResourceName { - t.Fatalf("Expected %q but got %q for ResourceName", v.Expected.ResourceName, actual.ResourceName) - } - - } -} - -func TestParseServiceIDInsensitively(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *ServiceId - }{ - { - // Incomplete URI - Input: "", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hEaLtHcArEaPiS", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/services", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hEaLtHcArEaPiS/sErViCeS", - Error: true, - }, - { - // Valid URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/services/resourceValue", - Expected: &ServiceId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "example-resource-group", - ResourceName: "resourceValue", - }, - }, - { - // Invalid (Valid Uri with Extra segment) - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/services/resourceValue/extra", - Error: true, - }, - { - // Valid URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hEaLtHcArEaPiS/sErViCeS/rEsOuRcEvAlUe", - Expected: &ServiceId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", - ResourceName: "rEsOuRcEvAlUe", - }, - }, - { - // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hEaLtHcArEaPiS/sErViCeS/rEsOuRcEvAlUe/extra", - Error: true, - }, - } - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := ParseServiceIDInsensitively(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expect a value but got an error: %+v", err) - } - if v.Error { - t.Fatal("Expect an error but didn't get one") - } - - if actual.SubscriptionId != v.Expected.SubscriptionId { - t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) - } - - if actual.ResourceGroupName != v.Expected.ResourceGroupName { - t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) - } - - if actual.ResourceName != v.Expected.ResourceName { - t.Fatalf("Expected %q but got %q for ResourceName", v.Expected.ResourceName, actual.ResourceName) - } - - } -} - -func TestSegmentsForServiceId(t *testing.T) { - segments := ServiceId{}.Segments() - if len(segments) == 0 { - t.Fatalf("ServiceId has no segments") - } - - uniqueNames := make(map[string]struct{}, 0) - for _, segment := range segments { - uniqueNames[segment.Name] = struct{}{} - } - if len(uniqueNames) != len(segments) { - t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) - } -} diff --git a/internal/services/healthcare/sdk/2021-01-11/resource/method_servicescreateorupdate_autorest.go b/internal/services/healthcare/sdk/2021-01-11/resource/method_servicescreateorupdate_autorest.go deleted file mode 100644 index 2f038ae8eecf..000000000000 --- a/internal/services/healthcare/sdk/2021-01-11/resource/method_servicescreateorupdate_autorest.go +++ /dev/null @@ -1,75 +0,0 @@ -package resource - -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" -) - -type ServicesCreateOrUpdateResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// ServicesCreateOrUpdate ... -func (c ResourceClient) ServicesCreateOrUpdate(ctx context.Context, id ServiceId, input ServicesDescription) (result ServicesCreateOrUpdateResponse, err error) { - req, err := c.preparerForServicesCreateOrUpdate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "resource.ResourceClient", "ServicesCreateOrUpdate", nil, "Failure preparing request") - return - } - - result, err = c.senderForServicesCreateOrUpdate(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "resource.ResourceClient", "ServicesCreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// ServicesCreateOrUpdateThenPoll performs ServicesCreateOrUpdate then polls until it's completed -func (c ResourceClient) ServicesCreateOrUpdateThenPoll(ctx context.Context, id ServiceId, input ServicesDescription) error { - result, err := c.ServicesCreateOrUpdate(ctx, id, input) - if err != nil { - return fmt.Errorf("performing ServicesCreateOrUpdate: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after ServicesCreateOrUpdate: %+v", err) - } - - return nil -} - -// preparerForServicesCreateOrUpdate prepares the ServicesCreateOrUpdate request. -func (c ResourceClient) preparerForServicesCreateOrUpdate(ctx context.Context, id ServiceId, input ServicesDescription) (*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)) -} - -// senderForServicesCreateOrUpdate sends the ServicesCreateOrUpdate request. The method will close the -// http.Response Body if it receives an error. -func (c ResourceClient) senderForServicesCreateOrUpdate(ctx context.Context, req *http.Request) (future ServicesCreateOrUpdateResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - future.Poller, err = polling.NewLongRunningPollerFromResponse(ctx, resp, c.Client) - return -} diff --git a/internal/services/healthcare/sdk/2021-01-11/resource/method_servicesdelete_autorest.go b/internal/services/healthcare/sdk/2021-01-11/resource/method_servicesdelete_autorest.go deleted file mode 100644 index dbe35e0b6207..000000000000 --- a/internal/services/healthcare/sdk/2021-01-11/resource/method_servicesdelete_autorest.go +++ /dev/null @@ -1,74 +0,0 @@ -package resource - -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" -) - -type ServicesDeleteResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// ServicesDelete ... -func (c ResourceClient) ServicesDelete(ctx context.Context, id ServiceId) (result ServicesDeleteResponse, err error) { - req, err := c.preparerForServicesDelete(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "resource.ResourceClient", "ServicesDelete", nil, "Failure preparing request") - return - } - - result, err = c.senderForServicesDelete(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "resource.ResourceClient", "ServicesDelete", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// ServicesDeleteThenPoll performs ServicesDelete then polls until it's completed -func (c ResourceClient) ServicesDeleteThenPoll(ctx context.Context, id ServiceId) error { - result, err := c.ServicesDelete(ctx, id) - if err != nil { - return fmt.Errorf("performing ServicesDelete: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after ServicesDelete: %+v", err) - } - - return nil -} - -// preparerForServicesDelete prepares the ServicesDelete request. -func (c ResourceClient) preparerForServicesDelete(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)) -} - -// senderForServicesDelete sends the ServicesDelete request. The method will close the -// http.Response Body if it receives an error. -func (c ResourceClient) senderForServicesDelete(ctx context.Context, req *http.Request) (future ServicesDeleteResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - future.Poller, err = polling.NewLongRunningPollerFromResponse(ctx, resp, c.Client) - return -} diff --git a/internal/services/healthcare/sdk/2021-01-11/resource/method_servicesget_autorest.go b/internal/services/healthcare/sdk/2021-01-11/resource/method_servicesget_autorest.go deleted file mode 100644 index 6bf9442cb8a1..000000000000 --- a/internal/services/healthcare/sdk/2021-01-11/resource/method_servicesget_autorest.go +++ /dev/null @@ -1,64 +0,0 @@ -package resource - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -type ServicesGetResponse struct { - HttpResponse *http.Response - Model *ServicesDescription -} - -// ServicesGet ... -func (c ResourceClient) ServicesGet(ctx context.Context, id ServiceId) (result ServicesGetResponse, err error) { - req, err := c.preparerForServicesGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "resource.ResourceClient", "ServicesGet", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "resource.ResourceClient", "ServicesGet", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForServicesGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "resource.ResourceClient", "ServicesGet", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForServicesGet prepares the ServicesGet request. -func (c ResourceClient) preparerForServicesGet(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)) -} - -// responderForServicesGet handles the response to the ServicesGet request. The method always -// closes the http.Response Body. -func (c ResourceClient) responderForServicesGet(resp *http.Response) (result ServicesGetResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - return -} diff --git a/internal/services/healthcare/sdk/2021-01-11/resource/method_servicesupdate_autorest.go b/internal/services/healthcare/sdk/2021-01-11/resource/method_servicesupdate_autorest.go deleted file mode 100644 index 9f8acc63f12a..000000000000 --- a/internal/services/healthcare/sdk/2021-01-11/resource/method_servicesupdate_autorest.go +++ /dev/null @@ -1,75 +0,0 @@ -package resource - -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" -) - -type ServicesUpdateResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// ServicesUpdate ... -func (c ResourceClient) ServicesUpdate(ctx context.Context, id ServiceId, input ServicesPatchDescription) (result ServicesUpdateResponse, err error) { - req, err := c.preparerForServicesUpdate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "resource.ResourceClient", "ServicesUpdate", nil, "Failure preparing request") - return - } - - result, err = c.senderForServicesUpdate(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "resource.ResourceClient", "ServicesUpdate", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// ServicesUpdateThenPoll performs ServicesUpdate then polls until it's completed -func (c ResourceClient) ServicesUpdateThenPoll(ctx context.Context, id ServiceId, input ServicesPatchDescription) error { - result, err := c.ServicesUpdate(ctx, id, input) - if err != nil { - return fmt.Errorf("performing ServicesUpdate: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after ServicesUpdate: %+v", err) - } - - return nil -} - -// preparerForServicesUpdate prepares the ServicesUpdate request. -func (c ResourceClient) preparerForServicesUpdate(ctx context.Context, id ServiceId, input ServicesPatchDescription) (*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)) -} - -// senderForServicesUpdate sends the ServicesUpdate request. The method will close the -// http.Response Body if it receives an error. -func (c ResourceClient) senderForServicesUpdate(ctx context.Context, req *http.Request) (future ServicesUpdateResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - future.Poller, err = polling.NewLongRunningPollerFromResponse(ctx, resp, c.Client) - return -} diff --git a/internal/services/healthcare/sdk/2021-01-11/resource/model_privateendpoint.go b/internal/services/healthcare/sdk/2021-01-11/resource/model_privateendpoint.go deleted file mode 100644 index 91d2298ebef4..000000000000 --- a/internal/services/healthcare/sdk/2021-01-11/resource/model_privateendpoint.go +++ /dev/null @@ -1,5 +0,0 @@ -package resource - -type PrivateEndpoint struct { - Id *string `json:"id,omitempty"` -} diff --git a/internal/services/healthcare/sdk/2021-01-11/resource/model_privateendpointconnection.go b/internal/services/healthcare/sdk/2021-01-11/resource/model_privateendpointconnection.go deleted file mode 100644 index 8a588e9071b9..000000000000 --- a/internal/services/healthcare/sdk/2021-01-11/resource/model_privateendpointconnection.go +++ /dev/null @@ -1,8 +0,0 @@ -package resource - -type PrivateEndpointConnection struct { - Id *string `json:"id,omitempty"` - Name *string `json:"name,omitempty"` - Properties *PrivateEndpointConnectionProperties `json:"properties,omitempty"` - Type *string `json:"type,omitempty"` -} diff --git a/internal/services/healthcare/sdk/2021-01-11/resource/model_privateendpointconnectionproperties.go b/internal/services/healthcare/sdk/2021-01-11/resource/model_privateendpointconnectionproperties.go deleted file mode 100644 index f2b79dce8bc5..000000000000 --- a/internal/services/healthcare/sdk/2021-01-11/resource/model_privateendpointconnectionproperties.go +++ /dev/null @@ -1,7 +0,0 @@ -package resource - -type PrivateEndpointConnectionProperties struct { - PrivateEndpoint *PrivateEndpoint `json:"privateEndpoint,omitempty"` - PrivateLinkServiceConnectionState PrivateLinkServiceConnectionState `json:"privateLinkServiceConnectionState"` - ProvisioningState *PrivateEndpointConnectionProvisioningState `json:"provisioningState,omitempty"` -} diff --git a/internal/services/healthcare/sdk/2021-01-11/resource/model_privatelinkserviceconnectionstate.go b/internal/services/healthcare/sdk/2021-01-11/resource/model_privatelinkserviceconnectionstate.go deleted file mode 100644 index 3617e3db806b..000000000000 --- a/internal/services/healthcare/sdk/2021-01-11/resource/model_privatelinkserviceconnectionstate.go +++ /dev/null @@ -1,7 +0,0 @@ -package resource - -type PrivateLinkServiceConnectionState struct { - ActionsRequired *string `json:"actionsRequired,omitempty"` - Description *string `json:"description,omitempty"` - Status *PrivateEndpointServiceConnectionStatus `json:"status,omitempty"` -} diff --git a/internal/services/healthcare/sdk/2021-01-11/resource/model_serviceaccesspolicyentry.go b/internal/services/healthcare/sdk/2021-01-11/resource/model_serviceaccesspolicyentry.go deleted file mode 100644 index bb7d73d7f581..000000000000 --- a/internal/services/healthcare/sdk/2021-01-11/resource/model_serviceaccesspolicyentry.go +++ /dev/null @@ -1,5 +0,0 @@ -package resource - -type ServiceAccessPolicyEntry struct { - ObjectId string `json:"objectId"` -} diff --git a/internal/services/healthcare/sdk/2021-01-11/resource/model_serviceacrconfigurationinfo.go b/internal/services/healthcare/sdk/2021-01-11/resource/model_serviceacrconfigurationinfo.go deleted file mode 100644 index 45d58c3f22c2..000000000000 --- a/internal/services/healthcare/sdk/2021-01-11/resource/model_serviceacrconfigurationinfo.go +++ /dev/null @@ -1,5 +0,0 @@ -package resource - -type ServiceAcrConfigurationInfo struct { - LoginServers *[]string `json:"loginServers,omitempty"` -} diff --git a/internal/services/healthcare/sdk/2021-01-11/resource/model_serviceauthenticationconfigurationinfo.go b/internal/services/healthcare/sdk/2021-01-11/resource/model_serviceauthenticationconfigurationinfo.go deleted file mode 100644 index b15aeecb91eb..000000000000 --- a/internal/services/healthcare/sdk/2021-01-11/resource/model_serviceauthenticationconfigurationinfo.go +++ /dev/null @@ -1,7 +0,0 @@ -package resource - -type ServiceAuthenticationConfigurationInfo struct { - Audience *string `json:"audience,omitempty"` - Authority *string `json:"authority,omitempty"` - SmartProxyEnabled *bool `json:"smartProxyEnabled,omitempty"` -} diff --git a/internal/services/healthcare/sdk/2021-01-11/resource/model_servicecorsconfigurationinfo.go b/internal/services/healthcare/sdk/2021-01-11/resource/model_servicecorsconfigurationinfo.go deleted file mode 100644 index 3222eb38f35f..000000000000 --- a/internal/services/healthcare/sdk/2021-01-11/resource/model_servicecorsconfigurationinfo.go +++ /dev/null @@ -1,9 +0,0 @@ -package resource - -type ServiceCorsConfigurationInfo struct { - AllowCredentials *bool `json:"allowCredentials,omitempty"` - Headers *[]string `json:"headers,omitempty"` - MaxAge *int64 `json:"maxAge,omitempty"` - Methods *[]string `json:"methods,omitempty"` - Origins *[]string `json:"origins,omitempty"` -} diff --git a/internal/services/healthcare/sdk/2021-01-11/resource/model_servicecosmosdbconfigurationinfo.go b/internal/services/healthcare/sdk/2021-01-11/resource/model_servicecosmosdbconfigurationinfo.go deleted file mode 100644 index bbdfe7992e43..000000000000 --- a/internal/services/healthcare/sdk/2021-01-11/resource/model_servicecosmosdbconfigurationinfo.go +++ /dev/null @@ -1,6 +0,0 @@ -package resource - -type ServiceCosmosDbConfigurationInfo struct { - KeyVaultKeyUri *string `json:"keyVaultKeyUri,omitempty"` - OfferThroughput *int64 `json:"offerThroughput,omitempty"` -} diff --git a/internal/services/healthcare/sdk/2021-01-11/resource/model_serviceexportconfigurationinfo.go b/internal/services/healthcare/sdk/2021-01-11/resource/model_serviceexportconfigurationinfo.go deleted file mode 100644 index 35ea1dbe59c1..000000000000 --- a/internal/services/healthcare/sdk/2021-01-11/resource/model_serviceexportconfigurationinfo.go +++ /dev/null @@ -1,5 +0,0 @@ -package resource - -type ServiceExportConfigurationInfo struct { - StorageAccountName *string `json:"storageAccountName,omitempty"` -} diff --git a/internal/services/healthcare/sdk/2021-01-11/resource/model_servicesdescription.go b/internal/services/healthcare/sdk/2021-01-11/resource/model_servicesdescription.go deleted file mode 100644 index 94364d8f618b..000000000000 --- a/internal/services/healthcare/sdk/2021-01-11/resource/model_servicesdescription.go +++ /dev/null @@ -1,18 +0,0 @@ -package resource - -import ( - "github.com/hashicorp/go-azure-helpers/resourcemanager/identity" -) - -type ServicesDescription struct { - Etag *string `json:"etag,omitempty"` - Id *string `json:"id,omitempty"` - Identity *identity.SystemAssigned `json:"identity,omitempty"` - Kind Kind `json:"kind"` - Location string `json:"location"` - Name *string `json:"name,omitempty"` - Properties *ServicesProperties `json:"properties,omitempty"` - SystemData *SystemData `json:"systemData,omitempty"` - Tags *map[string]string `json:"tags,omitempty"` - Type *string `json:"type,omitempty"` -} diff --git a/internal/services/healthcare/sdk/2021-01-11/resource/model_servicespatchdescription.go b/internal/services/healthcare/sdk/2021-01-11/resource/model_servicespatchdescription.go deleted file mode 100644 index d1bcdfe6c558..000000000000 --- a/internal/services/healthcare/sdk/2021-01-11/resource/model_servicespatchdescription.go +++ /dev/null @@ -1,6 +0,0 @@ -package resource - -type ServicesPatchDescription struct { - Properties *ServicesPropertiesUpdateParameters `json:"properties,omitempty"` - Tags *map[string]string `json:"tags,omitempty"` -} diff --git a/internal/services/healthcare/sdk/2021-01-11/resource/model_servicesproperties.go b/internal/services/healthcare/sdk/2021-01-11/resource/model_servicesproperties.go deleted file mode 100644 index 83dd58e7f604..000000000000 --- a/internal/services/healthcare/sdk/2021-01-11/resource/model_servicesproperties.go +++ /dev/null @@ -1,13 +0,0 @@ -package resource - -type ServicesProperties struct { - AccessPolicies *[]ServiceAccessPolicyEntry `json:"accessPolicies,omitempty"` - AcrConfiguration *ServiceAcrConfigurationInfo `json:"acrConfiguration,omitempty"` - AuthenticationConfiguration *ServiceAuthenticationConfigurationInfo `json:"authenticationConfiguration,omitempty"` - CorsConfiguration *ServiceCorsConfigurationInfo `json:"corsConfiguration,omitempty"` - CosmosDbConfiguration *ServiceCosmosDbConfigurationInfo `json:"cosmosDbConfiguration,omitempty"` - ExportConfiguration *ServiceExportConfigurationInfo `json:"exportConfiguration,omitempty"` - PrivateEndpointConnections *[]PrivateEndpointConnection `json:"privateEndpointConnections,omitempty"` - ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` - PublicNetworkAccess *PublicNetworkAccess `json:"publicNetworkAccess,omitempty"` -} diff --git a/internal/services/healthcare/sdk/2021-01-11/resource/model_servicespropertiesupdateparameters.go b/internal/services/healthcare/sdk/2021-01-11/resource/model_servicespropertiesupdateparameters.go deleted file mode 100644 index bdee5e5622b7..000000000000 --- a/internal/services/healthcare/sdk/2021-01-11/resource/model_servicespropertiesupdateparameters.go +++ /dev/null @@ -1,5 +0,0 @@ -package resource - -type ServicesPropertiesUpdateParameters struct { - PublicNetworkAccess *PublicNetworkAccess `json:"publicNetworkAccess,omitempty"` -} diff --git a/internal/services/healthcare/sdk/2021-01-11/resource/model_systemdata.go b/internal/services/healthcare/sdk/2021-01-11/resource/model_systemdata.go deleted file mode 100644 index 8d282622850b..000000000000 --- a/internal/services/healthcare/sdk/2021-01-11/resource/model_systemdata.go +++ /dev/null @@ -1,40 +0,0 @@ -package resource - -import ( - "time" - - "github.com/hashicorp/go-azure-helpers/lang/dates" -) - -type SystemData struct { - CreatedAt *string `json:"createdAt,omitempty"` - CreatedBy *string `json:"createdBy,omitempty"` - CreatedByType *CreatedByType `json:"createdByType,omitempty"` - LastModifiedAt *string `json:"lastModifiedAt,omitempty"` - LastModifiedBy *string `json:"lastModifiedBy,omitempty"` - LastModifiedByType *CreatedByType `json:"lastModifiedByType,omitempty"` -} - -func (o SystemData) GetCreatedAtAsTime() (*time.Time, error) { - if o.CreatedAt == nil { - return nil, nil - } - return dates.ParseAsFormat(o.CreatedAt, "2006-01-02T15:04:05Z07:00") -} - -func (o SystemData) SetCreatedAtAsTime(input time.Time) { - formatted := input.Format("2006-01-02T15:04:05Z07:00") - o.CreatedAt = &formatted -} - -func (o SystemData) GetLastModifiedAtAsTime() (*time.Time, error) { - if o.LastModifiedAt == nil { - return nil, nil - } - return dates.ParseAsFormat(o.LastModifiedAt, "2006-01-02T15:04:05Z07:00") -} - -func (o SystemData) SetLastModifiedAtAsTime(input time.Time) { - formatted := input.Format("2006-01-02T15:04:05Z07:00") - o.LastModifiedAt = &formatted -} diff --git a/internal/services/healthcare/sdk/2021-01-11/resource/version.go b/internal/services/healthcare/sdk/2021-01-11/resource/version.go deleted file mode 100644 index 368219e151ef..000000000000 --- a/internal/services/healthcare/sdk/2021-01-11/resource/version.go +++ /dev/null @@ -1,9 +0,0 @@ -package resource - -import "fmt" - -const defaultApiVersion = "2021-01-11" - -func userAgent() string { - return fmt.Sprintf("pandora/resource/%s", defaultApiVersion) -} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/collection/client.go b/internal/services/healthcare/sdk/2021-06-01-preview/collection/client.go deleted file mode 100644 index 9c73b5b57183..000000000000 --- a/internal/services/healthcare/sdk/2021-06-01-preview/collection/client.go +++ /dev/null @@ -1,15 +0,0 @@ -package collection - -import "github.com/Azure/go-autorest/autorest" - -type CollectionClient struct { - Client autorest.Client - baseUri string -} - -func NewCollectionClientWithBaseURI(endpoint string) CollectionClient { - return CollectionClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, - } -} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/collection/constants.go b/internal/services/healthcare/sdk/2021-06-01-preview/collection/constants.go deleted file mode 100644 index b26711c9a119..000000000000 --- a/internal/services/healthcare/sdk/2021-06-01-preview/collection/constants.go +++ /dev/null @@ -1,210 +0,0 @@ -package collection - -import "strings" - -type CreatedByType string - -const ( - CreatedByTypeApplication CreatedByType = "Application" - CreatedByTypeKey CreatedByType = "Key" - CreatedByTypeManagedIdentity CreatedByType = "ManagedIdentity" - CreatedByTypeUser CreatedByType = "User" -) - -func PossibleValuesForCreatedByType() []string { - return []string{ - string(CreatedByTypeApplication), - string(CreatedByTypeKey), - string(CreatedByTypeManagedIdentity), - string(CreatedByTypeUser), - } -} - -func parseCreatedByType(input string) (*CreatedByType, error) { - vals := map[string]CreatedByType{ - "application": CreatedByTypeApplication, - "key": CreatedByTypeKey, - "managedidentity": CreatedByTypeManagedIdentity, - "user": CreatedByTypeUser, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := CreatedByType(input) - return &out, nil -} - -type Kind string - -const ( - KindFhir Kind = "fhir" - KindFhirNegativeRFour Kind = "fhir-R4" - KindFhirNegativeStuThree Kind = "fhir-Stu3" -) - -func PossibleValuesForKind() []string { - return []string{ - string(KindFhir), - string(KindFhirNegativeRFour), - string(KindFhirNegativeStuThree), - } -} - -func parseKind(input string) (*Kind, error) { - vals := map[string]Kind{ - "fhir": KindFhir, - "fhir-r4": KindFhirNegativeRFour, - "fhir-stu3": KindFhirNegativeStuThree, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := Kind(input) - return &out, nil -} - -type PrivateEndpointConnectionProvisioningState string - -const ( - PrivateEndpointConnectionProvisioningStateCreating PrivateEndpointConnectionProvisioningState = "Creating" - PrivateEndpointConnectionProvisioningStateDeleting PrivateEndpointConnectionProvisioningState = "Deleting" - PrivateEndpointConnectionProvisioningStateFailed PrivateEndpointConnectionProvisioningState = "Failed" - PrivateEndpointConnectionProvisioningStateSucceeded PrivateEndpointConnectionProvisioningState = "Succeeded" -) - -func PossibleValuesForPrivateEndpointConnectionProvisioningState() []string { - return []string{ - string(PrivateEndpointConnectionProvisioningStateCreating), - string(PrivateEndpointConnectionProvisioningStateDeleting), - string(PrivateEndpointConnectionProvisioningStateFailed), - string(PrivateEndpointConnectionProvisioningStateSucceeded), - } -} - -func parsePrivateEndpointConnectionProvisioningState(input string) (*PrivateEndpointConnectionProvisioningState, error) { - vals := map[string]PrivateEndpointConnectionProvisioningState{ - "creating": PrivateEndpointConnectionProvisioningStateCreating, - "deleting": PrivateEndpointConnectionProvisioningStateDeleting, - "failed": PrivateEndpointConnectionProvisioningStateFailed, - "succeeded": PrivateEndpointConnectionProvisioningStateSucceeded, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := PrivateEndpointConnectionProvisioningState(input) - return &out, nil -} - -type PrivateEndpointServiceConnectionStatus string - -const ( - PrivateEndpointServiceConnectionStatusApproved PrivateEndpointServiceConnectionStatus = "Approved" - PrivateEndpointServiceConnectionStatusPending PrivateEndpointServiceConnectionStatus = "Pending" - PrivateEndpointServiceConnectionStatusRejected PrivateEndpointServiceConnectionStatus = "Rejected" -) - -func PossibleValuesForPrivateEndpointServiceConnectionStatus() []string { - return []string{ - string(PrivateEndpointServiceConnectionStatusApproved), - string(PrivateEndpointServiceConnectionStatusPending), - string(PrivateEndpointServiceConnectionStatusRejected), - } -} - -func parsePrivateEndpointServiceConnectionStatus(input string) (*PrivateEndpointServiceConnectionStatus, error) { - vals := map[string]PrivateEndpointServiceConnectionStatus{ - "approved": PrivateEndpointServiceConnectionStatusApproved, - "pending": PrivateEndpointServiceConnectionStatusPending, - "rejected": PrivateEndpointServiceConnectionStatusRejected, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := PrivateEndpointServiceConnectionStatus(input) - return &out, nil -} - -type ProvisioningState string - -const ( - ProvisioningStateAccepted ProvisioningState = "Accepted" - ProvisioningStateCanceled ProvisioningState = "Canceled" - ProvisioningStateCreating ProvisioningState = "Creating" - ProvisioningStateDeleting ProvisioningState = "Deleting" - ProvisioningStateDeprovisioned ProvisioningState = "Deprovisioned" - ProvisioningStateFailed ProvisioningState = "Failed" - ProvisioningStateSucceeded ProvisioningState = "Succeeded" - ProvisioningStateUpdating ProvisioningState = "Updating" - ProvisioningStateVerifying ProvisioningState = "Verifying" -) - -func PossibleValuesForProvisioningState() []string { - return []string{ - string(ProvisioningStateAccepted), - string(ProvisioningStateCanceled), - string(ProvisioningStateCreating), - string(ProvisioningStateDeleting), - string(ProvisioningStateDeprovisioned), - string(ProvisioningStateFailed), - string(ProvisioningStateSucceeded), - string(ProvisioningStateUpdating), - string(ProvisioningStateVerifying), - } -} - -func parseProvisioningState(input string) (*ProvisioningState, error) { - vals := map[string]ProvisioningState{ - "accepted": ProvisioningStateAccepted, - "canceled": ProvisioningStateCanceled, - "creating": ProvisioningStateCreating, - "deleting": ProvisioningStateDeleting, - "deprovisioned": ProvisioningStateDeprovisioned, - "failed": ProvisioningStateFailed, - "succeeded": ProvisioningStateSucceeded, - "updating": ProvisioningStateUpdating, - "verifying": ProvisioningStateVerifying, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := ProvisioningState(input) - return &out, nil -} - -type PublicNetworkAccess string - -const ( - PublicNetworkAccessDisabled PublicNetworkAccess = "Disabled" - PublicNetworkAccessEnabled PublicNetworkAccess = "Enabled" -) - -func PossibleValuesForPublicNetworkAccess() []string { - return []string{ - string(PublicNetworkAccessDisabled), - string(PublicNetworkAccessEnabled), - } -} - -func parsePublicNetworkAccess(input string) (*PublicNetworkAccess, error) { - vals := map[string]PublicNetworkAccess{ - "disabled": PublicNetworkAccessDisabled, - "enabled": PublicNetworkAccessEnabled, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := PublicNetworkAccess(input) - return &out, nil -} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/collection/method_serviceslist_autorest.go b/internal/services/healthcare/sdk/2021-06-01-preview/collection/method_serviceslist_autorest.go deleted file mode 100644 index 43106463a451..000000000000 --- a/internal/services/healthcare/sdk/2021-06-01-preview/collection/method_serviceslist_autorest.go +++ /dev/null @@ -1,184 +0,0 @@ -package collection - -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" -) - -type ServicesListResponse struct { - HttpResponse *http.Response - Model *[]ServicesDescription - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ServicesListResponse, error) -} - -type ServicesListCompleteResult struct { - Items []ServicesDescription -} - -func (r ServicesListResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ServicesListResponse) LoadMore(ctx context.Context) (resp ServicesListResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ServicesList ... -func (c CollectionClient) ServicesList(ctx context.Context, id commonids.SubscriptionId) (resp ServicesListResponse, err error) { - req, err := c.preparerForServicesList(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "collection.CollectionClient", "ServicesList", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "collection.CollectionClient", "ServicesList", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForServicesList(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "collection.CollectionClient", "ServicesList", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// ServicesListComplete retrieves all of the results into a single object -func (c CollectionClient) ServicesListComplete(ctx context.Context, id commonids.SubscriptionId) (ServicesListCompleteResult, error) { - return c.ServicesListCompleteMatchingPredicate(ctx, id, ServicesDescriptionPredicate{}) -} - -// ServicesListCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c CollectionClient) ServicesListCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate ServicesDescriptionPredicate) (resp ServicesListCompleteResult, err error) { - items := make([]ServicesDescription, 0) - - page, err := c.ServicesList(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 := ServicesListCompleteResult{ - Items: items, - } - return out, nil -} - -// preparerForServicesList prepares the ServicesList request. -func (c CollectionClient) preparerForServicesList(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.HealthcareApis/services", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForServicesListWithNextLink prepares the ServicesList request with the given nextLink token. -func (c CollectionClient) preparerForServicesListWithNextLink(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)) -} - -// responderForServicesList handles the response to the ServicesList request. The method always -// closes the http.Response Body. -func (c CollectionClient) responderForServicesList(resp *http.Response) (result ServicesListResponse, err error) { - type page struct { - Values []ServicesDescription `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 ServicesListResponse, err error) { - req, err := c.preparerForServicesListWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "collection.CollectionClient", "ServicesList", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "collection.CollectionClient", "ServicesList", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForServicesList(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "collection.CollectionClient", "ServicesList", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/collection/method_serviceslistbyresourcegroup_autorest.go b/internal/services/healthcare/sdk/2021-06-01-preview/collection/method_serviceslistbyresourcegroup_autorest.go deleted file mode 100644 index b57331bf1292..000000000000 --- a/internal/services/healthcare/sdk/2021-06-01-preview/collection/method_serviceslistbyresourcegroup_autorest.go +++ /dev/null @@ -1,184 +0,0 @@ -package collection - -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" -) - -type ServicesListByResourceGroupResponse struct { - HttpResponse *http.Response - Model *[]ServicesDescription - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ServicesListByResourceGroupResponse, error) -} - -type ServicesListByResourceGroupCompleteResult struct { - Items []ServicesDescription -} - -func (r ServicesListByResourceGroupResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ServicesListByResourceGroupResponse) LoadMore(ctx context.Context) (resp ServicesListByResourceGroupResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ServicesListByResourceGroup ... -func (c CollectionClient) ServicesListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (resp ServicesListByResourceGroupResponse, err error) { - req, err := c.preparerForServicesListByResourceGroup(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "collection.CollectionClient", "ServicesListByResourceGroup", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "collection.CollectionClient", "ServicesListByResourceGroup", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForServicesListByResourceGroup(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "collection.CollectionClient", "ServicesListByResourceGroup", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// ServicesListByResourceGroupComplete retrieves all of the results into a single object -func (c CollectionClient) ServicesListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (ServicesListByResourceGroupCompleteResult, error) { - return c.ServicesListByResourceGroupCompleteMatchingPredicate(ctx, id, ServicesDescriptionPredicate{}) -} - -// ServicesListByResourceGroupCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c CollectionClient) ServicesListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate ServicesDescriptionPredicate) (resp ServicesListByResourceGroupCompleteResult, err error) { - items := make([]ServicesDescription, 0) - - page, err := c.ServicesListByResourceGroup(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 := ServicesListByResourceGroupCompleteResult{ - Items: items, - } - return out, nil -} - -// preparerForServicesListByResourceGroup prepares the ServicesListByResourceGroup request. -func (c CollectionClient) preparerForServicesListByResourceGroup(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.HealthcareApis/services", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForServicesListByResourceGroupWithNextLink prepares the ServicesListByResourceGroup request with the given nextLink token. -func (c CollectionClient) preparerForServicesListByResourceGroupWithNextLink(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)) -} - -// responderForServicesListByResourceGroup handles the response to the ServicesListByResourceGroup request. The method always -// closes the http.Response Body. -func (c CollectionClient) responderForServicesListByResourceGroup(resp *http.Response) (result ServicesListByResourceGroupResponse, err error) { - type page struct { - Values []ServicesDescription `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 ServicesListByResourceGroupResponse, err error) { - req, err := c.preparerForServicesListByResourceGroupWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "collection.CollectionClient", "ServicesListByResourceGroup", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "collection.CollectionClient", "ServicesListByResourceGroup", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForServicesListByResourceGroup(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "collection.CollectionClient", "ServicesListByResourceGroup", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/collection/model_privateendpoint.go b/internal/services/healthcare/sdk/2021-06-01-preview/collection/model_privateendpoint.go deleted file mode 100644 index 4fbaafd6baef..000000000000 --- a/internal/services/healthcare/sdk/2021-06-01-preview/collection/model_privateendpoint.go +++ /dev/null @@ -1,5 +0,0 @@ -package collection - -type PrivateEndpoint struct { - Id *string `json:"id,omitempty"` -} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/collection/model_privateendpointconnection.go b/internal/services/healthcare/sdk/2021-06-01-preview/collection/model_privateendpointconnection.go deleted file mode 100644 index bb27ca23f744..000000000000 --- a/internal/services/healthcare/sdk/2021-06-01-preview/collection/model_privateendpointconnection.go +++ /dev/null @@ -1,8 +0,0 @@ -package collection - -type PrivateEndpointConnection struct { - Id *string `json:"id,omitempty"` - Name *string `json:"name,omitempty"` - Properties *PrivateEndpointConnectionProperties `json:"properties,omitempty"` - Type *string `json:"type,omitempty"` -} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/collection/model_privateendpointconnectionproperties.go b/internal/services/healthcare/sdk/2021-06-01-preview/collection/model_privateendpointconnectionproperties.go deleted file mode 100644 index 4610ed7818db..000000000000 --- a/internal/services/healthcare/sdk/2021-06-01-preview/collection/model_privateendpointconnectionproperties.go +++ /dev/null @@ -1,7 +0,0 @@ -package collection - -type PrivateEndpointConnectionProperties struct { - PrivateEndpoint *PrivateEndpoint `json:"privateEndpoint,omitempty"` - PrivateLinkServiceConnectionState PrivateLinkServiceConnectionState `json:"privateLinkServiceConnectionState"` - ProvisioningState *PrivateEndpointConnectionProvisioningState `json:"provisioningState,omitempty"` -} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/collection/model_privatelinkserviceconnectionstate.go b/internal/services/healthcare/sdk/2021-06-01-preview/collection/model_privatelinkserviceconnectionstate.go deleted file mode 100644 index fe6619d2e5b3..000000000000 --- a/internal/services/healthcare/sdk/2021-06-01-preview/collection/model_privatelinkserviceconnectionstate.go +++ /dev/null @@ -1,7 +0,0 @@ -package collection - -type PrivateLinkServiceConnectionState struct { - ActionsRequired *string `json:"actionsRequired,omitempty"` - Description *string `json:"description,omitempty"` - Status *PrivateEndpointServiceConnectionStatus `json:"status,omitempty"` -} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/collection/model_serviceaccesspolicyentry.go b/internal/services/healthcare/sdk/2021-06-01-preview/collection/model_serviceaccesspolicyentry.go deleted file mode 100644 index 788b9abe36c4..000000000000 --- a/internal/services/healthcare/sdk/2021-06-01-preview/collection/model_serviceaccesspolicyentry.go +++ /dev/null @@ -1,5 +0,0 @@ -package collection - -type ServiceAccessPolicyEntry struct { - ObjectId string `json:"objectId"` -} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/collection/model_serviceacrconfigurationinfo.go b/internal/services/healthcare/sdk/2021-06-01-preview/collection/model_serviceacrconfigurationinfo.go deleted file mode 100644 index e6aba5385d12..000000000000 --- a/internal/services/healthcare/sdk/2021-06-01-preview/collection/model_serviceacrconfigurationinfo.go +++ /dev/null @@ -1,5 +0,0 @@ -package collection - -type ServiceAcrConfigurationInfo struct { - LoginServers *[]string `json:"loginServers,omitempty"` -} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/collection/model_serviceauthenticationconfigurationinfo.go b/internal/services/healthcare/sdk/2021-06-01-preview/collection/model_serviceauthenticationconfigurationinfo.go deleted file mode 100644 index 817440eddd27..000000000000 --- a/internal/services/healthcare/sdk/2021-06-01-preview/collection/model_serviceauthenticationconfigurationinfo.go +++ /dev/null @@ -1,7 +0,0 @@ -package collection - -type ServiceAuthenticationConfigurationInfo struct { - Audience *string `json:"audience,omitempty"` - Authority *string `json:"authority,omitempty"` - SmartProxyEnabled *bool `json:"smartProxyEnabled,omitempty"` -} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/collection/model_servicecorsconfigurationinfo.go b/internal/services/healthcare/sdk/2021-06-01-preview/collection/model_servicecorsconfigurationinfo.go deleted file mode 100644 index c8c1e73b44ad..000000000000 --- a/internal/services/healthcare/sdk/2021-06-01-preview/collection/model_servicecorsconfigurationinfo.go +++ /dev/null @@ -1,9 +0,0 @@ -package collection - -type ServiceCorsConfigurationInfo struct { - AllowCredentials *bool `json:"allowCredentials,omitempty"` - Headers *[]string `json:"headers,omitempty"` - MaxAge *int64 `json:"maxAge,omitempty"` - Methods *[]string `json:"methods,omitempty"` - Origins *[]string `json:"origins,omitempty"` -} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/collection/model_servicecosmosdbconfigurationinfo.go b/internal/services/healthcare/sdk/2021-06-01-preview/collection/model_servicecosmosdbconfigurationinfo.go deleted file mode 100644 index eec76c56a531..000000000000 --- a/internal/services/healthcare/sdk/2021-06-01-preview/collection/model_servicecosmosdbconfigurationinfo.go +++ /dev/null @@ -1,6 +0,0 @@ -package collection - -type ServiceCosmosDbConfigurationInfo struct { - KeyVaultKeyUri *string `json:"keyVaultKeyUri,omitempty"` - OfferThroughput *int64 `json:"offerThroughput,omitempty"` -} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/collection/model_serviceexportconfigurationinfo.go b/internal/services/healthcare/sdk/2021-06-01-preview/collection/model_serviceexportconfigurationinfo.go deleted file mode 100644 index eee5a8843e2b..000000000000 --- a/internal/services/healthcare/sdk/2021-06-01-preview/collection/model_serviceexportconfigurationinfo.go +++ /dev/null @@ -1,5 +0,0 @@ -package collection - -type ServiceExportConfigurationInfo struct { - StorageAccountName *string `json:"storageAccountName,omitempty"` -} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/collection/model_servicesdescription.go b/internal/services/healthcare/sdk/2021-06-01-preview/collection/model_servicesdescription.go deleted file mode 100644 index 0571a820794e..000000000000 --- a/internal/services/healthcare/sdk/2021-06-01-preview/collection/model_servicesdescription.go +++ /dev/null @@ -1,18 +0,0 @@ -package collection - -import ( - "github.com/hashicorp/go-azure-helpers/resourcemanager/identity" -) - -type ServicesDescription struct { - Etag *string `json:"etag,omitempty"` - Id *string `json:"id,omitempty"` - Identity *identity.SystemAssigned `json:"identity,omitempty"` - Kind Kind `json:"kind"` - Location string `json:"location"` - Name *string `json:"name,omitempty"` - Properties *ServicesProperties `json:"properties,omitempty"` - SystemData *SystemData `json:"systemData,omitempty"` - Tags *map[string]string `json:"tags,omitempty"` - Type *string `json:"type,omitempty"` -} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/collection/model_servicesproperties.go b/internal/services/healthcare/sdk/2021-06-01-preview/collection/model_servicesproperties.go deleted file mode 100644 index aa60431aa653..000000000000 --- a/internal/services/healthcare/sdk/2021-06-01-preview/collection/model_servicesproperties.go +++ /dev/null @@ -1,13 +0,0 @@ -package collection - -type ServicesProperties struct { - AccessPolicies *[]ServiceAccessPolicyEntry `json:"accessPolicies,omitempty"` - AcrConfiguration *ServiceAcrConfigurationInfo `json:"acrConfiguration,omitempty"` - AuthenticationConfiguration *ServiceAuthenticationConfigurationInfo `json:"authenticationConfiguration,omitempty"` - CorsConfiguration *ServiceCorsConfigurationInfo `json:"corsConfiguration,omitempty"` - CosmosDbConfiguration *ServiceCosmosDbConfigurationInfo `json:"cosmosDbConfiguration,omitempty"` - ExportConfiguration *ServiceExportConfigurationInfo `json:"exportConfiguration,omitempty"` - PrivateEndpointConnections *[]PrivateEndpointConnection `json:"privateEndpointConnections,omitempty"` - ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` - PublicNetworkAccess *PublicNetworkAccess `json:"publicNetworkAccess,omitempty"` -} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/collection/model_systemdata.go b/internal/services/healthcare/sdk/2021-06-01-preview/collection/model_systemdata.go deleted file mode 100644 index a8361db52cda..000000000000 --- a/internal/services/healthcare/sdk/2021-06-01-preview/collection/model_systemdata.go +++ /dev/null @@ -1,40 +0,0 @@ -package collection - -import ( - "time" - - "github.com/hashicorp/go-azure-helpers/lang/dates" -) - -type SystemData struct { - CreatedAt *string `json:"createdAt,omitempty"` - CreatedBy *string `json:"createdBy,omitempty"` - CreatedByType *CreatedByType `json:"createdByType,omitempty"` - LastModifiedAt *string `json:"lastModifiedAt,omitempty"` - LastModifiedBy *string `json:"lastModifiedBy,omitempty"` - LastModifiedByType *CreatedByType `json:"lastModifiedByType,omitempty"` -} - -func (o SystemData) GetCreatedAtAsTime() (*time.Time, error) { - if o.CreatedAt == nil { - return nil, nil - } - return dates.ParseAsFormat(o.CreatedAt, "2006-01-02T15:04:05Z07:00") -} - -func (o SystemData) SetCreatedAtAsTime(input time.Time) { - formatted := input.Format("2006-01-02T15:04:05Z07:00") - o.CreatedAt = &formatted -} - -func (o SystemData) GetLastModifiedAtAsTime() (*time.Time, error) { - if o.LastModifiedAt == nil { - return nil, nil - } - return dates.ParseAsFormat(o.LastModifiedAt, "2006-01-02T15:04:05Z07:00") -} - -func (o SystemData) SetLastModifiedAtAsTime(input time.Time) { - formatted := input.Format("2006-01-02T15:04:05Z07:00") - o.LastModifiedAt = &formatted -} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/collection/predicates.go b/internal/services/healthcare/sdk/2021-06-01-preview/collection/predicates.go deleted file mode 100644 index b62be96254a8..000000000000 --- a/internal/services/healthcare/sdk/2021-06-01-preview/collection/predicates.go +++ /dev/null @@ -1,34 +0,0 @@ -package collection - -type ServicesDescriptionPredicate struct { - Etag *string - Id *string - Location *string - Name *string - Type *string -} - -func (p ServicesDescriptionPredicate) Matches(input ServicesDescription) bool { - - if p.Etag != nil && (input.Etag == nil && *p.Etag != *input.Etag) { - return false - } - - if p.Id != nil && (input.Id == nil && *p.Id != *input.Id) { - return false - } - - if p.Location != nil && *p.Location != input.Location { - return false - } - - if p.Name != nil && (input.Name == nil && *p.Name != *input.Name) { - return false - } - - if p.Type != nil && (input.Type == nil && *p.Type != *input.Type) { - return false - } - - return true -} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/collection/version.go b/internal/services/healthcare/sdk/2021-06-01-preview/collection/version.go deleted file mode 100644 index 239a2aed75d6..000000000000 --- a/internal/services/healthcare/sdk/2021-06-01-preview/collection/version.go +++ /dev/null @@ -1,9 +0,0 @@ -package collection - -import "fmt" - -const defaultApiVersion = "2021-06-01-preview" - -func userAgent() string { - return fmt.Sprintf("pandora/collection/%s", defaultApiVersion) -} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/dicomservices/client.go b/internal/services/healthcare/sdk/2021-06-01-preview/dicomservices/client.go deleted file mode 100644 index f28417b70643..000000000000 --- a/internal/services/healthcare/sdk/2021-06-01-preview/dicomservices/client.go +++ /dev/null @@ -1,15 +0,0 @@ -package dicomservices - -import "github.com/Azure/go-autorest/autorest" - -type DicomServicesClient struct { - Client autorest.Client - baseUri string -} - -func NewDicomServicesClientWithBaseURI(endpoint string) DicomServicesClient { - return DicomServicesClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, - } -} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/dicomservices/constants.go b/internal/services/healthcare/sdk/2021-06-01-preview/dicomservices/constants.go deleted file mode 100644 index d717e5afcf42..000000000000 --- a/internal/services/healthcare/sdk/2021-06-01-preview/dicomservices/constants.go +++ /dev/null @@ -1,98 +0,0 @@ -package dicomservices - -import "strings" - -type CreatedByType string - -const ( - CreatedByTypeApplication CreatedByType = "Application" - CreatedByTypeKey CreatedByType = "Key" - CreatedByTypeManagedIdentity CreatedByType = "ManagedIdentity" - CreatedByTypeUser CreatedByType = "User" -) - -func PossibleValuesForCreatedByType() []string { - return []string{ - string(CreatedByTypeApplication), - string(CreatedByTypeKey), - string(CreatedByTypeManagedIdentity), - string(CreatedByTypeUser), - } -} - -func parseCreatedByType(input string) (*CreatedByType, error) { - vals := map[string]CreatedByType{ - "application": CreatedByTypeApplication, - "key": CreatedByTypeKey, - "managedidentity": CreatedByTypeManagedIdentity, - "user": CreatedByTypeUser, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := CreatedByType(input) - return &out, nil -} - -type ProvisioningState string - -const ( - ProvisioningStateAccepted ProvisioningState = "Accepted" - ProvisioningStateCanceled ProvisioningState = "Canceled" - ProvisioningStateCreating ProvisioningState = "Creating" - ProvisioningStateDeleting ProvisioningState = "Deleting" - ProvisioningStateDeprovisioned ProvisioningState = "Deprovisioned" - ProvisioningStateFailed ProvisioningState = "Failed" - ProvisioningStateMoving ProvisioningState = "Moving" - ProvisioningStateSucceeded ProvisioningState = "Succeeded" - ProvisioningStateSuspended ProvisioningState = "Suspended" - ProvisioningStateSystemMaintenance ProvisioningState = "SystemMaintenance" - ProvisioningStateUpdating ProvisioningState = "Updating" - ProvisioningStateVerifying ProvisioningState = "Verifying" - ProvisioningStateWarned ProvisioningState = "Warned" -) - -func PossibleValuesForProvisioningState() []string { - return []string{ - string(ProvisioningStateAccepted), - string(ProvisioningStateCanceled), - string(ProvisioningStateCreating), - string(ProvisioningStateDeleting), - string(ProvisioningStateDeprovisioned), - string(ProvisioningStateFailed), - string(ProvisioningStateMoving), - string(ProvisioningStateSucceeded), - string(ProvisioningStateSuspended), - string(ProvisioningStateSystemMaintenance), - string(ProvisioningStateUpdating), - string(ProvisioningStateVerifying), - string(ProvisioningStateWarned), - } -} - -func parseProvisioningState(input string) (*ProvisioningState, error) { - vals := map[string]ProvisioningState{ - "accepted": ProvisioningStateAccepted, - "canceled": ProvisioningStateCanceled, - "creating": ProvisioningStateCreating, - "deleting": ProvisioningStateDeleting, - "deprovisioned": ProvisioningStateDeprovisioned, - "failed": ProvisioningStateFailed, - "moving": ProvisioningStateMoving, - "succeeded": ProvisioningStateSucceeded, - "suspended": ProvisioningStateSuspended, - "systemmaintenance": ProvisioningStateSystemMaintenance, - "updating": ProvisioningStateUpdating, - "verifying": ProvisioningStateVerifying, - "warned": ProvisioningStateWarned, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := ProvisioningState(input) - return &out, nil -} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/dicomservices/id_dicomservice.go b/internal/services/healthcare/sdk/2021-06-01-preview/dicomservices/id_dicomservice.go deleted file mode 100644 index 02bbcd1b3322..000000000000 --- a/internal/services/healthcare/sdk/2021-06-01-preview/dicomservices/id_dicomservice.go +++ /dev/null @@ -1,137 +0,0 @@ -package dicomservices - -import ( - "fmt" - "strings" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -var _ resourceids.ResourceId = DicomServiceId{} - -// DicomServiceId is a struct representing the Resource ID for a Dicom Service -type DicomServiceId struct { - SubscriptionId string - ResourceGroupName string - WorkspaceName string - DicomServiceName string -} - -// NewDicomServiceID returns a new DicomServiceId struct -func NewDicomServiceID(subscriptionId string, resourceGroupName string, workspaceName string, dicomServiceName string) DicomServiceId { - return DicomServiceId{ - SubscriptionId: subscriptionId, - ResourceGroupName: resourceGroupName, - WorkspaceName: workspaceName, - DicomServiceName: dicomServiceName, - } -} - -// ParseDicomServiceID parses 'input' into a DicomServiceId -func ParseDicomServiceID(input string) (*DicomServiceId, error) { - parser := resourceids.NewParserFromResourceIdType(DicomServiceId{}) - parsed, err := parser.Parse(input, false) - if err != nil { - return nil, fmt.Errorf("parsing %q: %+v", input, err) - } - - var ok bool - id := DicomServiceId{} - - if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { - return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) - } - - if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { - return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) - } - - if id.WorkspaceName, ok = parsed.Parsed["workspaceName"]; !ok { - return nil, fmt.Errorf("the segment 'workspaceName' was not found in the resource id %q", input) - } - - if id.DicomServiceName, ok = parsed.Parsed["dicomServiceName"]; !ok { - return nil, fmt.Errorf("the segment 'dicomServiceName' was not found in the resource id %q", input) - } - - return &id, nil -} - -// ParseDicomServiceIDInsensitively parses 'input' case-insensitively into a DicomServiceId -// note: this method should only be used for API response data and not user input -func ParseDicomServiceIDInsensitively(input string) (*DicomServiceId, error) { - parser := resourceids.NewParserFromResourceIdType(DicomServiceId{}) - parsed, err := parser.Parse(input, true) - if err != nil { - return nil, fmt.Errorf("parsing %q: %+v", input, err) - } - - var ok bool - id := DicomServiceId{} - - if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { - return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) - } - - if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { - return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) - } - - if id.WorkspaceName, ok = parsed.Parsed["workspaceName"]; !ok { - return nil, fmt.Errorf("the segment 'workspaceName' was not found in the resource id %q", input) - } - - if id.DicomServiceName, ok = parsed.Parsed["dicomServiceName"]; !ok { - return nil, fmt.Errorf("the segment 'dicomServiceName' was not found in the resource id %q", input) - } - - return &id, nil -} - -// ValidateDicomServiceID checks that 'input' can be parsed as a Dicom Service ID -func ValidateDicomServiceID(input interface{}, key string) (warnings []string, errors []error) { - v, ok := input.(string) - if !ok { - errors = append(errors, fmt.Errorf("expected %q to be a string", key)) - return - } - - if _, err := ParseDicomServiceID(v); err != nil { - errors = append(errors, err) - } - - return -} - -// ID returns the formatted Dicom Service ID -func (id DicomServiceId) ID() string { - fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.HealthcareApis/workspaces/%s/dicomServices/%s" - return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.WorkspaceName, id.DicomServiceName) -} - -// Segments returns a slice of Resource ID Segments which comprise this Dicom Service ID -func (id DicomServiceId) Segments() []resourceids.Segment { - return []resourceids.Segment{ - resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), - resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), - resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), - resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), - resourceids.StaticSegment("staticProviders", "providers", "providers"), - resourceids.ResourceProviderSegment("staticMicrosoftHealthcareApis", "Microsoft.HealthcareApis", "Microsoft.HealthcareApis"), - resourceids.StaticSegment("staticWorkspaces", "workspaces", "workspaces"), - resourceids.UserSpecifiedSegment("workspaceName", "workspaceValue"), - resourceids.StaticSegment("staticDicomServices", "dicomServices", "dicomServices"), - resourceids.UserSpecifiedSegment("dicomServiceName", "dicomServiceValue"), - } -} - -// String returns a human-readable description of this Dicom Service ID -func (id DicomServiceId) String() string { - components := []string{ - fmt.Sprintf("Subscription: %q", id.SubscriptionId), - fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), - fmt.Sprintf("Workspace Name: %q", id.WorkspaceName), - fmt.Sprintf("Dicom Service Name: %q", id.DicomServiceName), - } - return fmt.Sprintf("Dicom Service (%s)", strings.Join(components, "\n")) -} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/dicomservices/id_dicomservice_test.go b/internal/services/healthcare/sdk/2021-06-01-preview/dicomservices/id_dicomservice_test.go deleted file mode 100644 index 2ea7f0c98c99..000000000000 --- a/internal/services/healthcare/sdk/2021-06-01-preview/dicomservices/id_dicomservice_test.go +++ /dev/null @@ -1,324 +0,0 @@ -package dicomservices - -import ( - "testing" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -var _ resourceids.ResourceId = DicomServiceId{} - -func TestNewDicomServiceID(t *testing.T) { - id := NewDicomServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceValue", "dicomServiceValue") - - if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { - t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") - } - - if id.ResourceGroupName != "example-resource-group" { - t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") - } - - if id.WorkspaceName != "workspaceValue" { - t.Fatalf("Expected %q but got %q for Segment 'WorkspaceName'", id.WorkspaceName, "workspaceValue") - } - - if id.DicomServiceName != "dicomServiceValue" { - t.Fatalf("Expected %q but got %q for Segment 'DicomServiceName'", id.DicomServiceName, "dicomServiceValue") - } -} - -func TestFormatDicomServiceID(t *testing.T) { - actual := NewDicomServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceValue", "dicomServiceValue").ID() - expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/workspaces/workspaceValue/dicomServices/dicomServiceValue" - if actual != expected { - t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) - } -} - -func TestParseDicomServiceID(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *DicomServiceId - }{ - { - // Incomplete URI - Input: "", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/workspaces", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/workspaces/workspaceValue", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/workspaces/workspaceValue/dicomServices", - Error: true, - }, - { - // Valid URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/workspaces/workspaceValue/dicomServices/dicomServiceValue", - Expected: &DicomServiceId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "example-resource-group", - WorkspaceName: "workspaceValue", - DicomServiceName: "dicomServiceValue", - }, - }, - { - // Invalid (Valid Uri with Extra segment) - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/workspaces/workspaceValue/dicomServices/dicomServiceValue/extra", - Error: true, - }, - } - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := ParseDicomServiceID(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expect a value but got an error: %+v", err) - } - if v.Error { - t.Fatal("Expect an error but didn't get one") - } - - if actual.SubscriptionId != v.Expected.SubscriptionId { - t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) - } - - if actual.ResourceGroupName != v.Expected.ResourceGroupName { - t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) - } - - if actual.WorkspaceName != v.Expected.WorkspaceName { - t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) - } - - if actual.DicomServiceName != v.Expected.DicomServiceName { - t.Fatalf("Expected %q but got %q for DicomServiceName", v.Expected.DicomServiceName, actual.DicomServiceName) - } - - } -} - -func TestParseDicomServiceIDInsensitively(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *DicomServiceId - }{ - { - // Incomplete URI - Input: "", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hEaLtHcArEaPiS", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/workspaces", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hEaLtHcArEaPiS/wOrKsPaCeS", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/workspaces/workspaceValue", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hEaLtHcArEaPiS/wOrKsPaCeS/wOrKsPaCeVaLuE", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/workspaces/workspaceValue/dicomServices", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hEaLtHcArEaPiS/wOrKsPaCeS/wOrKsPaCeVaLuE/dIcOmSeRvIcEs", - Error: true, - }, - { - // Valid URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/workspaces/workspaceValue/dicomServices/dicomServiceValue", - Expected: &DicomServiceId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "example-resource-group", - WorkspaceName: "workspaceValue", - DicomServiceName: "dicomServiceValue", - }, - }, - { - // Invalid (Valid Uri with Extra segment) - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/workspaces/workspaceValue/dicomServices/dicomServiceValue/extra", - Error: true, - }, - { - // Valid URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hEaLtHcArEaPiS/wOrKsPaCeS/wOrKsPaCeVaLuE/dIcOmSeRvIcEs/dIcOmSeRvIcEvAlUe", - Expected: &DicomServiceId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", - WorkspaceName: "wOrKsPaCeVaLuE", - DicomServiceName: "dIcOmSeRvIcEvAlUe", - }, - }, - { - // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hEaLtHcArEaPiS/wOrKsPaCeS/wOrKsPaCeVaLuE/dIcOmSeRvIcEs/dIcOmSeRvIcEvAlUe/extra", - Error: true, - }, - } - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := ParseDicomServiceIDInsensitively(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expect a value but got an error: %+v", err) - } - if v.Error { - t.Fatal("Expect an error but didn't get one") - } - - if actual.SubscriptionId != v.Expected.SubscriptionId { - t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) - } - - if actual.ResourceGroupName != v.Expected.ResourceGroupName { - t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) - } - - if actual.WorkspaceName != v.Expected.WorkspaceName { - t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) - } - - if actual.DicomServiceName != v.Expected.DicomServiceName { - t.Fatalf("Expected %q but got %q for DicomServiceName", v.Expected.DicomServiceName, actual.DicomServiceName) - } - - } -} - -func TestSegmentsForDicomServiceId(t *testing.T) { - segments := DicomServiceId{}.Segments() - if len(segments) == 0 { - t.Fatalf("DicomServiceId has no segments") - } - - uniqueNames := make(map[string]struct{}, 0) - for _, segment := range segments { - uniqueNames[segment.Name] = struct{}{} - } - if len(uniqueNames) != len(segments) { - t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) - } -} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/dicomservices/id_workspace.go b/internal/services/healthcare/sdk/2021-06-01-preview/dicomservices/id_workspace.go deleted file mode 100644 index cce75d91dddb..000000000000 --- a/internal/services/healthcare/sdk/2021-06-01-preview/dicomservices/id_workspace.go +++ /dev/null @@ -1,124 +0,0 @@ -package dicomservices - -import ( - "fmt" - "strings" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -var _ resourceids.ResourceId = WorkspaceId{} - -// WorkspaceId is a struct representing the Resource ID for a Workspace -type WorkspaceId struct { - SubscriptionId string - ResourceGroupName string - WorkspaceName string -} - -// NewWorkspaceID returns a new WorkspaceId struct -func NewWorkspaceID(subscriptionId string, resourceGroupName string, workspaceName string) WorkspaceId { - return WorkspaceId{ - SubscriptionId: subscriptionId, - ResourceGroupName: resourceGroupName, - WorkspaceName: workspaceName, - } -} - -// ParseWorkspaceID parses 'input' into a WorkspaceId -func ParseWorkspaceID(input string) (*WorkspaceId, error) { - parser := resourceids.NewParserFromResourceIdType(WorkspaceId{}) - parsed, err := parser.Parse(input, false) - if err != nil { - return nil, fmt.Errorf("parsing %q: %+v", input, err) - } - - var ok bool - id := WorkspaceId{} - - if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { - return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) - } - - if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { - return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) - } - - if id.WorkspaceName, ok = parsed.Parsed["workspaceName"]; !ok { - return nil, fmt.Errorf("the segment 'workspaceName' was not found in the resource id %q", input) - } - - return &id, nil -} - -// ParseWorkspaceIDInsensitively parses 'input' case-insensitively into a WorkspaceId -// note: this method should only be used for API response data and not user input -func ParseWorkspaceIDInsensitively(input string) (*WorkspaceId, error) { - parser := resourceids.NewParserFromResourceIdType(WorkspaceId{}) - parsed, err := parser.Parse(input, true) - if err != nil { - return nil, fmt.Errorf("parsing %q: %+v", input, err) - } - - var ok bool - id := WorkspaceId{} - - if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { - return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) - } - - if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { - return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) - } - - if id.WorkspaceName, ok = parsed.Parsed["workspaceName"]; !ok { - return nil, fmt.Errorf("the segment 'workspaceName' was not found in the resource id %q", input) - } - - return &id, nil -} - -// ValidateWorkspaceID checks that 'input' can be parsed as a Workspace ID -func ValidateWorkspaceID(input interface{}, key string) (warnings []string, errors []error) { - v, ok := input.(string) - if !ok { - errors = append(errors, fmt.Errorf("expected %q to be a string", key)) - return - } - - if _, err := ParseWorkspaceID(v); err != nil { - errors = append(errors, err) - } - - return -} - -// ID returns the formatted Workspace ID -func (id WorkspaceId) ID() string { - fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.HealthcareApis/workspaces/%s" - return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.WorkspaceName) -} - -// Segments returns a slice of Resource ID Segments which comprise this Workspace ID -func (id WorkspaceId) Segments() []resourceids.Segment { - return []resourceids.Segment{ - resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), - resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), - resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), - resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), - resourceids.StaticSegment("staticProviders", "providers", "providers"), - resourceids.ResourceProviderSegment("staticMicrosoftHealthcareApis", "Microsoft.HealthcareApis", "Microsoft.HealthcareApis"), - resourceids.StaticSegment("staticWorkspaces", "workspaces", "workspaces"), - resourceids.UserSpecifiedSegment("workspaceName", "workspaceValue"), - } -} - -// String returns a human-readable description of this Workspace ID -func (id WorkspaceId) String() string { - components := []string{ - fmt.Sprintf("Subscription: %q", id.SubscriptionId), - fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), - fmt.Sprintf("Workspace Name: %q", id.WorkspaceName), - } - return fmt.Sprintf("Workspace (%s)", strings.Join(components, "\n")) -} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/dicomservices/id_workspace_test.go b/internal/services/healthcare/sdk/2021-06-01-preview/dicomservices/id_workspace_test.go deleted file mode 100644 index 1d85dcbe025f..000000000000 --- a/internal/services/healthcare/sdk/2021-06-01-preview/dicomservices/id_workspace_test.go +++ /dev/null @@ -1,279 +0,0 @@ -package dicomservices - -import ( - "testing" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -var _ resourceids.ResourceId = WorkspaceId{} - -func TestNewWorkspaceID(t *testing.T) { - id := NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceValue") - - if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { - t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") - } - - if id.ResourceGroupName != "example-resource-group" { - t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") - } - - if id.WorkspaceName != "workspaceValue" { - t.Fatalf("Expected %q but got %q for Segment 'WorkspaceName'", id.WorkspaceName, "workspaceValue") - } -} - -func TestFormatWorkspaceID(t *testing.T) { - actual := NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceValue").ID() - expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/workspaces/workspaceValue" - if actual != expected { - t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) - } -} - -func TestParseWorkspaceID(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *WorkspaceId - }{ - { - // Incomplete URI - Input: "", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/workspaces", - Error: true, - }, - { - // Valid URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/workspaces/workspaceValue", - Expected: &WorkspaceId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "example-resource-group", - WorkspaceName: "workspaceValue", - }, - }, - { - // Invalid (Valid Uri with Extra segment) - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/workspaces/workspaceValue/extra", - Error: true, - }, - } - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := ParseWorkspaceID(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expect a value but got an error: %+v", err) - } - if v.Error { - t.Fatal("Expect an error but didn't get one") - } - - if actual.SubscriptionId != v.Expected.SubscriptionId { - t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) - } - - if actual.ResourceGroupName != v.Expected.ResourceGroupName { - t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) - } - - if actual.WorkspaceName != v.Expected.WorkspaceName { - t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) - } - - } -} - -func TestParseWorkspaceIDInsensitively(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *WorkspaceId - }{ - { - // Incomplete URI - Input: "", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hEaLtHcArEaPiS", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/workspaces", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hEaLtHcArEaPiS/wOrKsPaCeS", - Error: true, - }, - { - // Valid URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/workspaces/workspaceValue", - Expected: &WorkspaceId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "example-resource-group", - WorkspaceName: "workspaceValue", - }, - }, - { - // Invalid (Valid Uri with Extra segment) - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/workspaces/workspaceValue/extra", - Error: true, - }, - { - // Valid URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hEaLtHcArEaPiS/wOrKsPaCeS/wOrKsPaCeVaLuE", - Expected: &WorkspaceId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", - WorkspaceName: "wOrKsPaCeVaLuE", - }, - }, - { - // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hEaLtHcArEaPiS/wOrKsPaCeS/wOrKsPaCeVaLuE/extra", - Error: true, - }, - } - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := ParseWorkspaceIDInsensitively(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expect a value but got an error: %+v", err) - } - if v.Error { - t.Fatal("Expect an error but didn't get one") - } - - if actual.SubscriptionId != v.Expected.SubscriptionId { - t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) - } - - if actual.ResourceGroupName != v.Expected.ResourceGroupName { - t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) - } - - if actual.WorkspaceName != v.Expected.WorkspaceName { - t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) - } - - } -} - -func TestSegmentsForWorkspaceId(t *testing.T) { - segments := WorkspaceId{}.Segments() - if len(segments) == 0 { - t.Fatalf("WorkspaceId has no segments") - } - - uniqueNames := make(map[string]struct{}, 0) - for _, segment := range segments { - uniqueNames[segment.Name] = struct{}{} - } - if len(uniqueNames) != len(segments) { - t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) - } -} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/dicomservices/method_createorupdate_autorest.go b/internal/services/healthcare/sdk/2021-06-01-preview/dicomservices/method_createorupdate_autorest.go deleted file mode 100644 index 3e5b6eeda9cc..000000000000 --- a/internal/services/healthcare/sdk/2021-06-01-preview/dicomservices/method_createorupdate_autorest.go +++ /dev/null @@ -1,75 +0,0 @@ -package dicomservices - -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" -) - -type CreateOrUpdateResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// CreateOrUpdate ... -func (c DicomServicesClient) CreateOrUpdate(ctx context.Context, id DicomServiceId, input DicomService) (result CreateOrUpdateResponse, err error) { - req, err := c.preparerForCreateOrUpdate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "dicomservices.DicomServicesClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result, err = c.senderForCreateOrUpdate(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "dicomservices.DicomServicesClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed -func (c DicomServicesClient) CreateOrUpdateThenPoll(ctx context.Context, id DicomServiceId, input DicomService) 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 DicomServicesClient) preparerForCreateOrUpdate(ctx context.Context, id DicomServiceId, input DicomService) (*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 DicomServicesClient) senderForCreateOrUpdate(ctx context.Context, req *http.Request) (future CreateOrUpdateResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - future.Poller, err = polling.NewLongRunningPollerFromResponse(ctx, resp, c.Client) - return -} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/dicomservices/method_delete_autorest.go b/internal/services/healthcare/sdk/2021-06-01-preview/dicomservices/method_delete_autorest.go deleted file mode 100644 index f68d272b8339..000000000000 --- a/internal/services/healthcare/sdk/2021-06-01-preview/dicomservices/method_delete_autorest.go +++ /dev/null @@ -1,74 +0,0 @@ -package dicomservices - -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" -) - -type DeleteResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// Delete ... -func (c DicomServicesClient) Delete(ctx context.Context, id DicomServiceId) (result DeleteResponse, err error) { - req, err := c.preparerForDelete(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "dicomservices.DicomServicesClient", "Delete", nil, "Failure preparing request") - return - } - - result, err = c.senderForDelete(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "dicomservices.DicomServicesClient", "Delete", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// DeleteThenPoll performs Delete then polls until it's completed -func (c DicomServicesClient) DeleteThenPoll(ctx context.Context, id DicomServiceId) 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 DicomServicesClient) preparerForDelete(ctx context.Context, id DicomServiceId) (*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 DicomServicesClient) senderForDelete(ctx context.Context, req *http.Request) (future DeleteResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - future.Poller, err = polling.NewLongRunningPollerFromResponse(ctx, resp, c.Client) - return -} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/dicomservices/method_get_autorest.go b/internal/services/healthcare/sdk/2021-06-01-preview/dicomservices/method_get_autorest.go deleted file mode 100644 index 9d7252dedec2..000000000000 --- a/internal/services/healthcare/sdk/2021-06-01-preview/dicomservices/method_get_autorest.go +++ /dev/null @@ -1,64 +0,0 @@ -package dicomservices - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -type GetResponse struct { - HttpResponse *http.Response - Model *DicomService -} - -// Get ... -func (c DicomServicesClient) Get(ctx context.Context, id DicomServiceId) (result GetResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "dicomservices.DicomServicesClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "dicomservices.DicomServicesClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "dicomservices.DicomServicesClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c DicomServicesClient) preparerForGet(ctx context.Context, id DicomServiceId) (*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 DicomServicesClient) responderForGet(resp *http.Response) (result GetResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - return -} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/dicomservices/method_listbyworkspace_autorest.go b/internal/services/healthcare/sdk/2021-06-01-preview/dicomservices/method_listbyworkspace_autorest.go deleted file mode 100644 index 978262b2923c..000000000000 --- a/internal/services/healthcare/sdk/2021-06-01-preview/dicomservices/method_listbyworkspace_autorest.go +++ /dev/null @@ -1,183 +0,0 @@ -package dicomservices - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -type ListByWorkspaceResponse struct { - HttpResponse *http.Response - Model *[]DicomService - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListByWorkspaceResponse, error) -} - -type ListByWorkspaceCompleteResult struct { - Items []DicomService -} - -func (r ListByWorkspaceResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListByWorkspaceResponse) LoadMore(ctx context.Context) (resp ListByWorkspaceResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListByWorkspace ... -func (c DicomServicesClient) ListByWorkspace(ctx context.Context, id WorkspaceId) (resp ListByWorkspaceResponse, err error) { - req, err := c.preparerForListByWorkspace(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "dicomservices.DicomServicesClient", "ListByWorkspace", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "dicomservices.DicomServicesClient", "ListByWorkspace", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListByWorkspace(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "dicomservices.DicomServicesClient", "ListByWorkspace", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// ListByWorkspaceComplete retrieves all of the results into a single object -func (c DicomServicesClient) ListByWorkspaceComplete(ctx context.Context, id WorkspaceId) (ListByWorkspaceCompleteResult, error) { - return c.ListByWorkspaceCompleteMatchingPredicate(ctx, id, DicomServicePredicate{}) -} - -// ListByWorkspaceCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c DicomServicesClient) ListByWorkspaceCompleteMatchingPredicate(ctx context.Context, id WorkspaceId, predicate DicomServicePredicate) (resp ListByWorkspaceCompleteResult, err error) { - items := make([]DicomService, 0) - - page, err := c.ListByWorkspace(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 := ListByWorkspaceCompleteResult{ - Items: items, - } - return out, nil -} - -// preparerForListByWorkspace prepares the ListByWorkspace request. -func (c DicomServicesClient) preparerForListByWorkspace(ctx context.Context, id WorkspaceId) (*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/dicomServices", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListByWorkspaceWithNextLink prepares the ListByWorkspace request with the given nextLink token. -func (c DicomServicesClient) preparerForListByWorkspaceWithNextLink(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)) -} - -// responderForListByWorkspace handles the response to the ListByWorkspace request. The method always -// closes the http.Response Body. -func (c DicomServicesClient) responderForListByWorkspace(resp *http.Response) (result ListByWorkspaceResponse, err error) { - type page struct { - Values []DicomService `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 ListByWorkspaceResponse, err error) { - req, err := c.preparerForListByWorkspaceWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "dicomservices.DicomServicesClient", "ListByWorkspace", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "dicomservices.DicomServicesClient", "ListByWorkspace", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByWorkspace(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "dicomservices.DicomServicesClient", "ListByWorkspace", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/dicomservices/method_update_autorest.go b/internal/services/healthcare/sdk/2021-06-01-preview/dicomservices/method_update_autorest.go deleted file mode 100644 index c62715bcf985..000000000000 --- a/internal/services/healthcare/sdk/2021-06-01-preview/dicomservices/method_update_autorest.go +++ /dev/null @@ -1,75 +0,0 @@ -package dicomservices - -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" -) - -type UpdateResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// Update ... -func (c DicomServicesClient) Update(ctx context.Context, id DicomServiceId, input ResourceTags) (result UpdateResponse, err error) { - req, err := c.preparerForUpdate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "dicomservices.DicomServicesClient", "Update", nil, "Failure preparing request") - return - } - - result, err = c.senderForUpdate(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "dicomservices.DicomServicesClient", "Update", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// UpdateThenPoll performs Update then polls until it's completed -func (c DicomServicesClient) UpdateThenPoll(ctx context.Context, id DicomServiceId, input ResourceTags) 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 DicomServicesClient) preparerForUpdate(ctx context.Context, id DicomServiceId, input ResourceTags) (*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 DicomServicesClient) senderForUpdate(ctx context.Context, req *http.Request) (future UpdateResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - future.Poller, err = polling.NewLongRunningPollerFromResponse(ctx, resp, c.Client) - return -} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/dicomservices/model_dicomservice.go b/internal/services/healthcare/sdk/2021-06-01-preview/dicomservices/model_dicomservice.go deleted file mode 100644 index d48dc717ca59..000000000000 --- a/internal/services/healthcare/sdk/2021-06-01-preview/dicomservices/model_dicomservice.go +++ /dev/null @@ -1,12 +0,0 @@ -package dicomservices - -type DicomService struct { - Etag *string `json:"etag,omitempty"` - Id *string `json:"id,omitempty"` - Location *string `json:"location,omitempty"` - Name *string `json:"name,omitempty"` - Properties *DicomServiceProperties `json:"properties,omitempty"` - SystemData *SystemData `json:"systemData,omitempty"` - Tags *map[string]string `json:"tags,omitempty"` - Type *string `json:"type,omitempty"` -} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/dicomservices/model_dicomserviceauthenticationconfiguration.go b/internal/services/healthcare/sdk/2021-06-01-preview/dicomservices/model_dicomserviceauthenticationconfiguration.go deleted file mode 100644 index e1c559253e2a..000000000000 --- a/internal/services/healthcare/sdk/2021-06-01-preview/dicomservices/model_dicomserviceauthenticationconfiguration.go +++ /dev/null @@ -1,6 +0,0 @@ -package dicomservices - -type DicomServiceAuthenticationConfiguration struct { - Audiences *[]string `json:"audiences,omitempty"` - Authority *string `json:"authority,omitempty"` -} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/dicomservices/model_dicomserviceproperties.go b/internal/services/healthcare/sdk/2021-06-01-preview/dicomservices/model_dicomserviceproperties.go deleted file mode 100644 index b55a89d50d5c..000000000000 --- a/internal/services/healthcare/sdk/2021-06-01-preview/dicomservices/model_dicomserviceproperties.go +++ /dev/null @@ -1,7 +0,0 @@ -package dicomservices - -type DicomServiceProperties struct { - AuthenticationConfiguration *DicomServiceAuthenticationConfiguration `json:"authenticationConfiguration,omitempty"` - ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` - ServiceUrl *string `json:"serviceUrl,omitempty"` -} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/dicomservices/model_resourcetags.go b/internal/services/healthcare/sdk/2021-06-01-preview/dicomservices/model_resourcetags.go deleted file mode 100644 index 0b836f1bcd4d..000000000000 --- a/internal/services/healthcare/sdk/2021-06-01-preview/dicomservices/model_resourcetags.go +++ /dev/null @@ -1,5 +0,0 @@ -package dicomservices - -type ResourceTags struct { - Tags *map[string]string `json:"tags,omitempty"` -} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/dicomservices/model_systemdata.go b/internal/services/healthcare/sdk/2021-06-01-preview/dicomservices/model_systemdata.go deleted file mode 100644 index cfe11a5037b6..000000000000 --- a/internal/services/healthcare/sdk/2021-06-01-preview/dicomservices/model_systemdata.go +++ /dev/null @@ -1,40 +0,0 @@ -package dicomservices - -import ( - "time" - - "github.com/hashicorp/go-azure-helpers/lang/dates" -) - -type SystemData struct { - CreatedAt *string `json:"createdAt,omitempty"` - CreatedBy *string `json:"createdBy,omitempty"` - CreatedByType *CreatedByType `json:"createdByType,omitempty"` - LastModifiedAt *string `json:"lastModifiedAt,omitempty"` - LastModifiedBy *string `json:"lastModifiedBy,omitempty"` - LastModifiedByType *CreatedByType `json:"lastModifiedByType,omitempty"` -} - -func (o SystemData) GetCreatedAtAsTime() (*time.Time, error) { - if o.CreatedAt == nil { - return nil, nil - } - return dates.ParseAsFormat(o.CreatedAt, "2006-01-02T15:04:05Z07:00") -} - -func (o SystemData) SetCreatedAtAsTime(input time.Time) { - formatted := input.Format("2006-01-02T15:04:05Z07:00") - o.CreatedAt = &formatted -} - -func (o SystemData) GetLastModifiedAtAsTime() (*time.Time, error) { - if o.LastModifiedAt == nil { - return nil, nil - } - return dates.ParseAsFormat(o.LastModifiedAt, "2006-01-02T15:04:05Z07:00") -} - -func (o SystemData) SetLastModifiedAtAsTime(input time.Time) { - formatted := input.Format("2006-01-02T15:04:05Z07:00") - o.LastModifiedAt = &formatted -} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/dicomservices/predicates.go b/internal/services/healthcare/sdk/2021-06-01-preview/dicomservices/predicates.go deleted file mode 100644 index c331a042d4bb..000000000000 --- a/internal/services/healthcare/sdk/2021-06-01-preview/dicomservices/predicates.go +++ /dev/null @@ -1,34 +0,0 @@ -package dicomservices - -type DicomServicePredicate struct { - Etag *string - Id *string - Location *string - Name *string - Type *string -} - -func (p DicomServicePredicate) Matches(input DicomService) bool { - - if p.Etag != nil && (input.Etag == nil && *p.Etag != *input.Etag) { - return false - } - - if p.Id != nil && (input.Id == nil && *p.Id != *input.Id) { - return false - } - - if p.Location != nil && (input.Location == nil && *p.Location != *input.Location) { - return false - } - - if p.Name != nil && (input.Name == nil && *p.Name != *input.Name) { - return false - } - - if p.Type != nil && (input.Type == nil && *p.Type != *input.Type) { - return false - } - - return true -} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/dicomservices/version.go b/internal/services/healthcare/sdk/2021-06-01-preview/dicomservices/version.go deleted file mode 100644 index 193ab1a9e9b2..000000000000 --- a/internal/services/healthcare/sdk/2021-06-01-preview/dicomservices/version.go +++ /dev/null @@ -1,9 +0,0 @@ -package dicomservices - -import "fmt" - -const defaultApiVersion = "2021-06-01-preview" - -func userAgent() string { - return fmt.Sprintf("pandora/dicomservices/%s", defaultApiVersion) -} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/client.go b/internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/client.go deleted file mode 100644 index da61d03b51b7..000000000000 --- a/internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/client.go +++ /dev/null @@ -1,15 +0,0 @@ -package fhirservices - -import "github.com/Azure/go-autorest/autorest" - -type FhirServicesClient struct { - Client autorest.Client - baseUri string -} - -func NewFhirServicesClientWithBaseURI(endpoint string) FhirServicesClient { - return FhirServicesClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, - } -} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/constants.go b/internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/constants.go deleted file mode 100644 index 21039bcfe1c1..000000000000 --- a/internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/constants.go +++ /dev/null @@ -1,154 +0,0 @@ -package fhirservices - -import "strings" - -type CreatedByType string - -const ( - CreatedByTypeApplication CreatedByType = "Application" - CreatedByTypeKey CreatedByType = "Key" - CreatedByTypeManagedIdentity CreatedByType = "ManagedIdentity" - CreatedByTypeUser CreatedByType = "User" -) - -func PossibleValuesForCreatedByType() []string { - return []string{ - string(CreatedByTypeApplication), - string(CreatedByTypeKey), - string(CreatedByTypeManagedIdentity), - string(CreatedByTypeUser), - } -} - -func parseCreatedByType(input string) (*CreatedByType, error) { - vals := map[string]CreatedByType{ - "application": CreatedByTypeApplication, - "key": CreatedByTypeKey, - "managedidentity": CreatedByTypeManagedIdentity, - "user": CreatedByTypeUser, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := CreatedByType(input) - return &out, nil -} - -type FhirServiceKind string - -const ( - FhirServiceKindFhirNegativeRFour FhirServiceKind = "fhir-R4" - FhirServiceKindFhirNegativeStuThree FhirServiceKind = "fhir-Stu3" -) - -func PossibleValuesForFhirServiceKind() []string { - return []string{ - string(FhirServiceKindFhirNegativeRFour), - string(FhirServiceKindFhirNegativeStuThree), - } -} - -func parseFhirServiceKind(input string) (*FhirServiceKind, error) { - vals := map[string]FhirServiceKind{ - "fhir-r4": FhirServiceKindFhirNegativeRFour, - "fhir-stu3": FhirServiceKindFhirNegativeStuThree, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := FhirServiceKind(input) - return &out, nil -} - -type ManagedServiceIdentityType string - -const ( - ManagedServiceIdentityTypeNone ManagedServiceIdentityType = "None" - ManagedServiceIdentityTypeSystemAssigned ManagedServiceIdentityType = "SystemAssigned" -) - -func PossibleValuesForManagedServiceIdentityType() []string { - return []string{ - string(ManagedServiceIdentityTypeNone), - string(ManagedServiceIdentityTypeSystemAssigned), - } -} - -func parseManagedServiceIdentityType(input string) (*ManagedServiceIdentityType, error) { - vals := map[string]ManagedServiceIdentityType{ - "none": ManagedServiceIdentityTypeNone, - "systemassigned": ManagedServiceIdentityTypeSystemAssigned, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := ManagedServiceIdentityType(input) - return &out, nil -} - -type ProvisioningState string - -const ( - ProvisioningStateAccepted ProvisioningState = "Accepted" - ProvisioningStateCanceled ProvisioningState = "Canceled" - ProvisioningStateCreating ProvisioningState = "Creating" - ProvisioningStateDeleting ProvisioningState = "Deleting" - ProvisioningStateDeprovisioned ProvisioningState = "Deprovisioned" - ProvisioningStateFailed ProvisioningState = "Failed" - ProvisioningStateMoving ProvisioningState = "Moving" - ProvisioningStateSucceeded ProvisioningState = "Succeeded" - ProvisioningStateSuspended ProvisioningState = "Suspended" - ProvisioningStateSystemMaintenance ProvisioningState = "SystemMaintenance" - ProvisioningStateUpdating ProvisioningState = "Updating" - ProvisioningStateVerifying ProvisioningState = "Verifying" - ProvisioningStateWarned ProvisioningState = "Warned" -) - -func PossibleValuesForProvisioningState() []string { - return []string{ - string(ProvisioningStateAccepted), - string(ProvisioningStateCanceled), - string(ProvisioningStateCreating), - string(ProvisioningStateDeleting), - string(ProvisioningStateDeprovisioned), - string(ProvisioningStateFailed), - string(ProvisioningStateMoving), - string(ProvisioningStateSucceeded), - string(ProvisioningStateSuspended), - string(ProvisioningStateSystemMaintenance), - string(ProvisioningStateUpdating), - string(ProvisioningStateVerifying), - string(ProvisioningStateWarned), - } -} - -func parseProvisioningState(input string) (*ProvisioningState, error) { - vals := map[string]ProvisioningState{ - "accepted": ProvisioningStateAccepted, - "canceled": ProvisioningStateCanceled, - "creating": ProvisioningStateCreating, - "deleting": ProvisioningStateDeleting, - "deprovisioned": ProvisioningStateDeprovisioned, - "failed": ProvisioningStateFailed, - "moving": ProvisioningStateMoving, - "succeeded": ProvisioningStateSucceeded, - "suspended": ProvisioningStateSuspended, - "systemmaintenance": ProvisioningStateSystemMaintenance, - "updating": ProvisioningStateUpdating, - "verifying": ProvisioningStateVerifying, - "warned": ProvisioningStateWarned, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := ProvisioningState(input) - return &out, nil -} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/id_fhirservice.go b/internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/id_fhirservice.go deleted file mode 100644 index e7cb11987bac..000000000000 --- a/internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/id_fhirservice.go +++ /dev/null @@ -1,137 +0,0 @@ -package fhirservices - -import ( - "fmt" - "strings" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -var _ resourceids.ResourceId = FhirServiceId{} - -// FhirServiceId is a struct representing the Resource ID for a Fhir Service -type FhirServiceId struct { - SubscriptionId string - ResourceGroupName string - WorkspaceName string - FhirServiceName string -} - -// NewFhirServiceID returns a new FhirServiceId struct -func NewFhirServiceID(subscriptionId string, resourceGroupName string, workspaceName string, fhirServiceName string) FhirServiceId { - return FhirServiceId{ - SubscriptionId: subscriptionId, - ResourceGroupName: resourceGroupName, - WorkspaceName: workspaceName, - FhirServiceName: fhirServiceName, - } -} - -// ParseFhirServiceID parses 'input' into a FhirServiceId -func ParseFhirServiceID(input string) (*FhirServiceId, error) { - parser := resourceids.NewParserFromResourceIdType(FhirServiceId{}) - parsed, err := parser.Parse(input, false) - if err != nil { - return nil, fmt.Errorf("parsing %q: %+v", input, err) - } - - var ok bool - id := FhirServiceId{} - - if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { - return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) - } - - if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { - return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) - } - - if id.WorkspaceName, ok = parsed.Parsed["workspaceName"]; !ok { - return nil, fmt.Errorf("the segment 'workspaceName' was not found in the resource id %q", input) - } - - if id.FhirServiceName, ok = parsed.Parsed["fhirServiceName"]; !ok { - return nil, fmt.Errorf("the segment 'fhirServiceName' was not found in the resource id %q", input) - } - - return &id, nil -} - -// ParseFhirServiceIDInsensitively parses 'input' case-insensitively into a FhirServiceId -// note: this method should only be used for API response data and not user input -func ParseFhirServiceIDInsensitively(input string) (*FhirServiceId, error) { - parser := resourceids.NewParserFromResourceIdType(FhirServiceId{}) - parsed, err := parser.Parse(input, true) - if err != nil { - return nil, fmt.Errorf("parsing %q: %+v", input, err) - } - - var ok bool - id := FhirServiceId{} - - if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { - return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) - } - - if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { - return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) - } - - if id.WorkspaceName, ok = parsed.Parsed["workspaceName"]; !ok { - return nil, fmt.Errorf("the segment 'workspaceName' was not found in the resource id %q", input) - } - - if id.FhirServiceName, ok = parsed.Parsed["fhirServiceName"]; !ok { - return nil, fmt.Errorf("the segment 'fhirServiceName' was not found in the resource id %q", input) - } - - return &id, nil -} - -// ValidateFhirServiceID checks that 'input' can be parsed as a Fhir Service ID -func ValidateFhirServiceID(input interface{}, key string) (warnings []string, errors []error) { - v, ok := input.(string) - if !ok { - errors = append(errors, fmt.Errorf("expected %q to be a string", key)) - return - } - - if _, err := ParseFhirServiceID(v); err != nil { - errors = append(errors, err) - } - - return -} - -// ID returns the formatted Fhir Service ID -func (id FhirServiceId) ID() string { - fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.HealthcareApis/workspaces/%s/fhirServices/%s" - return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.WorkspaceName, id.FhirServiceName) -} - -// Segments returns a slice of Resource ID Segments which comprise this Fhir Service ID -func (id FhirServiceId) Segments() []resourceids.Segment { - return []resourceids.Segment{ - resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), - resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), - resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), - resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), - resourceids.StaticSegment("staticProviders", "providers", "providers"), - resourceids.ResourceProviderSegment("staticMicrosoftHealthcareApis", "Microsoft.HealthcareApis", "Microsoft.HealthcareApis"), - resourceids.StaticSegment("staticWorkspaces", "workspaces", "workspaces"), - resourceids.UserSpecifiedSegment("workspaceName", "workspaceValue"), - resourceids.StaticSegment("staticFhirServices", "fhirServices", "fhirServices"), - resourceids.UserSpecifiedSegment("fhirServiceName", "fhirServiceValue"), - } -} - -// String returns a human-readable description of this Fhir Service ID -func (id FhirServiceId) String() string { - components := []string{ - fmt.Sprintf("Subscription: %q", id.SubscriptionId), - fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), - fmt.Sprintf("Workspace Name: %q", id.WorkspaceName), - fmt.Sprintf("Fhir Service Name: %q", id.FhirServiceName), - } - return fmt.Sprintf("Fhir Service (%s)", strings.Join(components, "\n")) -} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/id_fhirservice_test.go b/internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/id_fhirservice_test.go deleted file mode 100644 index 26537436e30b..000000000000 --- a/internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/id_fhirservice_test.go +++ /dev/null @@ -1,324 +0,0 @@ -package fhirservices - -import ( - "testing" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -var _ resourceids.ResourceId = FhirServiceId{} - -func TestNewFhirServiceID(t *testing.T) { - id := NewFhirServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceValue", "fhirServiceValue") - - if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { - t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") - } - - if id.ResourceGroupName != "example-resource-group" { - t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") - } - - if id.WorkspaceName != "workspaceValue" { - t.Fatalf("Expected %q but got %q for Segment 'WorkspaceName'", id.WorkspaceName, "workspaceValue") - } - - if id.FhirServiceName != "fhirServiceValue" { - t.Fatalf("Expected %q but got %q for Segment 'FhirServiceName'", id.FhirServiceName, "fhirServiceValue") - } -} - -func TestFormatFhirServiceID(t *testing.T) { - actual := NewFhirServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceValue", "fhirServiceValue").ID() - expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/workspaces/workspaceValue/fhirServices/fhirServiceValue" - if actual != expected { - t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) - } -} - -func TestParseFhirServiceID(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *FhirServiceId - }{ - { - // Incomplete URI - Input: "", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/workspaces", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/workspaces/workspaceValue", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/workspaces/workspaceValue/fhirServices", - Error: true, - }, - { - // Valid URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/workspaces/workspaceValue/fhirServices/fhirServiceValue", - Expected: &FhirServiceId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "example-resource-group", - WorkspaceName: "workspaceValue", - FhirServiceName: "fhirServiceValue", - }, - }, - { - // Invalid (Valid Uri with Extra segment) - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/workspaces/workspaceValue/fhirServices/fhirServiceValue/extra", - Error: true, - }, - } - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := ParseFhirServiceID(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expect a value but got an error: %+v", err) - } - if v.Error { - t.Fatal("Expect an error but didn't get one") - } - - if actual.SubscriptionId != v.Expected.SubscriptionId { - t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) - } - - if actual.ResourceGroupName != v.Expected.ResourceGroupName { - t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) - } - - if actual.WorkspaceName != v.Expected.WorkspaceName { - t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) - } - - if actual.FhirServiceName != v.Expected.FhirServiceName { - t.Fatalf("Expected %q but got %q for FhirServiceName", v.Expected.FhirServiceName, actual.FhirServiceName) - } - - } -} - -func TestParseFhirServiceIDInsensitively(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *FhirServiceId - }{ - { - // Incomplete URI - Input: "", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hEaLtHcArEaPiS", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/workspaces", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hEaLtHcArEaPiS/wOrKsPaCeS", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/workspaces/workspaceValue", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hEaLtHcArEaPiS/wOrKsPaCeS/wOrKsPaCeVaLuE", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/workspaces/workspaceValue/fhirServices", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hEaLtHcArEaPiS/wOrKsPaCeS/wOrKsPaCeVaLuE/fHiRsErViCeS", - Error: true, - }, - { - // Valid URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/workspaces/workspaceValue/fhirServices/fhirServiceValue", - Expected: &FhirServiceId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "example-resource-group", - WorkspaceName: "workspaceValue", - FhirServiceName: "fhirServiceValue", - }, - }, - { - // Invalid (Valid Uri with Extra segment) - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/workspaces/workspaceValue/fhirServices/fhirServiceValue/extra", - Error: true, - }, - { - // Valid URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hEaLtHcArEaPiS/wOrKsPaCeS/wOrKsPaCeVaLuE/fHiRsErViCeS/fHiRsErViCeVaLuE", - Expected: &FhirServiceId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", - WorkspaceName: "wOrKsPaCeVaLuE", - FhirServiceName: "fHiRsErViCeVaLuE", - }, - }, - { - // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hEaLtHcArEaPiS/wOrKsPaCeS/wOrKsPaCeVaLuE/fHiRsErViCeS/fHiRsErViCeVaLuE/extra", - Error: true, - }, - } - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := ParseFhirServiceIDInsensitively(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expect a value but got an error: %+v", err) - } - if v.Error { - t.Fatal("Expect an error but didn't get one") - } - - if actual.SubscriptionId != v.Expected.SubscriptionId { - t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) - } - - if actual.ResourceGroupName != v.Expected.ResourceGroupName { - t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) - } - - if actual.WorkspaceName != v.Expected.WorkspaceName { - t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) - } - - if actual.FhirServiceName != v.Expected.FhirServiceName { - t.Fatalf("Expected %q but got %q for FhirServiceName", v.Expected.FhirServiceName, actual.FhirServiceName) - } - - } -} - -func TestSegmentsForFhirServiceId(t *testing.T) { - segments := FhirServiceId{}.Segments() - if len(segments) == 0 { - t.Fatalf("FhirServiceId has no segments") - } - - uniqueNames := make(map[string]struct{}, 0) - for _, segment := range segments { - uniqueNames[segment.Name] = struct{}{} - } - if len(uniqueNames) != len(segments) { - t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) - } -} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/id_workspace.go b/internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/id_workspace.go deleted file mode 100644 index 8abd7a760f49..000000000000 --- a/internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/id_workspace.go +++ /dev/null @@ -1,124 +0,0 @@ -package fhirservices - -import ( - "fmt" - "strings" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -var _ resourceids.ResourceId = WorkspaceId{} - -// WorkspaceId is a struct representing the Resource ID for a Workspace -type WorkspaceId struct { - SubscriptionId string - ResourceGroupName string - WorkspaceName string -} - -// NewWorkspaceID returns a new WorkspaceId struct -func NewWorkspaceID(subscriptionId string, resourceGroupName string, workspaceName string) WorkspaceId { - return WorkspaceId{ - SubscriptionId: subscriptionId, - ResourceGroupName: resourceGroupName, - WorkspaceName: workspaceName, - } -} - -// ParseWorkspaceID parses 'input' into a WorkspaceId -func ParseWorkspaceID(input string) (*WorkspaceId, error) { - parser := resourceids.NewParserFromResourceIdType(WorkspaceId{}) - parsed, err := parser.Parse(input, false) - if err != nil { - return nil, fmt.Errorf("parsing %q: %+v", input, err) - } - - var ok bool - id := WorkspaceId{} - - if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { - return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) - } - - if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { - return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) - } - - if id.WorkspaceName, ok = parsed.Parsed["workspaceName"]; !ok { - return nil, fmt.Errorf("the segment 'workspaceName' was not found in the resource id %q", input) - } - - return &id, nil -} - -// ParseWorkspaceIDInsensitively parses 'input' case-insensitively into a WorkspaceId -// note: this method should only be used for API response data and not user input -func ParseWorkspaceIDInsensitively(input string) (*WorkspaceId, error) { - parser := resourceids.NewParserFromResourceIdType(WorkspaceId{}) - parsed, err := parser.Parse(input, true) - if err != nil { - return nil, fmt.Errorf("parsing %q: %+v", input, err) - } - - var ok bool - id := WorkspaceId{} - - if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { - return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) - } - - if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { - return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) - } - - if id.WorkspaceName, ok = parsed.Parsed["workspaceName"]; !ok { - return nil, fmt.Errorf("the segment 'workspaceName' was not found in the resource id %q", input) - } - - return &id, nil -} - -// ValidateWorkspaceID checks that 'input' can be parsed as a Workspace ID -func ValidateWorkspaceID(input interface{}, key string) (warnings []string, errors []error) { - v, ok := input.(string) - if !ok { - errors = append(errors, fmt.Errorf("expected %q to be a string", key)) - return - } - - if _, err := ParseWorkspaceID(v); err != nil { - errors = append(errors, err) - } - - return -} - -// ID returns the formatted Workspace ID -func (id WorkspaceId) ID() string { - fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.HealthcareApis/workspaces/%s" - return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.WorkspaceName) -} - -// Segments returns a slice of Resource ID Segments which comprise this Workspace ID -func (id WorkspaceId) Segments() []resourceids.Segment { - return []resourceids.Segment{ - resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), - resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), - resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), - resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), - resourceids.StaticSegment("staticProviders", "providers", "providers"), - resourceids.ResourceProviderSegment("staticMicrosoftHealthcareApis", "Microsoft.HealthcareApis", "Microsoft.HealthcareApis"), - resourceids.StaticSegment("staticWorkspaces", "workspaces", "workspaces"), - resourceids.UserSpecifiedSegment("workspaceName", "workspaceValue"), - } -} - -// String returns a human-readable description of this Workspace ID -func (id WorkspaceId) String() string { - components := []string{ - fmt.Sprintf("Subscription: %q", id.SubscriptionId), - fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), - fmt.Sprintf("Workspace Name: %q", id.WorkspaceName), - } - return fmt.Sprintf("Workspace (%s)", strings.Join(components, "\n")) -} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/id_workspace_test.go b/internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/id_workspace_test.go deleted file mode 100644 index 5aa31df8f9e6..000000000000 --- a/internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/id_workspace_test.go +++ /dev/null @@ -1,279 +0,0 @@ -package fhirservices - -import ( - "testing" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -var _ resourceids.ResourceId = WorkspaceId{} - -func TestNewWorkspaceID(t *testing.T) { - id := NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceValue") - - if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { - t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") - } - - if id.ResourceGroupName != "example-resource-group" { - t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") - } - - if id.WorkspaceName != "workspaceValue" { - t.Fatalf("Expected %q but got %q for Segment 'WorkspaceName'", id.WorkspaceName, "workspaceValue") - } -} - -func TestFormatWorkspaceID(t *testing.T) { - actual := NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceValue").ID() - expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/workspaces/workspaceValue" - if actual != expected { - t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) - } -} - -func TestParseWorkspaceID(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *WorkspaceId - }{ - { - // Incomplete URI - Input: "", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/workspaces", - Error: true, - }, - { - // Valid URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/workspaces/workspaceValue", - Expected: &WorkspaceId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "example-resource-group", - WorkspaceName: "workspaceValue", - }, - }, - { - // Invalid (Valid Uri with Extra segment) - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/workspaces/workspaceValue/extra", - Error: true, - }, - } - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := ParseWorkspaceID(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expect a value but got an error: %+v", err) - } - if v.Error { - t.Fatal("Expect an error but didn't get one") - } - - if actual.SubscriptionId != v.Expected.SubscriptionId { - t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) - } - - if actual.ResourceGroupName != v.Expected.ResourceGroupName { - t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) - } - - if actual.WorkspaceName != v.Expected.WorkspaceName { - t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) - } - - } -} - -func TestParseWorkspaceIDInsensitively(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *WorkspaceId - }{ - { - // Incomplete URI - Input: "", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hEaLtHcArEaPiS", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/workspaces", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hEaLtHcArEaPiS/wOrKsPaCeS", - Error: true, - }, - { - // Valid URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/workspaces/workspaceValue", - Expected: &WorkspaceId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "example-resource-group", - WorkspaceName: "workspaceValue", - }, - }, - { - // Invalid (Valid Uri with Extra segment) - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/workspaces/workspaceValue/extra", - Error: true, - }, - { - // Valid URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hEaLtHcArEaPiS/wOrKsPaCeS/wOrKsPaCeVaLuE", - Expected: &WorkspaceId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", - WorkspaceName: "wOrKsPaCeVaLuE", - }, - }, - { - // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hEaLtHcArEaPiS/wOrKsPaCeS/wOrKsPaCeVaLuE/extra", - Error: true, - }, - } - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := ParseWorkspaceIDInsensitively(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expect a value but got an error: %+v", err) - } - if v.Error { - t.Fatal("Expect an error but didn't get one") - } - - if actual.SubscriptionId != v.Expected.SubscriptionId { - t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) - } - - if actual.ResourceGroupName != v.Expected.ResourceGroupName { - t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) - } - - if actual.WorkspaceName != v.Expected.WorkspaceName { - t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) - } - - } -} - -func TestSegmentsForWorkspaceId(t *testing.T) { - segments := WorkspaceId{}.Segments() - if len(segments) == 0 { - t.Fatalf("WorkspaceId has no segments") - } - - uniqueNames := make(map[string]struct{}, 0) - for _, segment := range segments { - uniqueNames[segment.Name] = struct{}{} - } - if len(uniqueNames) != len(segments) { - t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) - } -} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/method_createorupdate_autorest.go b/internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/method_createorupdate_autorest.go deleted file mode 100644 index b2535d43d8a7..000000000000 --- a/internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/method_createorupdate_autorest.go +++ /dev/null @@ -1,75 +0,0 @@ -package fhirservices - -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" -) - -type CreateOrUpdateResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// CreateOrUpdate ... -func (c FhirServicesClient) CreateOrUpdate(ctx context.Context, id FhirServiceId, input FhirService) (result CreateOrUpdateResponse, err error) { - req, err := c.preparerForCreateOrUpdate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "fhirservices.FhirServicesClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result, err = c.senderForCreateOrUpdate(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "fhirservices.FhirServicesClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed -func (c FhirServicesClient) CreateOrUpdateThenPoll(ctx context.Context, id FhirServiceId, input FhirService) 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 FhirServicesClient) preparerForCreateOrUpdate(ctx context.Context, id FhirServiceId, input FhirService) (*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 FhirServicesClient) senderForCreateOrUpdate(ctx context.Context, req *http.Request) (future CreateOrUpdateResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - future.Poller, err = polling.NewLongRunningPollerFromResponse(ctx, resp, c.Client) - return -} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/method_delete_autorest.go b/internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/method_delete_autorest.go deleted file mode 100644 index f8361563ff15..000000000000 --- a/internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/method_delete_autorest.go +++ /dev/null @@ -1,74 +0,0 @@ -package fhirservices - -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" -) - -type DeleteResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// Delete ... -func (c FhirServicesClient) Delete(ctx context.Context, id FhirServiceId) (result DeleteResponse, err error) { - req, err := c.preparerForDelete(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "fhirservices.FhirServicesClient", "Delete", nil, "Failure preparing request") - return - } - - result, err = c.senderForDelete(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "fhirservices.FhirServicesClient", "Delete", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// DeleteThenPoll performs Delete then polls until it's completed -func (c FhirServicesClient) DeleteThenPoll(ctx context.Context, id FhirServiceId) 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 FhirServicesClient) preparerForDelete(ctx context.Context, id FhirServiceId) (*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 FhirServicesClient) senderForDelete(ctx context.Context, req *http.Request) (future DeleteResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - future.Poller, err = polling.NewLongRunningPollerFromResponse(ctx, resp, c.Client) - return -} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/method_get_autorest.go b/internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/method_get_autorest.go deleted file mode 100644 index 3c89a465f94f..000000000000 --- a/internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/method_get_autorest.go +++ /dev/null @@ -1,64 +0,0 @@ -package fhirservices - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -type GetResponse struct { - HttpResponse *http.Response - Model *FhirService -} - -// Get ... -func (c FhirServicesClient) Get(ctx context.Context, id FhirServiceId) (result GetResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "fhirservices.FhirServicesClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "fhirservices.FhirServicesClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "fhirservices.FhirServicesClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c FhirServicesClient) preparerForGet(ctx context.Context, id FhirServiceId) (*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 FhirServicesClient) responderForGet(resp *http.Response) (result GetResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - return -} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/method_listbyworkspace_autorest.go b/internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/method_listbyworkspace_autorest.go deleted file mode 100644 index a30fb5ef5129..000000000000 --- a/internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/method_listbyworkspace_autorest.go +++ /dev/null @@ -1,183 +0,0 @@ -package fhirservices - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -type ListByWorkspaceResponse struct { - HttpResponse *http.Response - Model *[]FhirService - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListByWorkspaceResponse, error) -} - -type ListByWorkspaceCompleteResult struct { - Items []FhirService -} - -func (r ListByWorkspaceResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListByWorkspaceResponse) LoadMore(ctx context.Context) (resp ListByWorkspaceResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListByWorkspace ... -func (c FhirServicesClient) ListByWorkspace(ctx context.Context, id WorkspaceId) (resp ListByWorkspaceResponse, err error) { - req, err := c.preparerForListByWorkspace(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "fhirservices.FhirServicesClient", "ListByWorkspace", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "fhirservices.FhirServicesClient", "ListByWorkspace", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListByWorkspace(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "fhirservices.FhirServicesClient", "ListByWorkspace", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// ListByWorkspaceComplete retrieves all of the results into a single object -func (c FhirServicesClient) ListByWorkspaceComplete(ctx context.Context, id WorkspaceId) (ListByWorkspaceCompleteResult, error) { - return c.ListByWorkspaceCompleteMatchingPredicate(ctx, id, FhirServicePredicate{}) -} - -// ListByWorkspaceCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c FhirServicesClient) ListByWorkspaceCompleteMatchingPredicate(ctx context.Context, id WorkspaceId, predicate FhirServicePredicate) (resp ListByWorkspaceCompleteResult, err error) { - items := make([]FhirService, 0) - - page, err := c.ListByWorkspace(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 := ListByWorkspaceCompleteResult{ - Items: items, - } - return out, nil -} - -// preparerForListByWorkspace prepares the ListByWorkspace request. -func (c FhirServicesClient) preparerForListByWorkspace(ctx context.Context, id WorkspaceId) (*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/fhirServices", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListByWorkspaceWithNextLink prepares the ListByWorkspace request with the given nextLink token. -func (c FhirServicesClient) preparerForListByWorkspaceWithNextLink(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)) -} - -// responderForListByWorkspace handles the response to the ListByWorkspace request. The method always -// closes the http.Response Body. -func (c FhirServicesClient) responderForListByWorkspace(resp *http.Response) (result ListByWorkspaceResponse, err error) { - type page struct { - Values []FhirService `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 ListByWorkspaceResponse, err error) { - req, err := c.preparerForListByWorkspaceWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "fhirservices.FhirServicesClient", "ListByWorkspace", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "fhirservices.FhirServicesClient", "ListByWorkspace", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByWorkspace(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "fhirservices.FhirServicesClient", "ListByWorkspace", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/method_update_autorest.go b/internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/method_update_autorest.go deleted file mode 100644 index 3a286b326764..000000000000 --- a/internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/method_update_autorest.go +++ /dev/null @@ -1,75 +0,0 @@ -package fhirservices - -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" -) - -type UpdateResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// Update ... -func (c FhirServicesClient) Update(ctx context.Context, id FhirServiceId, input FhirServicePatchResource) (result UpdateResponse, err error) { - req, err := c.preparerForUpdate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "fhirservices.FhirServicesClient", "Update", nil, "Failure preparing request") - return - } - - result, err = c.senderForUpdate(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "fhirservices.FhirServicesClient", "Update", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// UpdateThenPoll performs Update then polls until it's completed -func (c FhirServicesClient) UpdateThenPoll(ctx context.Context, id FhirServiceId, input FhirServicePatchResource) 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 FhirServicesClient) preparerForUpdate(ctx context.Context, id FhirServiceId, input FhirServicePatchResource) (*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 FhirServicesClient) senderForUpdate(ctx context.Context, req *http.Request) (future UpdateResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - future.Poller, err = polling.NewLongRunningPollerFromResponse(ctx, resp, c.Client) - return -} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/model_fhirservice.go b/internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/model_fhirservice.go deleted file mode 100644 index a1e36a7b64f9..000000000000 --- a/internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/model_fhirservice.go +++ /dev/null @@ -1,14 +0,0 @@ -package fhirservices - -type FhirService struct { - Etag *string `json:"etag,omitempty"` - Id *string `json:"id,omitempty"` - Identity *ServiceManagedIdentityIdentity `json:"identity,omitempty"` - Kind *FhirServiceKind `json:"kind,omitempty"` - Location *string `json:"location,omitempty"` - Name *string `json:"name,omitempty"` - Properties *FhirServiceProperties `json:"properties,omitempty"` - SystemData *SystemData `json:"systemData,omitempty"` - Tags *map[string]string `json:"tags,omitempty"` - Type *string `json:"type,omitempty"` -} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/model_fhirserviceaccesspolicyentry.go b/internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/model_fhirserviceaccesspolicyentry.go deleted file mode 100644 index 31a9e85ea171..000000000000 --- a/internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/model_fhirserviceaccesspolicyentry.go +++ /dev/null @@ -1,5 +0,0 @@ -package fhirservices - -type FhirServiceAccessPolicyEntry struct { - ObjectId string `json:"objectId"` -} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/model_fhirserviceacrconfiguration.go b/internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/model_fhirserviceacrconfiguration.go deleted file mode 100644 index f733e51101d1..000000000000 --- a/internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/model_fhirserviceacrconfiguration.go +++ /dev/null @@ -1,5 +0,0 @@ -package fhirservices - -type FhirServiceAcrConfiguration struct { - LoginServers *[]string `json:"loginServers,omitempty"` -} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/model_fhirserviceauthenticationconfiguration.go b/internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/model_fhirserviceauthenticationconfiguration.go deleted file mode 100644 index 6d25b36de86f..000000000000 --- a/internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/model_fhirserviceauthenticationconfiguration.go +++ /dev/null @@ -1,7 +0,0 @@ -package fhirservices - -type FhirServiceAuthenticationConfiguration struct { - Audience *string `json:"audience,omitempty"` - Authority *string `json:"authority,omitempty"` - SmartProxyEnabled *bool `json:"smartProxyEnabled,omitempty"` -} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/model_fhirservicecorsconfiguration.go b/internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/model_fhirservicecorsconfiguration.go deleted file mode 100644 index 9ec0330a3947..000000000000 --- a/internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/model_fhirservicecorsconfiguration.go +++ /dev/null @@ -1,9 +0,0 @@ -package fhirservices - -type FhirServiceCorsConfiguration struct { - AllowCredentials *bool `json:"allowCredentials,omitempty"` - Headers *[]string `json:"headers,omitempty"` - MaxAge *int64 `json:"maxAge,omitempty"` - Methods *[]string `json:"methods,omitempty"` - Origins *[]string `json:"origins,omitempty"` -} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/model_fhirserviceexportconfiguration.go b/internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/model_fhirserviceexportconfiguration.go deleted file mode 100644 index 0eaf3c1e2007..000000000000 --- a/internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/model_fhirserviceexportconfiguration.go +++ /dev/null @@ -1,5 +0,0 @@ -package fhirservices - -type FhirServiceExportConfiguration struct { - StorageAccountName *string `json:"storageAccountName,omitempty"` -} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/model_fhirservicepatchresource.go b/internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/model_fhirservicepatchresource.go deleted file mode 100644 index 652c5a21ce35..000000000000 --- a/internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/model_fhirservicepatchresource.go +++ /dev/null @@ -1,6 +0,0 @@ -package fhirservices - -type FhirServicePatchResource struct { - Identity *ServiceManagedIdentityIdentity `json:"identity,omitempty"` - Tags *map[string]string `json:"tags,omitempty"` -} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/model_fhirserviceproperties.go b/internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/model_fhirserviceproperties.go deleted file mode 100644 index 6d773381b0af..000000000000 --- a/internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/model_fhirserviceproperties.go +++ /dev/null @@ -1,10 +0,0 @@ -package fhirservices - -type FhirServiceProperties struct { - AccessPolicies *[]FhirServiceAccessPolicyEntry `json:"accessPolicies,omitempty"` - AcrConfiguration *FhirServiceAcrConfiguration `json:"acrConfiguration,omitempty"` - AuthenticationConfiguration *FhirServiceAuthenticationConfiguration `json:"authenticationConfiguration,omitempty"` - CorsConfiguration *FhirServiceCorsConfiguration `json:"corsConfiguration,omitempty"` - ExportConfiguration *FhirServiceExportConfiguration `json:"exportConfiguration,omitempty"` - ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` -} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/model_servicemanagedidentityidentity.go b/internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/model_servicemanagedidentityidentity.go deleted file mode 100644 index b15f4aff7956..000000000000 --- a/internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/model_servicemanagedidentityidentity.go +++ /dev/null @@ -1,5 +0,0 @@ -package fhirservices - -type ServiceManagedIdentityIdentity struct { - Type *ManagedServiceIdentityType `json:"type,omitempty"` -} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/model_systemdata.go b/internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/model_systemdata.go deleted file mode 100644 index 2454158fc621..000000000000 --- a/internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/model_systemdata.go +++ /dev/null @@ -1,40 +0,0 @@ -package fhirservices - -import ( - "time" - - "github.com/hashicorp/go-azure-helpers/lang/dates" -) - -type SystemData struct { - CreatedAt *string `json:"createdAt,omitempty"` - CreatedBy *string `json:"createdBy,omitempty"` - CreatedByType *CreatedByType `json:"createdByType,omitempty"` - LastModifiedAt *string `json:"lastModifiedAt,omitempty"` - LastModifiedBy *string `json:"lastModifiedBy,omitempty"` - LastModifiedByType *CreatedByType `json:"lastModifiedByType,omitempty"` -} - -func (o SystemData) GetCreatedAtAsTime() (*time.Time, error) { - if o.CreatedAt == nil { - return nil, nil - } - return dates.ParseAsFormat(o.CreatedAt, "2006-01-02T15:04:05Z07:00") -} - -func (o SystemData) SetCreatedAtAsTime(input time.Time) { - formatted := input.Format("2006-01-02T15:04:05Z07:00") - o.CreatedAt = &formatted -} - -func (o SystemData) GetLastModifiedAtAsTime() (*time.Time, error) { - if o.LastModifiedAt == nil { - return nil, nil - } - return dates.ParseAsFormat(o.LastModifiedAt, "2006-01-02T15:04:05Z07:00") -} - -func (o SystemData) SetLastModifiedAtAsTime(input time.Time) { - formatted := input.Format("2006-01-02T15:04:05Z07:00") - o.LastModifiedAt = &formatted -} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/predicates.go b/internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/predicates.go deleted file mode 100644 index c64d1a5adfa0..000000000000 --- a/internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/predicates.go +++ /dev/null @@ -1,34 +0,0 @@ -package fhirservices - -type FhirServicePredicate struct { - Etag *string - Id *string - Location *string - Name *string - Type *string -} - -func (p FhirServicePredicate) Matches(input FhirService) bool { - - if p.Etag != nil && (input.Etag == nil && *p.Etag != *input.Etag) { - return false - } - - if p.Id != nil && (input.Id == nil && *p.Id != *input.Id) { - return false - } - - if p.Location != nil && (input.Location == nil && *p.Location != *input.Location) { - return false - } - - if p.Name != nil && (input.Name == nil && *p.Name != *input.Name) { - return false - } - - if p.Type != nil && (input.Type == nil && *p.Type != *input.Type) { - return false - } - - return true -} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/version.go b/internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/version.go deleted file mode 100644 index f2ca1c55d66e..000000000000 --- a/internal/services/healthcare/sdk/2021-06-01-preview/fhirservices/version.go +++ /dev/null @@ -1,9 +0,0 @@ -package fhirservices - -import "fmt" - -const defaultApiVersion = "2021-06-01-preview" - -func userAgent() string { - return fmt.Sprintf("pandora/fhirservices/%s", defaultApiVersion) -} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/client.go b/internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/client.go deleted file mode 100644 index e47505b51f6b..000000000000 --- a/internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/client.go +++ /dev/null @@ -1,15 +0,0 @@ -package iotconnectors - -import "github.com/Azure/go-autorest/autorest" - -type IotConnectorsClient struct { - Client autorest.Client - baseUri string -} - -func NewIotConnectorsClientWithBaseURI(endpoint string) IotConnectorsClient { - return IotConnectorsClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, - } -} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/constants.go b/internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/constants.go deleted file mode 100644 index 2c82c5ad9189..000000000000 --- a/internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/constants.go +++ /dev/null @@ -1,154 +0,0 @@ -package iotconnectors - -import "strings" - -type CreatedByType string - -const ( - CreatedByTypeApplication CreatedByType = "Application" - CreatedByTypeKey CreatedByType = "Key" - CreatedByTypeManagedIdentity CreatedByType = "ManagedIdentity" - CreatedByTypeUser CreatedByType = "User" -) - -func PossibleValuesForCreatedByType() []string { - return []string{ - string(CreatedByTypeApplication), - string(CreatedByTypeKey), - string(CreatedByTypeManagedIdentity), - string(CreatedByTypeUser), - } -} - -func parseCreatedByType(input string) (*CreatedByType, error) { - vals := map[string]CreatedByType{ - "application": CreatedByTypeApplication, - "key": CreatedByTypeKey, - "managedidentity": CreatedByTypeManagedIdentity, - "user": CreatedByTypeUser, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := CreatedByType(input) - return &out, nil -} - -type IotIdentityResolutionType string - -const ( - IotIdentityResolutionTypeCreate IotIdentityResolutionType = "Create" - IotIdentityResolutionTypeLookup IotIdentityResolutionType = "Lookup" -) - -func PossibleValuesForIotIdentityResolutionType() []string { - return []string{ - string(IotIdentityResolutionTypeCreate), - string(IotIdentityResolutionTypeLookup), - } -} - -func parseIotIdentityResolutionType(input string) (*IotIdentityResolutionType, error) { - vals := map[string]IotIdentityResolutionType{ - "create": IotIdentityResolutionTypeCreate, - "lookup": IotIdentityResolutionTypeLookup, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := IotIdentityResolutionType(input) - return &out, nil -} - -type ManagedServiceIdentityType string - -const ( - ManagedServiceIdentityTypeNone ManagedServiceIdentityType = "None" - ManagedServiceIdentityTypeSystemAssigned ManagedServiceIdentityType = "SystemAssigned" -) - -func PossibleValuesForManagedServiceIdentityType() []string { - return []string{ - string(ManagedServiceIdentityTypeNone), - string(ManagedServiceIdentityTypeSystemAssigned), - } -} - -func parseManagedServiceIdentityType(input string) (*ManagedServiceIdentityType, error) { - vals := map[string]ManagedServiceIdentityType{ - "none": ManagedServiceIdentityTypeNone, - "systemassigned": ManagedServiceIdentityTypeSystemAssigned, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := ManagedServiceIdentityType(input) - return &out, nil -} - -type ProvisioningState string - -const ( - ProvisioningStateAccepted ProvisioningState = "Accepted" - ProvisioningStateCanceled ProvisioningState = "Canceled" - ProvisioningStateCreating ProvisioningState = "Creating" - ProvisioningStateDeleting ProvisioningState = "Deleting" - ProvisioningStateDeprovisioned ProvisioningState = "Deprovisioned" - ProvisioningStateFailed ProvisioningState = "Failed" - ProvisioningStateMoving ProvisioningState = "Moving" - ProvisioningStateSucceeded ProvisioningState = "Succeeded" - ProvisioningStateSuspended ProvisioningState = "Suspended" - ProvisioningStateSystemMaintenance ProvisioningState = "SystemMaintenance" - ProvisioningStateUpdating ProvisioningState = "Updating" - ProvisioningStateVerifying ProvisioningState = "Verifying" - ProvisioningStateWarned ProvisioningState = "Warned" -) - -func PossibleValuesForProvisioningState() []string { - return []string{ - string(ProvisioningStateAccepted), - string(ProvisioningStateCanceled), - string(ProvisioningStateCreating), - string(ProvisioningStateDeleting), - string(ProvisioningStateDeprovisioned), - string(ProvisioningStateFailed), - string(ProvisioningStateMoving), - string(ProvisioningStateSucceeded), - string(ProvisioningStateSuspended), - string(ProvisioningStateSystemMaintenance), - string(ProvisioningStateUpdating), - string(ProvisioningStateVerifying), - string(ProvisioningStateWarned), - } -} - -func parseProvisioningState(input string) (*ProvisioningState, error) { - vals := map[string]ProvisioningState{ - "accepted": ProvisioningStateAccepted, - "canceled": ProvisioningStateCanceled, - "creating": ProvisioningStateCreating, - "deleting": ProvisioningStateDeleting, - "deprovisioned": ProvisioningStateDeprovisioned, - "failed": ProvisioningStateFailed, - "moving": ProvisioningStateMoving, - "succeeded": ProvisioningStateSucceeded, - "suspended": ProvisioningStateSuspended, - "systemmaintenance": ProvisioningStateSystemMaintenance, - "updating": ProvisioningStateUpdating, - "verifying": ProvisioningStateVerifying, - "warned": ProvisioningStateWarned, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := ProvisioningState(input) - return &out, nil -} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/id_fhirdestination.go b/internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/id_fhirdestination.go deleted file mode 100644 index 1c50fbf55c10..000000000000 --- a/internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/id_fhirdestination.go +++ /dev/null @@ -1,150 +0,0 @@ -package iotconnectors - -import ( - "fmt" - "strings" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -var _ resourceids.ResourceId = FhirDestinationId{} - -// FhirDestinationId is a struct representing the Resource ID for a Fhir Destination -type FhirDestinationId struct { - SubscriptionId string - ResourceGroupName string - WorkspaceName string - IotConnectorName string - FhirDestinationName string -} - -// NewFhirDestinationID returns a new FhirDestinationId struct -func NewFhirDestinationID(subscriptionId string, resourceGroupName string, workspaceName string, iotConnectorName string, fhirDestinationName string) FhirDestinationId { - return FhirDestinationId{ - SubscriptionId: subscriptionId, - ResourceGroupName: resourceGroupName, - WorkspaceName: workspaceName, - IotConnectorName: iotConnectorName, - FhirDestinationName: fhirDestinationName, - } -} - -// ParseFhirDestinationID parses 'input' into a FhirDestinationId -func ParseFhirDestinationID(input string) (*FhirDestinationId, error) { - parser := resourceids.NewParserFromResourceIdType(FhirDestinationId{}) - parsed, err := parser.Parse(input, false) - if err != nil { - return nil, fmt.Errorf("parsing %q: %+v", input, err) - } - - var ok bool - id := FhirDestinationId{} - - if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { - return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) - } - - if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { - return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) - } - - if id.WorkspaceName, ok = parsed.Parsed["workspaceName"]; !ok { - return nil, fmt.Errorf("the segment 'workspaceName' was not found in the resource id %q", input) - } - - if id.IotConnectorName, ok = parsed.Parsed["iotConnectorName"]; !ok { - return nil, fmt.Errorf("the segment 'iotConnectorName' was not found in the resource id %q", input) - } - - if id.FhirDestinationName, ok = parsed.Parsed["fhirDestinationName"]; !ok { - return nil, fmt.Errorf("the segment 'fhirDestinationName' was not found in the resource id %q", input) - } - - return &id, nil -} - -// ParseFhirDestinationIDInsensitively parses 'input' case-insensitively into a FhirDestinationId -// note: this method should only be used for API response data and not user input -func ParseFhirDestinationIDInsensitively(input string) (*FhirDestinationId, error) { - parser := resourceids.NewParserFromResourceIdType(FhirDestinationId{}) - parsed, err := parser.Parse(input, true) - if err != nil { - return nil, fmt.Errorf("parsing %q: %+v", input, err) - } - - var ok bool - id := FhirDestinationId{} - - if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { - return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) - } - - if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { - return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) - } - - if id.WorkspaceName, ok = parsed.Parsed["workspaceName"]; !ok { - return nil, fmt.Errorf("the segment 'workspaceName' was not found in the resource id %q", input) - } - - if id.IotConnectorName, ok = parsed.Parsed["iotConnectorName"]; !ok { - return nil, fmt.Errorf("the segment 'iotConnectorName' was not found in the resource id %q", input) - } - - if id.FhirDestinationName, ok = parsed.Parsed["fhirDestinationName"]; !ok { - return nil, fmt.Errorf("the segment 'fhirDestinationName' was not found in the resource id %q", input) - } - - return &id, nil -} - -// ValidateFhirDestinationID checks that 'input' can be parsed as a Fhir Destination ID -func ValidateFhirDestinationID(input interface{}, key string) (warnings []string, errors []error) { - v, ok := input.(string) - if !ok { - errors = append(errors, fmt.Errorf("expected %q to be a string", key)) - return - } - - if _, err := ParseFhirDestinationID(v); err != nil { - errors = append(errors, err) - } - - return -} - -// ID returns the formatted Fhir Destination ID -func (id FhirDestinationId) ID() string { - fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.HealthcareApis/workspaces/%s/iotConnectors/%s/fhirDestinations/%s" - return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.WorkspaceName, id.IotConnectorName, id.FhirDestinationName) -} - -// Segments returns a slice of Resource ID Segments which comprise this Fhir Destination ID -func (id FhirDestinationId) Segments() []resourceids.Segment { - return []resourceids.Segment{ - resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), - resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), - resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), - resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), - resourceids.StaticSegment("staticProviders", "providers", "providers"), - resourceids.ResourceProviderSegment("staticMicrosoftHealthcareApis", "Microsoft.HealthcareApis", "Microsoft.HealthcareApis"), - resourceids.StaticSegment("staticWorkspaces", "workspaces", "workspaces"), - resourceids.UserSpecifiedSegment("workspaceName", "workspaceValue"), - resourceids.StaticSegment("staticIotConnectors", "iotConnectors", "iotConnectors"), - resourceids.UserSpecifiedSegment("iotConnectorName", "iotConnectorValue"), - resourceids.StaticSegment("staticFhirDestinations", "fhirDestinations", "fhirDestinations"), - resourceids.UserSpecifiedSegment("fhirDestinationName", "fhirDestinationValue"), - } -} - -// String returns a human-readable description of this Fhir Destination ID -func (id FhirDestinationId) String() string { - components := []string{ - fmt.Sprintf("Subscription: %q", id.SubscriptionId), - fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), - fmt.Sprintf("Workspace Name: %q", id.WorkspaceName), - fmt.Sprintf("Iot Connector Name: %q", id.IotConnectorName), - fmt.Sprintf("Fhir Destination Name: %q", id.FhirDestinationName), - } - return fmt.Sprintf("Fhir Destination (%s)", strings.Join(components, "\n")) -} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/id_fhirdestination_test.go b/internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/id_fhirdestination_test.go deleted file mode 100644 index 04999190d678..000000000000 --- a/internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/id_fhirdestination_test.go +++ /dev/null @@ -1,369 +0,0 @@ -package iotconnectors - -import ( - "testing" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -var _ resourceids.ResourceId = FhirDestinationId{} - -func TestNewFhirDestinationID(t *testing.T) { - id := NewFhirDestinationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceValue", "iotConnectorValue", "fhirDestinationValue") - - if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { - t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") - } - - if id.ResourceGroupName != "example-resource-group" { - t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") - } - - if id.WorkspaceName != "workspaceValue" { - t.Fatalf("Expected %q but got %q for Segment 'WorkspaceName'", id.WorkspaceName, "workspaceValue") - } - - if id.IotConnectorName != "iotConnectorValue" { - t.Fatalf("Expected %q but got %q for Segment 'IotConnectorName'", id.IotConnectorName, "iotConnectorValue") - } - - if id.FhirDestinationName != "fhirDestinationValue" { - t.Fatalf("Expected %q but got %q for Segment 'FhirDestinationName'", id.FhirDestinationName, "fhirDestinationValue") - } -} - -func TestFormatFhirDestinationID(t *testing.T) { - actual := NewFhirDestinationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceValue", "iotConnectorValue", "fhirDestinationValue").ID() - expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/workspaces/workspaceValue/iotConnectors/iotConnectorValue/fhirDestinations/fhirDestinationValue" - if actual != expected { - t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) - } -} - -func TestParseFhirDestinationID(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *FhirDestinationId - }{ - { - // Incomplete URI - Input: "", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/workspaces", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/workspaces/workspaceValue", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/workspaces/workspaceValue/iotConnectors", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/workspaces/workspaceValue/iotConnectors/iotConnectorValue", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/workspaces/workspaceValue/iotConnectors/iotConnectorValue/fhirDestinations", - Error: true, - }, - { - // Valid URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/workspaces/workspaceValue/iotConnectors/iotConnectorValue/fhirDestinations/fhirDestinationValue", - Expected: &FhirDestinationId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "example-resource-group", - WorkspaceName: "workspaceValue", - IotConnectorName: "iotConnectorValue", - FhirDestinationName: "fhirDestinationValue", - }, - }, - { - // Invalid (Valid Uri with Extra segment) - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/workspaces/workspaceValue/iotConnectors/iotConnectorValue/fhirDestinations/fhirDestinationValue/extra", - Error: true, - }, - } - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := ParseFhirDestinationID(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expect a value but got an error: %+v", err) - } - if v.Error { - t.Fatal("Expect an error but didn't get one") - } - - if actual.SubscriptionId != v.Expected.SubscriptionId { - t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) - } - - if actual.ResourceGroupName != v.Expected.ResourceGroupName { - t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) - } - - if actual.WorkspaceName != v.Expected.WorkspaceName { - t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) - } - - if actual.IotConnectorName != v.Expected.IotConnectorName { - t.Fatalf("Expected %q but got %q for IotConnectorName", v.Expected.IotConnectorName, actual.IotConnectorName) - } - - if actual.FhirDestinationName != v.Expected.FhirDestinationName { - t.Fatalf("Expected %q but got %q for FhirDestinationName", v.Expected.FhirDestinationName, actual.FhirDestinationName) - } - - } -} - -func TestParseFhirDestinationIDInsensitively(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *FhirDestinationId - }{ - { - // Incomplete URI - Input: "", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hEaLtHcArEaPiS", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/workspaces", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hEaLtHcArEaPiS/wOrKsPaCeS", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/workspaces/workspaceValue", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hEaLtHcArEaPiS/wOrKsPaCeS/wOrKsPaCeVaLuE", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/workspaces/workspaceValue/iotConnectors", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hEaLtHcArEaPiS/wOrKsPaCeS/wOrKsPaCeVaLuE/iOtCoNnEcToRs", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/workspaces/workspaceValue/iotConnectors/iotConnectorValue", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hEaLtHcArEaPiS/wOrKsPaCeS/wOrKsPaCeVaLuE/iOtCoNnEcToRs/iOtCoNnEcToRvAlUe", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/workspaces/workspaceValue/iotConnectors/iotConnectorValue/fhirDestinations", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hEaLtHcArEaPiS/wOrKsPaCeS/wOrKsPaCeVaLuE/iOtCoNnEcToRs/iOtCoNnEcToRvAlUe/fHiRdEsTiNaTiOnS", - Error: true, - }, - { - // Valid URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/workspaces/workspaceValue/iotConnectors/iotConnectorValue/fhirDestinations/fhirDestinationValue", - Expected: &FhirDestinationId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "example-resource-group", - WorkspaceName: "workspaceValue", - IotConnectorName: "iotConnectorValue", - FhirDestinationName: "fhirDestinationValue", - }, - }, - { - // Invalid (Valid Uri with Extra segment) - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/workspaces/workspaceValue/iotConnectors/iotConnectorValue/fhirDestinations/fhirDestinationValue/extra", - Error: true, - }, - { - // Valid URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hEaLtHcArEaPiS/wOrKsPaCeS/wOrKsPaCeVaLuE/iOtCoNnEcToRs/iOtCoNnEcToRvAlUe/fHiRdEsTiNaTiOnS/fHiRdEsTiNaTiOnVaLuE", - Expected: &FhirDestinationId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", - WorkspaceName: "wOrKsPaCeVaLuE", - IotConnectorName: "iOtCoNnEcToRvAlUe", - FhirDestinationName: "fHiRdEsTiNaTiOnVaLuE", - }, - }, - { - // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hEaLtHcArEaPiS/wOrKsPaCeS/wOrKsPaCeVaLuE/iOtCoNnEcToRs/iOtCoNnEcToRvAlUe/fHiRdEsTiNaTiOnS/fHiRdEsTiNaTiOnVaLuE/extra", - Error: true, - }, - } - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := ParseFhirDestinationIDInsensitively(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expect a value but got an error: %+v", err) - } - if v.Error { - t.Fatal("Expect an error but didn't get one") - } - - if actual.SubscriptionId != v.Expected.SubscriptionId { - t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) - } - - if actual.ResourceGroupName != v.Expected.ResourceGroupName { - t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) - } - - if actual.WorkspaceName != v.Expected.WorkspaceName { - t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) - } - - if actual.IotConnectorName != v.Expected.IotConnectorName { - t.Fatalf("Expected %q but got %q for IotConnectorName", v.Expected.IotConnectorName, actual.IotConnectorName) - } - - if actual.FhirDestinationName != v.Expected.FhirDestinationName { - t.Fatalf("Expected %q but got %q for FhirDestinationName", v.Expected.FhirDestinationName, actual.FhirDestinationName) - } - - } -} - -func TestSegmentsForFhirDestinationId(t *testing.T) { - segments := FhirDestinationId{}.Segments() - if len(segments) == 0 { - t.Fatalf("FhirDestinationId has no segments") - } - - uniqueNames := make(map[string]struct{}, 0) - for _, segment := range segments { - uniqueNames[segment.Name] = struct{}{} - } - if len(uniqueNames) != len(segments) { - t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) - } -} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/id_iotconnector.go b/internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/id_iotconnector.go deleted file mode 100644 index 7188ae3eac54..000000000000 --- a/internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/id_iotconnector.go +++ /dev/null @@ -1,137 +0,0 @@ -package iotconnectors - -import ( - "fmt" - "strings" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -var _ resourceids.ResourceId = IotConnectorId{} - -// IotConnectorId is a struct representing the Resource ID for a Iot Connector -type IotConnectorId struct { - SubscriptionId string - ResourceGroupName string - WorkspaceName string - IotConnectorName string -} - -// NewIotConnectorID returns a new IotConnectorId struct -func NewIotConnectorID(subscriptionId string, resourceGroupName string, workspaceName string, iotConnectorName string) IotConnectorId { - return IotConnectorId{ - SubscriptionId: subscriptionId, - ResourceGroupName: resourceGroupName, - WorkspaceName: workspaceName, - IotConnectorName: iotConnectorName, - } -} - -// ParseIotConnectorID parses 'input' into a IotConnectorId -func ParseIotConnectorID(input string) (*IotConnectorId, error) { - parser := resourceids.NewParserFromResourceIdType(IotConnectorId{}) - parsed, err := parser.Parse(input, false) - if err != nil { - return nil, fmt.Errorf("parsing %q: %+v", input, err) - } - - var ok bool - id := IotConnectorId{} - - if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { - return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) - } - - if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { - return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) - } - - if id.WorkspaceName, ok = parsed.Parsed["workspaceName"]; !ok { - return nil, fmt.Errorf("the segment 'workspaceName' was not found in the resource id %q", input) - } - - if id.IotConnectorName, ok = parsed.Parsed["iotConnectorName"]; !ok { - return nil, fmt.Errorf("the segment 'iotConnectorName' was not found in the resource id %q", input) - } - - return &id, nil -} - -// ParseIotConnectorIDInsensitively parses 'input' case-insensitively into a IotConnectorId -// note: this method should only be used for API response data and not user input -func ParseIotConnectorIDInsensitively(input string) (*IotConnectorId, error) { - parser := resourceids.NewParserFromResourceIdType(IotConnectorId{}) - parsed, err := parser.Parse(input, true) - if err != nil { - return nil, fmt.Errorf("parsing %q: %+v", input, err) - } - - var ok bool - id := IotConnectorId{} - - if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { - return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) - } - - if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { - return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) - } - - if id.WorkspaceName, ok = parsed.Parsed["workspaceName"]; !ok { - return nil, fmt.Errorf("the segment 'workspaceName' was not found in the resource id %q", input) - } - - if id.IotConnectorName, ok = parsed.Parsed["iotConnectorName"]; !ok { - return nil, fmt.Errorf("the segment 'iotConnectorName' was not found in the resource id %q", input) - } - - return &id, nil -} - -// ValidateIotConnectorID checks that 'input' can be parsed as a Iot Connector ID -func ValidateIotConnectorID(input interface{}, key string) (warnings []string, errors []error) { - v, ok := input.(string) - if !ok { - errors = append(errors, fmt.Errorf("expected %q to be a string", key)) - return - } - - if _, err := ParseIotConnectorID(v); err != nil { - errors = append(errors, err) - } - - return -} - -// ID returns the formatted Iot Connector ID -func (id IotConnectorId) ID() string { - fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.HealthcareApis/workspaces/%s/iotConnectors/%s" - return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.WorkspaceName, id.IotConnectorName) -} - -// Segments returns a slice of Resource ID Segments which comprise this Iot Connector ID -func (id IotConnectorId) Segments() []resourceids.Segment { - return []resourceids.Segment{ - resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), - resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), - resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), - resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), - resourceids.StaticSegment("staticProviders", "providers", "providers"), - resourceids.ResourceProviderSegment("staticMicrosoftHealthcareApis", "Microsoft.HealthcareApis", "Microsoft.HealthcareApis"), - resourceids.StaticSegment("staticWorkspaces", "workspaces", "workspaces"), - resourceids.UserSpecifiedSegment("workspaceName", "workspaceValue"), - resourceids.StaticSegment("staticIotConnectors", "iotConnectors", "iotConnectors"), - resourceids.UserSpecifiedSegment("iotConnectorName", "iotConnectorValue"), - } -} - -// String returns a human-readable description of this Iot Connector ID -func (id IotConnectorId) String() string { - components := []string{ - fmt.Sprintf("Subscription: %q", id.SubscriptionId), - fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), - fmt.Sprintf("Workspace Name: %q", id.WorkspaceName), - fmt.Sprintf("Iot Connector Name: %q", id.IotConnectorName), - } - return fmt.Sprintf("Iot Connector (%s)", strings.Join(components, "\n")) -} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/id_iotconnector_test.go b/internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/id_iotconnector_test.go deleted file mode 100644 index c05aa57833bc..000000000000 --- a/internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/id_iotconnector_test.go +++ /dev/null @@ -1,324 +0,0 @@ -package iotconnectors - -import ( - "testing" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -var _ resourceids.ResourceId = IotConnectorId{} - -func TestNewIotConnectorID(t *testing.T) { - id := NewIotConnectorID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceValue", "iotConnectorValue") - - if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { - t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") - } - - if id.ResourceGroupName != "example-resource-group" { - t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") - } - - if id.WorkspaceName != "workspaceValue" { - t.Fatalf("Expected %q but got %q for Segment 'WorkspaceName'", id.WorkspaceName, "workspaceValue") - } - - if id.IotConnectorName != "iotConnectorValue" { - t.Fatalf("Expected %q but got %q for Segment 'IotConnectorName'", id.IotConnectorName, "iotConnectorValue") - } -} - -func TestFormatIotConnectorID(t *testing.T) { - actual := NewIotConnectorID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceValue", "iotConnectorValue").ID() - expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/workspaces/workspaceValue/iotConnectors/iotConnectorValue" - if actual != expected { - t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) - } -} - -func TestParseIotConnectorID(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *IotConnectorId - }{ - { - // Incomplete URI - Input: "", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/workspaces", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/workspaces/workspaceValue", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/workspaces/workspaceValue/iotConnectors", - Error: true, - }, - { - // Valid URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/workspaces/workspaceValue/iotConnectors/iotConnectorValue", - Expected: &IotConnectorId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "example-resource-group", - WorkspaceName: "workspaceValue", - IotConnectorName: "iotConnectorValue", - }, - }, - { - // Invalid (Valid Uri with Extra segment) - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/workspaces/workspaceValue/iotConnectors/iotConnectorValue/extra", - Error: true, - }, - } - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := ParseIotConnectorID(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expect a value but got an error: %+v", err) - } - if v.Error { - t.Fatal("Expect an error but didn't get one") - } - - if actual.SubscriptionId != v.Expected.SubscriptionId { - t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) - } - - if actual.ResourceGroupName != v.Expected.ResourceGroupName { - t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) - } - - if actual.WorkspaceName != v.Expected.WorkspaceName { - t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) - } - - if actual.IotConnectorName != v.Expected.IotConnectorName { - t.Fatalf("Expected %q but got %q for IotConnectorName", v.Expected.IotConnectorName, actual.IotConnectorName) - } - - } -} - -func TestParseIotConnectorIDInsensitively(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *IotConnectorId - }{ - { - // Incomplete URI - Input: "", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hEaLtHcArEaPiS", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/workspaces", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hEaLtHcArEaPiS/wOrKsPaCeS", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/workspaces/workspaceValue", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hEaLtHcArEaPiS/wOrKsPaCeS/wOrKsPaCeVaLuE", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/workspaces/workspaceValue/iotConnectors", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hEaLtHcArEaPiS/wOrKsPaCeS/wOrKsPaCeVaLuE/iOtCoNnEcToRs", - Error: true, - }, - { - // Valid URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/workspaces/workspaceValue/iotConnectors/iotConnectorValue", - Expected: &IotConnectorId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "example-resource-group", - WorkspaceName: "workspaceValue", - IotConnectorName: "iotConnectorValue", - }, - }, - { - // Invalid (Valid Uri with Extra segment) - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/workspaces/workspaceValue/iotConnectors/iotConnectorValue/extra", - Error: true, - }, - { - // Valid URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hEaLtHcArEaPiS/wOrKsPaCeS/wOrKsPaCeVaLuE/iOtCoNnEcToRs/iOtCoNnEcToRvAlUe", - Expected: &IotConnectorId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", - WorkspaceName: "wOrKsPaCeVaLuE", - IotConnectorName: "iOtCoNnEcToRvAlUe", - }, - }, - { - // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hEaLtHcArEaPiS/wOrKsPaCeS/wOrKsPaCeVaLuE/iOtCoNnEcToRs/iOtCoNnEcToRvAlUe/extra", - Error: true, - }, - } - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := ParseIotConnectorIDInsensitively(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expect a value but got an error: %+v", err) - } - if v.Error { - t.Fatal("Expect an error but didn't get one") - } - - if actual.SubscriptionId != v.Expected.SubscriptionId { - t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) - } - - if actual.ResourceGroupName != v.Expected.ResourceGroupName { - t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) - } - - if actual.WorkspaceName != v.Expected.WorkspaceName { - t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) - } - - if actual.IotConnectorName != v.Expected.IotConnectorName { - t.Fatalf("Expected %q but got %q for IotConnectorName", v.Expected.IotConnectorName, actual.IotConnectorName) - } - - } -} - -func TestSegmentsForIotConnectorId(t *testing.T) { - segments := IotConnectorId{}.Segments() - if len(segments) == 0 { - t.Fatalf("IotConnectorId has no segments") - } - - uniqueNames := make(map[string]struct{}, 0) - for _, segment := range segments { - uniqueNames[segment.Name] = struct{}{} - } - if len(uniqueNames) != len(segments) { - t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) - } -} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/id_workspace.go b/internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/id_workspace.go deleted file mode 100644 index dc5ca4d7ed70..000000000000 --- a/internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/id_workspace.go +++ /dev/null @@ -1,124 +0,0 @@ -package iotconnectors - -import ( - "fmt" - "strings" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -var _ resourceids.ResourceId = WorkspaceId{} - -// WorkspaceId is a struct representing the Resource ID for a Workspace -type WorkspaceId struct { - SubscriptionId string - ResourceGroupName string - WorkspaceName string -} - -// NewWorkspaceID returns a new WorkspaceId struct -func NewWorkspaceID(subscriptionId string, resourceGroupName string, workspaceName string) WorkspaceId { - return WorkspaceId{ - SubscriptionId: subscriptionId, - ResourceGroupName: resourceGroupName, - WorkspaceName: workspaceName, - } -} - -// ParseWorkspaceID parses 'input' into a WorkspaceId -func ParseWorkspaceID(input string) (*WorkspaceId, error) { - parser := resourceids.NewParserFromResourceIdType(WorkspaceId{}) - parsed, err := parser.Parse(input, false) - if err != nil { - return nil, fmt.Errorf("parsing %q: %+v", input, err) - } - - var ok bool - id := WorkspaceId{} - - if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { - return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) - } - - if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { - return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) - } - - if id.WorkspaceName, ok = parsed.Parsed["workspaceName"]; !ok { - return nil, fmt.Errorf("the segment 'workspaceName' was not found in the resource id %q", input) - } - - return &id, nil -} - -// ParseWorkspaceIDInsensitively parses 'input' case-insensitively into a WorkspaceId -// note: this method should only be used for API response data and not user input -func ParseWorkspaceIDInsensitively(input string) (*WorkspaceId, error) { - parser := resourceids.NewParserFromResourceIdType(WorkspaceId{}) - parsed, err := parser.Parse(input, true) - if err != nil { - return nil, fmt.Errorf("parsing %q: %+v", input, err) - } - - var ok bool - id := WorkspaceId{} - - if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { - return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) - } - - if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { - return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) - } - - if id.WorkspaceName, ok = parsed.Parsed["workspaceName"]; !ok { - return nil, fmt.Errorf("the segment 'workspaceName' was not found in the resource id %q", input) - } - - return &id, nil -} - -// ValidateWorkspaceID checks that 'input' can be parsed as a Workspace ID -func ValidateWorkspaceID(input interface{}, key string) (warnings []string, errors []error) { - v, ok := input.(string) - if !ok { - errors = append(errors, fmt.Errorf("expected %q to be a string", key)) - return - } - - if _, err := ParseWorkspaceID(v); err != nil { - errors = append(errors, err) - } - - return -} - -// ID returns the formatted Workspace ID -func (id WorkspaceId) ID() string { - fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.HealthcareApis/workspaces/%s" - return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.WorkspaceName) -} - -// Segments returns a slice of Resource ID Segments which comprise this Workspace ID -func (id WorkspaceId) Segments() []resourceids.Segment { - return []resourceids.Segment{ - resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), - resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), - resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), - resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), - resourceids.StaticSegment("staticProviders", "providers", "providers"), - resourceids.ResourceProviderSegment("staticMicrosoftHealthcareApis", "Microsoft.HealthcareApis", "Microsoft.HealthcareApis"), - resourceids.StaticSegment("staticWorkspaces", "workspaces", "workspaces"), - resourceids.UserSpecifiedSegment("workspaceName", "workspaceValue"), - } -} - -// String returns a human-readable description of this Workspace ID -func (id WorkspaceId) String() string { - components := []string{ - fmt.Sprintf("Subscription: %q", id.SubscriptionId), - fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), - fmt.Sprintf("Workspace Name: %q", id.WorkspaceName), - } - return fmt.Sprintf("Workspace (%s)", strings.Join(components, "\n")) -} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/id_workspace_test.go b/internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/id_workspace_test.go deleted file mode 100644 index 71cf45cc1ade..000000000000 --- a/internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/id_workspace_test.go +++ /dev/null @@ -1,279 +0,0 @@ -package iotconnectors - -import ( - "testing" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -var _ resourceids.ResourceId = WorkspaceId{} - -func TestNewWorkspaceID(t *testing.T) { - id := NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceValue") - - if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { - t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") - } - - if id.ResourceGroupName != "example-resource-group" { - t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") - } - - if id.WorkspaceName != "workspaceValue" { - t.Fatalf("Expected %q but got %q for Segment 'WorkspaceName'", id.WorkspaceName, "workspaceValue") - } -} - -func TestFormatWorkspaceID(t *testing.T) { - actual := NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceValue").ID() - expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/workspaces/workspaceValue" - if actual != expected { - t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) - } -} - -func TestParseWorkspaceID(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *WorkspaceId - }{ - { - // Incomplete URI - Input: "", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/workspaces", - Error: true, - }, - { - // Valid URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/workspaces/workspaceValue", - Expected: &WorkspaceId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "example-resource-group", - WorkspaceName: "workspaceValue", - }, - }, - { - // Invalid (Valid Uri with Extra segment) - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/workspaces/workspaceValue/extra", - Error: true, - }, - } - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := ParseWorkspaceID(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expect a value but got an error: %+v", err) - } - if v.Error { - t.Fatal("Expect an error but didn't get one") - } - - if actual.SubscriptionId != v.Expected.SubscriptionId { - t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) - } - - if actual.ResourceGroupName != v.Expected.ResourceGroupName { - t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) - } - - if actual.WorkspaceName != v.Expected.WorkspaceName { - t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) - } - - } -} - -func TestParseWorkspaceIDInsensitively(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *WorkspaceId - }{ - { - // Incomplete URI - Input: "", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hEaLtHcArEaPiS", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/workspaces", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hEaLtHcArEaPiS/wOrKsPaCeS", - Error: true, - }, - { - // Valid URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/workspaces/workspaceValue", - Expected: &WorkspaceId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "example-resource-group", - WorkspaceName: "workspaceValue", - }, - }, - { - // Invalid (Valid Uri with Extra segment) - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/workspaces/workspaceValue/extra", - Error: true, - }, - { - // Valid URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hEaLtHcArEaPiS/wOrKsPaCeS/wOrKsPaCeVaLuE", - Expected: &WorkspaceId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", - WorkspaceName: "wOrKsPaCeVaLuE", - }, - }, - { - // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hEaLtHcArEaPiS/wOrKsPaCeS/wOrKsPaCeVaLuE/extra", - Error: true, - }, - } - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := ParseWorkspaceIDInsensitively(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expect a value but got an error: %+v", err) - } - if v.Error { - t.Fatal("Expect an error but didn't get one") - } - - if actual.SubscriptionId != v.Expected.SubscriptionId { - t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) - } - - if actual.ResourceGroupName != v.Expected.ResourceGroupName { - t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) - } - - if actual.WorkspaceName != v.Expected.WorkspaceName { - t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) - } - - } -} - -func TestSegmentsForWorkspaceId(t *testing.T) { - segments := WorkspaceId{}.Segments() - if len(segments) == 0 { - t.Fatalf("WorkspaceId has no segments") - } - - uniqueNames := make(map[string]struct{}, 0) - for _, segment := range segments { - uniqueNames[segment.Name] = struct{}{} - } - if len(uniqueNames) != len(segments) { - t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) - } -} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/method_createorupdate_autorest.go b/internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/method_createorupdate_autorest.go deleted file mode 100644 index ddd01a3d9e3c..000000000000 --- a/internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/method_createorupdate_autorest.go +++ /dev/null @@ -1,75 +0,0 @@ -package iotconnectors - -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" -) - -type CreateOrUpdateResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// CreateOrUpdate ... -func (c IotConnectorsClient) CreateOrUpdate(ctx context.Context, id IotConnectorId, input IotConnector) (result CreateOrUpdateResponse, err error) { - req, err := c.preparerForCreateOrUpdate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "iotconnectors.IotConnectorsClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result, err = c.senderForCreateOrUpdate(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "iotconnectors.IotConnectorsClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed -func (c IotConnectorsClient) CreateOrUpdateThenPoll(ctx context.Context, id IotConnectorId, input IotConnector) 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 IotConnectorsClient) preparerForCreateOrUpdate(ctx context.Context, id IotConnectorId, input IotConnector) (*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 IotConnectorsClient) senderForCreateOrUpdate(ctx context.Context, req *http.Request) (future CreateOrUpdateResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - future.Poller, err = polling.NewLongRunningPollerFromResponse(ctx, resp, c.Client) - return -} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/method_delete_autorest.go b/internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/method_delete_autorest.go deleted file mode 100644 index af3c325d03d3..000000000000 --- a/internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/method_delete_autorest.go +++ /dev/null @@ -1,74 +0,0 @@ -package iotconnectors - -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" -) - -type DeleteResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// Delete ... -func (c IotConnectorsClient) Delete(ctx context.Context, id IotConnectorId) (result DeleteResponse, err error) { - req, err := c.preparerForDelete(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "iotconnectors.IotConnectorsClient", "Delete", nil, "Failure preparing request") - return - } - - result, err = c.senderForDelete(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "iotconnectors.IotConnectorsClient", "Delete", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// DeleteThenPoll performs Delete then polls until it's completed -func (c IotConnectorsClient) DeleteThenPoll(ctx context.Context, id IotConnectorId) 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 IotConnectorsClient) preparerForDelete(ctx context.Context, id IotConnectorId) (*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 IotConnectorsClient) senderForDelete(ctx context.Context, req *http.Request) (future DeleteResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - future.Poller, err = polling.NewLongRunningPollerFromResponse(ctx, resp, c.Client) - return -} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/method_fhirdestinationslistbyiotconnector_autorest.go b/internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/method_fhirdestinationslistbyiotconnector_autorest.go deleted file mode 100644 index ef5526815211..000000000000 --- a/internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/method_fhirdestinationslistbyiotconnector_autorest.go +++ /dev/null @@ -1,183 +0,0 @@ -package iotconnectors - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -type FhirDestinationsListByIotConnectorResponse struct { - HttpResponse *http.Response - Model *[]IotFhirDestination - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (FhirDestinationsListByIotConnectorResponse, error) -} - -type FhirDestinationsListByIotConnectorCompleteResult struct { - Items []IotFhirDestination -} - -func (r FhirDestinationsListByIotConnectorResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r FhirDestinationsListByIotConnectorResponse) LoadMore(ctx context.Context) (resp FhirDestinationsListByIotConnectorResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// FhirDestinationsListByIotConnector ... -func (c IotConnectorsClient) FhirDestinationsListByIotConnector(ctx context.Context, id IotConnectorId) (resp FhirDestinationsListByIotConnectorResponse, err error) { - req, err := c.preparerForFhirDestinationsListByIotConnector(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "iotconnectors.IotConnectorsClient", "FhirDestinationsListByIotConnector", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "iotconnectors.IotConnectorsClient", "FhirDestinationsListByIotConnector", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForFhirDestinationsListByIotConnector(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "iotconnectors.IotConnectorsClient", "FhirDestinationsListByIotConnector", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// FhirDestinationsListByIotConnectorComplete retrieves all of the results into a single object -func (c IotConnectorsClient) FhirDestinationsListByIotConnectorComplete(ctx context.Context, id IotConnectorId) (FhirDestinationsListByIotConnectorCompleteResult, error) { - return c.FhirDestinationsListByIotConnectorCompleteMatchingPredicate(ctx, id, IotFhirDestinationPredicate{}) -} - -// FhirDestinationsListByIotConnectorCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c IotConnectorsClient) FhirDestinationsListByIotConnectorCompleteMatchingPredicate(ctx context.Context, id IotConnectorId, predicate IotFhirDestinationPredicate) (resp FhirDestinationsListByIotConnectorCompleteResult, err error) { - items := make([]IotFhirDestination, 0) - - page, err := c.FhirDestinationsListByIotConnector(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 := FhirDestinationsListByIotConnectorCompleteResult{ - Items: items, - } - return out, nil -} - -// preparerForFhirDestinationsListByIotConnector prepares the FhirDestinationsListByIotConnector request. -func (c IotConnectorsClient) preparerForFhirDestinationsListByIotConnector(ctx context.Context, id IotConnectorId) (*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/fhirDestinations", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForFhirDestinationsListByIotConnectorWithNextLink prepares the FhirDestinationsListByIotConnector request with the given nextLink token. -func (c IotConnectorsClient) preparerForFhirDestinationsListByIotConnectorWithNextLink(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)) -} - -// responderForFhirDestinationsListByIotConnector handles the response to the FhirDestinationsListByIotConnector request. The method always -// closes the http.Response Body. -func (c IotConnectorsClient) responderForFhirDestinationsListByIotConnector(resp *http.Response) (result FhirDestinationsListByIotConnectorResponse, err error) { - type page struct { - Values []IotFhirDestination `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 FhirDestinationsListByIotConnectorResponse, err error) { - req, err := c.preparerForFhirDestinationsListByIotConnectorWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "iotconnectors.IotConnectorsClient", "FhirDestinationsListByIotConnector", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "iotconnectors.IotConnectorsClient", "FhirDestinationsListByIotConnector", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForFhirDestinationsListByIotConnector(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "iotconnectors.IotConnectorsClient", "FhirDestinationsListByIotConnector", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/method_get_autorest.go b/internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/method_get_autorest.go deleted file mode 100644 index 097d83b2e092..000000000000 --- a/internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/method_get_autorest.go +++ /dev/null @@ -1,64 +0,0 @@ -package iotconnectors - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -type GetResponse struct { - HttpResponse *http.Response - Model *IotConnector -} - -// Get ... -func (c IotConnectorsClient) Get(ctx context.Context, id IotConnectorId) (result GetResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "iotconnectors.IotConnectorsClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "iotconnectors.IotConnectorsClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "iotconnectors.IotConnectorsClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c IotConnectorsClient) preparerForGet(ctx context.Context, id IotConnectorId) (*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 IotConnectorsClient) responderForGet(resp *http.Response) (result GetResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - return -} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/method_iotconnectorfhirdestinationcreateorupdate_autorest.go b/internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/method_iotconnectorfhirdestinationcreateorupdate_autorest.go deleted file mode 100644 index f2487864f453..000000000000 --- a/internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/method_iotconnectorfhirdestinationcreateorupdate_autorest.go +++ /dev/null @@ -1,75 +0,0 @@ -package iotconnectors - -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" -) - -type IotConnectorFhirDestinationCreateOrUpdateResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// IotConnectorFhirDestinationCreateOrUpdate ... -func (c IotConnectorsClient) IotConnectorFhirDestinationCreateOrUpdate(ctx context.Context, id FhirDestinationId, input IotFhirDestination) (result IotConnectorFhirDestinationCreateOrUpdateResponse, err error) { - req, err := c.preparerForIotConnectorFhirDestinationCreateOrUpdate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "iotconnectors.IotConnectorsClient", "IotConnectorFhirDestinationCreateOrUpdate", nil, "Failure preparing request") - return - } - - result, err = c.senderForIotConnectorFhirDestinationCreateOrUpdate(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "iotconnectors.IotConnectorsClient", "IotConnectorFhirDestinationCreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// IotConnectorFhirDestinationCreateOrUpdateThenPoll performs IotConnectorFhirDestinationCreateOrUpdate then polls until it's completed -func (c IotConnectorsClient) IotConnectorFhirDestinationCreateOrUpdateThenPoll(ctx context.Context, id FhirDestinationId, input IotFhirDestination) error { - result, err := c.IotConnectorFhirDestinationCreateOrUpdate(ctx, id, input) - if err != nil { - return fmt.Errorf("performing IotConnectorFhirDestinationCreateOrUpdate: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after IotConnectorFhirDestinationCreateOrUpdate: %+v", err) - } - - return nil -} - -// preparerForIotConnectorFhirDestinationCreateOrUpdate prepares the IotConnectorFhirDestinationCreateOrUpdate request. -func (c IotConnectorsClient) preparerForIotConnectorFhirDestinationCreateOrUpdate(ctx context.Context, id FhirDestinationId, input IotFhirDestination) (*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)) -} - -// senderForIotConnectorFhirDestinationCreateOrUpdate sends the IotConnectorFhirDestinationCreateOrUpdate request. The method will close the -// http.Response Body if it receives an error. -func (c IotConnectorsClient) senderForIotConnectorFhirDestinationCreateOrUpdate(ctx context.Context, req *http.Request) (future IotConnectorFhirDestinationCreateOrUpdateResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - future.Poller, err = polling.NewLongRunningPollerFromResponse(ctx, resp, c.Client) - return -} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/method_iotconnectorfhirdestinationdelete_autorest.go b/internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/method_iotconnectorfhirdestinationdelete_autorest.go deleted file mode 100644 index 1c1c35e065e8..000000000000 --- a/internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/method_iotconnectorfhirdestinationdelete_autorest.go +++ /dev/null @@ -1,74 +0,0 @@ -package iotconnectors - -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" -) - -type IotConnectorFhirDestinationDeleteResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// IotConnectorFhirDestinationDelete ... -func (c IotConnectorsClient) IotConnectorFhirDestinationDelete(ctx context.Context, id FhirDestinationId) (result IotConnectorFhirDestinationDeleteResponse, err error) { - req, err := c.preparerForIotConnectorFhirDestinationDelete(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "iotconnectors.IotConnectorsClient", "IotConnectorFhirDestinationDelete", nil, "Failure preparing request") - return - } - - result, err = c.senderForIotConnectorFhirDestinationDelete(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "iotconnectors.IotConnectorsClient", "IotConnectorFhirDestinationDelete", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// IotConnectorFhirDestinationDeleteThenPoll performs IotConnectorFhirDestinationDelete then polls until it's completed -func (c IotConnectorsClient) IotConnectorFhirDestinationDeleteThenPoll(ctx context.Context, id FhirDestinationId) error { - result, err := c.IotConnectorFhirDestinationDelete(ctx, id) - if err != nil { - return fmt.Errorf("performing IotConnectorFhirDestinationDelete: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after IotConnectorFhirDestinationDelete: %+v", err) - } - - return nil -} - -// preparerForIotConnectorFhirDestinationDelete prepares the IotConnectorFhirDestinationDelete request. -func (c IotConnectorsClient) preparerForIotConnectorFhirDestinationDelete(ctx context.Context, id FhirDestinationId) (*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)) -} - -// senderForIotConnectorFhirDestinationDelete sends the IotConnectorFhirDestinationDelete request. The method will close the -// http.Response Body if it receives an error. -func (c IotConnectorsClient) senderForIotConnectorFhirDestinationDelete(ctx context.Context, req *http.Request) (future IotConnectorFhirDestinationDeleteResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - future.Poller, err = polling.NewLongRunningPollerFromResponse(ctx, resp, c.Client) - return -} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/method_iotconnectorfhirdestinationget_autorest.go b/internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/method_iotconnectorfhirdestinationget_autorest.go deleted file mode 100644 index 81cf2854678a..000000000000 --- a/internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/method_iotconnectorfhirdestinationget_autorest.go +++ /dev/null @@ -1,64 +0,0 @@ -package iotconnectors - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -type IotConnectorFhirDestinationGetResponse struct { - HttpResponse *http.Response - Model *IotFhirDestination -} - -// IotConnectorFhirDestinationGet ... -func (c IotConnectorsClient) IotConnectorFhirDestinationGet(ctx context.Context, id FhirDestinationId) (result IotConnectorFhirDestinationGetResponse, err error) { - req, err := c.preparerForIotConnectorFhirDestinationGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "iotconnectors.IotConnectorsClient", "IotConnectorFhirDestinationGet", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "iotconnectors.IotConnectorsClient", "IotConnectorFhirDestinationGet", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForIotConnectorFhirDestinationGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "iotconnectors.IotConnectorsClient", "IotConnectorFhirDestinationGet", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForIotConnectorFhirDestinationGet prepares the IotConnectorFhirDestinationGet request. -func (c IotConnectorsClient) preparerForIotConnectorFhirDestinationGet(ctx context.Context, id FhirDestinationId) (*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)) -} - -// responderForIotConnectorFhirDestinationGet handles the response to the IotConnectorFhirDestinationGet request. The method always -// closes the http.Response Body. -func (c IotConnectorsClient) responderForIotConnectorFhirDestinationGet(resp *http.Response) (result IotConnectorFhirDestinationGetResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - return -} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/method_listbyworkspace_autorest.go b/internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/method_listbyworkspace_autorest.go deleted file mode 100644 index 20359d309383..000000000000 --- a/internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/method_listbyworkspace_autorest.go +++ /dev/null @@ -1,183 +0,0 @@ -package iotconnectors - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -type ListByWorkspaceResponse struct { - HttpResponse *http.Response - Model *[]IotConnector - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListByWorkspaceResponse, error) -} - -type ListByWorkspaceCompleteResult struct { - Items []IotConnector -} - -func (r ListByWorkspaceResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListByWorkspaceResponse) LoadMore(ctx context.Context) (resp ListByWorkspaceResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListByWorkspace ... -func (c IotConnectorsClient) ListByWorkspace(ctx context.Context, id WorkspaceId) (resp ListByWorkspaceResponse, err error) { - req, err := c.preparerForListByWorkspace(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "iotconnectors.IotConnectorsClient", "ListByWorkspace", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "iotconnectors.IotConnectorsClient", "ListByWorkspace", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListByWorkspace(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "iotconnectors.IotConnectorsClient", "ListByWorkspace", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// ListByWorkspaceComplete retrieves all of the results into a single object -func (c IotConnectorsClient) ListByWorkspaceComplete(ctx context.Context, id WorkspaceId) (ListByWorkspaceCompleteResult, error) { - return c.ListByWorkspaceCompleteMatchingPredicate(ctx, id, IotConnectorPredicate{}) -} - -// ListByWorkspaceCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c IotConnectorsClient) ListByWorkspaceCompleteMatchingPredicate(ctx context.Context, id WorkspaceId, predicate IotConnectorPredicate) (resp ListByWorkspaceCompleteResult, err error) { - items := make([]IotConnector, 0) - - page, err := c.ListByWorkspace(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 := ListByWorkspaceCompleteResult{ - Items: items, - } - return out, nil -} - -// preparerForListByWorkspace prepares the ListByWorkspace request. -func (c IotConnectorsClient) preparerForListByWorkspace(ctx context.Context, id WorkspaceId) (*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/iotConnectors", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListByWorkspaceWithNextLink prepares the ListByWorkspace request with the given nextLink token. -func (c IotConnectorsClient) preparerForListByWorkspaceWithNextLink(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)) -} - -// responderForListByWorkspace handles the response to the ListByWorkspace request. The method always -// closes the http.Response Body. -func (c IotConnectorsClient) responderForListByWorkspace(resp *http.Response) (result ListByWorkspaceResponse, err error) { - type page struct { - Values []IotConnector `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 ListByWorkspaceResponse, err error) { - req, err := c.preparerForListByWorkspaceWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "iotconnectors.IotConnectorsClient", "ListByWorkspace", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "iotconnectors.IotConnectorsClient", "ListByWorkspace", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByWorkspace(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "iotconnectors.IotConnectorsClient", "ListByWorkspace", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/method_update_autorest.go b/internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/method_update_autorest.go deleted file mode 100644 index 181a12ba76fd..000000000000 --- a/internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/method_update_autorest.go +++ /dev/null @@ -1,75 +0,0 @@ -package iotconnectors - -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" -) - -type UpdateResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// Update ... -func (c IotConnectorsClient) Update(ctx context.Context, id IotConnectorId, input IotConnectorPatchResource) (result UpdateResponse, err error) { - req, err := c.preparerForUpdate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "iotconnectors.IotConnectorsClient", "Update", nil, "Failure preparing request") - return - } - - result, err = c.senderForUpdate(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "iotconnectors.IotConnectorsClient", "Update", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// UpdateThenPoll performs Update then polls until it's completed -func (c IotConnectorsClient) UpdateThenPoll(ctx context.Context, id IotConnectorId, input IotConnectorPatchResource) 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 IotConnectorsClient) preparerForUpdate(ctx context.Context, id IotConnectorId, input IotConnectorPatchResource) (*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 IotConnectorsClient) senderForUpdate(ctx context.Context, req *http.Request) (future UpdateResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - future.Poller, err = polling.NewLongRunningPollerFromResponse(ctx, resp, c.Client) - return -} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/model_iotconnector.go b/internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/model_iotconnector.go deleted file mode 100644 index 3c9c43084af5..000000000000 --- a/internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/model_iotconnector.go +++ /dev/null @@ -1,13 +0,0 @@ -package iotconnectors - -type IotConnector struct { - Etag *string `json:"etag,omitempty"` - Id *string `json:"id,omitempty"` - Identity *ServiceManagedIdentityIdentity `json:"identity,omitempty"` - Location *string `json:"location,omitempty"` - Name *string `json:"name,omitempty"` - Properties *IotConnectorProperties `json:"properties,omitempty"` - SystemData *SystemData `json:"systemData,omitempty"` - Tags *map[string]string `json:"tags,omitempty"` - Type *string `json:"type,omitempty"` -} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/model_iotconnectorpatchresource.go b/internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/model_iotconnectorpatchresource.go deleted file mode 100644 index 4c980b149b47..000000000000 --- a/internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/model_iotconnectorpatchresource.go +++ /dev/null @@ -1,6 +0,0 @@ -package iotconnectors - -type IotConnectorPatchResource struct { - Identity *ServiceManagedIdentityIdentity `json:"identity,omitempty"` - Tags *map[string]string `json:"tags,omitempty"` -} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/model_iotconnectorproperties.go b/internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/model_iotconnectorproperties.go deleted file mode 100644 index 1102fd1e56f4..000000000000 --- a/internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/model_iotconnectorproperties.go +++ /dev/null @@ -1,7 +0,0 @@ -package iotconnectors - -type IotConnectorProperties struct { - DeviceMapping *IotMappingProperties `json:"deviceMapping,omitempty"` - IngestionEndpointConfiguration *IotEventHubIngestionEndpointConfiguration `json:"ingestionEndpointConfiguration,omitempty"` - ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` -} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/model_ioteventhubingestionendpointconfiguration.go b/internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/model_ioteventhubingestionendpointconfiguration.go deleted file mode 100644 index e34400fc4440..000000000000 --- a/internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/model_ioteventhubingestionendpointconfiguration.go +++ /dev/null @@ -1,7 +0,0 @@ -package iotconnectors - -type IotEventHubIngestionEndpointConfiguration struct { - ConsumerGroup *string `json:"consumerGroup,omitempty"` - EventHubName *string `json:"eventHubName,omitempty"` - FullyQualifiedEventHubNamespace *string `json:"fullyQualifiedEventHubNamespace,omitempty"` -} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/model_iotfhirdestination.go b/internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/model_iotfhirdestination.go deleted file mode 100644 index 0a3bdef0662e..000000000000 --- a/internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/model_iotfhirdestination.go +++ /dev/null @@ -1,11 +0,0 @@ -package iotconnectors - -type IotFhirDestination struct { - Etag *string `json:"etag,omitempty"` - Id *string `json:"id,omitempty"` - Location *string `json:"location,omitempty"` - Name *string `json:"name,omitempty"` - Properties IotFhirDestinationProperties `json:"properties"` - SystemData *SystemData `json:"systemData,omitempty"` - Type *string `json:"type,omitempty"` -} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/model_iotfhirdestinationproperties.go b/internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/model_iotfhirdestinationproperties.go deleted file mode 100644 index b86368e0ce81..000000000000 --- a/internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/model_iotfhirdestinationproperties.go +++ /dev/null @@ -1,8 +0,0 @@ -package iotconnectors - -type IotFhirDestinationProperties struct { - FhirMapping IotMappingProperties `json:"fhirMapping"` - FhirServiceResourceId string `json:"fhirServiceResourceId"` - ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` - ResourceIdentityResolutionType IotIdentityResolutionType `json:"resourceIdentityResolutionType"` -} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/model_iotmappingproperties.go b/internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/model_iotmappingproperties.go deleted file mode 100644 index 9cba478c4d2b..000000000000 --- a/internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/model_iotmappingproperties.go +++ /dev/null @@ -1,5 +0,0 @@ -package iotconnectors - -type IotMappingProperties struct { - Content *interface{} `json:"content,omitempty"` -} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/model_servicemanagedidentityidentity.go b/internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/model_servicemanagedidentityidentity.go deleted file mode 100644 index eb6d993f1928..000000000000 --- a/internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/model_servicemanagedidentityidentity.go +++ /dev/null @@ -1,5 +0,0 @@ -package iotconnectors - -type ServiceManagedIdentityIdentity struct { - Type *ManagedServiceIdentityType `json:"type,omitempty"` -} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/model_systemdata.go b/internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/model_systemdata.go deleted file mode 100644 index b911891fcd2f..000000000000 --- a/internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/model_systemdata.go +++ /dev/null @@ -1,40 +0,0 @@ -package iotconnectors - -import ( - "time" - - "github.com/hashicorp/go-azure-helpers/lang/dates" -) - -type SystemData struct { - CreatedAt *string `json:"createdAt,omitempty"` - CreatedBy *string `json:"createdBy,omitempty"` - CreatedByType *CreatedByType `json:"createdByType,omitempty"` - LastModifiedAt *string `json:"lastModifiedAt,omitempty"` - LastModifiedBy *string `json:"lastModifiedBy,omitempty"` - LastModifiedByType *CreatedByType `json:"lastModifiedByType,omitempty"` -} - -func (o SystemData) GetCreatedAtAsTime() (*time.Time, error) { - if o.CreatedAt == nil { - return nil, nil - } - return dates.ParseAsFormat(o.CreatedAt, "2006-01-02T15:04:05Z07:00") -} - -func (o SystemData) SetCreatedAtAsTime(input time.Time) { - formatted := input.Format("2006-01-02T15:04:05Z07:00") - o.CreatedAt = &formatted -} - -func (o SystemData) GetLastModifiedAtAsTime() (*time.Time, error) { - if o.LastModifiedAt == nil { - return nil, nil - } - return dates.ParseAsFormat(o.LastModifiedAt, "2006-01-02T15:04:05Z07:00") -} - -func (o SystemData) SetLastModifiedAtAsTime(input time.Time) { - formatted := input.Format("2006-01-02T15:04:05Z07:00") - o.LastModifiedAt = &formatted -} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/predicates.go b/internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/predicates.go deleted file mode 100644 index 9d1c0b3fa06e..000000000000 --- a/internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/predicates.go +++ /dev/null @@ -1,67 +0,0 @@ -package iotconnectors - -type IotConnectorPredicate struct { - Etag *string - Id *string - Location *string - Name *string - Type *string -} - -func (p IotConnectorPredicate) Matches(input IotConnector) bool { - - if p.Etag != nil && (input.Etag == nil && *p.Etag != *input.Etag) { - return false - } - - if p.Id != nil && (input.Id == nil && *p.Id != *input.Id) { - return false - } - - if p.Location != nil && (input.Location == nil && *p.Location != *input.Location) { - return false - } - - if p.Name != nil && (input.Name == nil && *p.Name != *input.Name) { - return false - } - - if p.Type != nil && (input.Type == nil && *p.Type != *input.Type) { - return false - } - - return true -} - -type IotFhirDestinationPredicate struct { - Etag *string - Id *string - Location *string - Name *string - Type *string -} - -func (p IotFhirDestinationPredicate) Matches(input IotFhirDestination) bool { - - if p.Etag != nil && (input.Etag == nil && *p.Etag != *input.Etag) { - return false - } - - if p.Id != nil && (input.Id == nil && *p.Id != *input.Id) { - return false - } - - if p.Location != nil && (input.Location == nil && *p.Location != *input.Location) { - return false - } - - if p.Name != nil && (input.Name == nil && *p.Name != *input.Name) { - return false - } - - if p.Type != nil && (input.Type == nil && *p.Type != *input.Type) { - return false - } - - return true -} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/version.go b/internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/version.go deleted file mode 100644 index 1fd7f1e701a0..000000000000 --- a/internal/services/healthcare/sdk/2021-06-01-preview/iotconnectors/version.go +++ /dev/null @@ -1,9 +0,0 @@ -package iotconnectors - -import "fmt" - -const defaultApiVersion = "2021-06-01-preview" - -func userAgent() string { - return fmt.Sprintf("pandora/iotconnectors/%s", defaultApiVersion) -} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/privateendpointconnections/client.go b/internal/services/healthcare/sdk/2021-06-01-preview/privateendpointconnections/client.go deleted file mode 100644 index adc4283affb2..000000000000 --- a/internal/services/healthcare/sdk/2021-06-01-preview/privateendpointconnections/client.go +++ /dev/null @@ -1,15 +0,0 @@ -package privateendpointconnections - -import "github.com/Azure/go-autorest/autorest" - -type PrivateEndpointConnectionsClient struct { - Client autorest.Client - baseUri string -} - -func NewPrivateEndpointConnectionsClientWithBaseURI(endpoint string) PrivateEndpointConnectionsClient { - return PrivateEndpointConnectionsClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, - } -} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/privateendpointconnections/constants.go b/internal/services/healthcare/sdk/2021-06-01-preview/privateendpointconnections/constants.go deleted file mode 100644 index 32001a4a5e77..000000000000 --- a/internal/services/healthcare/sdk/2021-06-01-preview/privateendpointconnections/constants.go +++ /dev/null @@ -1,102 +0,0 @@ -package privateendpointconnections - -import "strings" - -type CreatedByType string - -const ( - CreatedByTypeApplication CreatedByType = "Application" - CreatedByTypeKey CreatedByType = "Key" - CreatedByTypeManagedIdentity CreatedByType = "ManagedIdentity" - CreatedByTypeUser CreatedByType = "User" -) - -func PossibleValuesForCreatedByType() []string { - return []string{ - string(CreatedByTypeApplication), - string(CreatedByTypeKey), - string(CreatedByTypeManagedIdentity), - string(CreatedByTypeUser), - } -} - -func parseCreatedByType(input string) (*CreatedByType, error) { - vals := map[string]CreatedByType{ - "application": CreatedByTypeApplication, - "key": CreatedByTypeKey, - "managedidentity": CreatedByTypeManagedIdentity, - "user": CreatedByTypeUser, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := CreatedByType(input) - return &out, nil -} - -type PrivateEndpointConnectionProvisioningState string - -const ( - PrivateEndpointConnectionProvisioningStateCreating PrivateEndpointConnectionProvisioningState = "Creating" - PrivateEndpointConnectionProvisioningStateDeleting PrivateEndpointConnectionProvisioningState = "Deleting" - PrivateEndpointConnectionProvisioningStateFailed PrivateEndpointConnectionProvisioningState = "Failed" - PrivateEndpointConnectionProvisioningStateSucceeded PrivateEndpointConnectionProvisioningState = "Succeeded" -) - -func PossibleValuesForPrivateEndpointConnectionProvisioningState() []string { - return []string{ - string(PrivateEndpointConnectionProvisioningStateCreating), - string(PrivateEndpointConnectionProvisioningStateDeleting), - string(PrivateEndpointConnectionProvisioningStateFailed), - string(PrivateEndpointConnectionProvisioningStateSucceeded), - } -} - -func parsePrivateEndpointConnectionProvisioningState(input string) (*PrivateEndpointConnectionProvisioningState, error) { - vals := map[string]PrivateEndpointConnectionProvisioningState{ - "creating": PrivateEndpointConnectionProvisioningStateCreating, - "deleting": PrivateEndpointConnectionProvisioningStateDeleting, - "failed": PrivateEndpointConnectionProvisioningStateFailed, - "succeeded": PrivateEndpointConnectionProvisioningStateSucceeded, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := PrivateEndpointConnectionProvisioningState(input) - return &out, nil -} - -type PrivateEndpointServiceConnectionStatus string - -const ( - PrivateEndpointServiceConnectionStatusApproved PrivateEndpointServiceConnectionStatus = "Approved" - PrivateEndpointServiceConnectionStatusPending PrivateEndpointServiceConnectionStatus = "Pending" - PrivateEndpointServiceConnectionStatusRejected PrivateEndpointServiceConnectionStatus = "Rejected" -) - -func PossibleValuesForPrivateEndpointServiceConnectionStatus() []string { - return []string{ - string(PrivateEndpointServiceConnectionStatusApproved), - string(PrivateEndpointServiceConnectionStatusPending), - string(PrivateEndpointServiceConnectionStatusRejected), - } -} - -func parsePrivateEndpointServiceConnectionStatus(input string) (*PrivateEndpointServiceConnectionStatus, error) { - vals := map[string]PrivateEndpointServiceConnectionStatus{ - "approved": PrivateEndpointServiceConnectionStatusApproved, - "pending": PrivateEndpointServiceConnectionStatusPending, - "rejected": PrivateEndpointServiceConnectionStatusRejected, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := PrivateEndpointServiceConnectionStatus(input) - return &out, nil -} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/privateendpointconnections/id_privateendpointconnection.go b/internal/services/healthcare/sdk/2021-06-01-preview/privateendpointconnections/id_privateendpointconnection.go deleted file mode 100644 index f6e6cb11f4d1..000000000000 --- a/internal/services/healthcare/sdk/2021-06-01-preview/privateendpointconnections/id_privateendpointconnection.go +++ /dev/null @@ -1,137 +0,0 @@ -package privateendpointconnections - -import ( - "fmt" - "strings" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -var _ resourceids.ResourceId = PrivateEndpointConnectionId{} - -// PrivateEndpointConnectionId is a struct representing the Resource ID for a Private Endpoint Connection -type PrivateEndpointConnectionId struct { - SubscriptionId string - ResourceGroupName string - ResourceName string - PrivateEndpointConnectionName string -} - -// NewPrivateEndpointConnectionID returns a new PrivateEndpointConnectionId struct -func NewPrivateEndpointConnectionID(subscriptionId string, resourceGroupName string, resourceName string, privateEndpointConnectionName string) PrivateEndpointConnectionId { - return PrivateEndpointConnectionId{ - SubscriptionId: subscriptionId, - ResourceGroupName: resourceGroupName, - ResourceName: resourceName, - PrivateEndpointConnectionName: privateEndpointConnectionName, - } -} - -// ParsePrivateEndpointConnectionID parses 'input' into a PrivateEndpointConnectionId -func ParsePrivateEndpointConnectionID(input string) (*PrivateEndpointConnectionId, error) { - parser := resourceids.NewParserFromResourceIdType(PrivateEndpointConnectionId{}) - parsed, err := parser.Parse(input, false) - if err != nil { - return nil, fmt.Errorf("parsing %q: %+v", input, err) - } - - var ok bool - id := PrivateEndpointConnectionId{} - - if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { - return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) - } - - if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { - return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) - } - - if id.ResourceName, ok = parsed.Parsed["resourceName"]; !ok { - return nil, fmt.Errorf("the segment 'resourceName' was not found in the resource id %q", input) - } - - if id.PrivateEndpointConnectionName, ok = parsed.Parsed["privateEndpointConnectionName"]; !ok { - return nil, fmt.Errorf("the segment 'privateEndpointConnectionName' was not found in the resource id %q", input) - } - - return &id, nil -} - -// ParsePrivateEndpointConnectionIDInsensitively parses 'input' case-insensitively into a PrivateEndpointConnectionId -// note: this method should only be used for API response data and not user input -func ParsePrivateEndpointConnectionIDInsensitively(input string) (*PrivateEndpointConnectionId, error) { - parser := resourceids.NewParserFromResourceIdType(PrivateEndpointConnectionId{}) - parsed, err := parser.Parse(input, true) - if err != nil { - return nil, fmt.Errorf("parsing %q: %+v", input, err) - } - - var ok bool - id := PrivateEndpointConnectionId{} - - if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { - return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) - } - - if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { - return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) - } - - if id.ResourceName, ok = parsed.Parsed["resourceName"]; !ok { - return nil, fmt.Errorf("the segment 'resourceName' was not found in the resource id %q", input) - } - - if id.PrivateEndpointConnectionName, ok = parsed.Parsed["privateEndpointConnectionName"]; !ok { - return nil, fmt.Errorf("the segment 'privateEndpointConnectionName' was not found in the resource id %q", input) - } - - return &id, nil -} - -// ValidatePrivateEndpointConnectionID checks that 'input' can be parsed as a Private Endpoint Connection ID -func ValidatePrivateEndpointConnectionID(input interface{}, key string) (warnings []string, errors []error) { - v, ok := input.(string) - if !ok { - errors = append(errors, fmt.Errorf("expected %q to be a string", key)) - return - } - - if _, err := ParsePrivateEndpointConnectionID(v); err != nil { - errors = append(errors, err) - } - - return -} - -// ID returns the formatted Private Endpoint Connection ID -func (id PrivateEndpointConnectionId) ID() string { - fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.HealthcareApis/services/%s/privateEndpointConnections/%s" - return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ResourceName, id.PrivateEndpointConnectionName) -} - -// Segments returns a slice of Resource ID Segments which comprise this Private Endpoint Connection ID -func (id PrivateEndpointConnectionId) Segments() []resourceids.Segment { - return []resourceids.Segment{ - resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), - resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), - resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), - resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), - resourceids.StaticSegment("staticProviders", "providers", "providers"), - resourceids.ResourceProviderSegment("staticMicrosoftHealthcareApis", "Microsoft.HealthcareApis", "Microsoft.HealthcareApis"), - resourceids.StaticSegment("staticServices", "services", "services"), - resourceids.UserSpecifiedSegment("resourceName", "resourceValue"), - resourceids.StaticSegment("staticPrivateEndpointConnections", "privateEndpointConnections", "privateEndpointConnections"), - resourceids.UserSpecifiedSegment("privateEndpointConnectionName", "privateEndpointConnectionValue"), - } -} - -// String returns a human-readable description of this Private Endpoint Connection ID -func (id PrivateEndpointConnectionId) String() string { - components := []string{ - fmt.Sprintf("Subscription: %q", id.SubscriptionId), - fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), - fmt.Sprintf("Resource Name: %q", id.ResourceName), - fmt.Sprintf("Private Endpoint Connection Name: %q", id.PrivateEndpointConnectionName), - } - return fmt.Sprintf("Private Endpoint Connection (%s)", strings.Join(components, "\n")) -} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/privateendpointconnections/id_privateendpointconnection_test.go b/internal/services/healthcare/sdk/2021-06-01-preview/privateendpointconnections/id_privateendpointconnection_test.go deleted file mode 100644 index 7876560ae7a7..000000000000 --- a/internal/services/healthcare/sdk/2021-06-01-preview/privateendpointconnections/id_privateendpointconnection_test.go +++ /dev/null @@ -1,324 +0,0 @@ -package privateendpointconnections - -import ( - "testing" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -var _ resourceids.ResourceId = PrivateEndpointConnectionId{} - -func TestNewPrivateEndpointConnectionID(t *testing.T) { - id := NewPrivateEndpointConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "resourceValue", "privateEndpointConnectionValue") - - if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { - t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") - } - - if id.ResourceGroupName != "example-resource-group" { - t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") - } - - if id.ResourceName != "resourceValue" { - t.Fatalf("Expected %q but got %q for Segment 'ResourceName'", id.ResourceName, "resourceValue") - } - - if id.PrivateEndpointConnectionName != "privateEndpointConnectionValue" { - t.Fatalf("Expected %q but got %q for Segment 'PrivateEndpointConnectionName'", id.PrivateEndpointConnectionName, "privateEndpointConnectionValue") - } -} - -func TestFormatPrivateEndpointConnectionID(t *testing.T) { - actual := NewPrivateEndpointConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "resourceValue", "privateEndpointConnectionValue").ID() - expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/services/resourceValue/privateEndpointConnections/privateEndpointConnectionValue" - if actual != expected { - t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) - } -} - -func TestParsePrivateEndpointConnectionID(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *PrivateEndpointConnectionId - }{ - { - // Incomplete URI - Input: "", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/services", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/services/resourceValue", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/services/resourceValue/privateEndpointConnections", - Error: true, - }, - { - // Valid URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/services/resourceValue/privateEndpointConnections/privateEndpointConnectionValue", - Expected: &PrivateEndpointConnectionId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "example-resource-group", - ResourceName: "resourceValue", - PrivateEndpointConnectionName: "privateEndpointConnectionValue", - }, - }, - { - // Invalid (Valid Uri with Extra segment) - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/services/resourceValue/privateEndpointConnections/privateEndpointConnectionValue/extra", - Error: true, - }, - } - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := ParsePrivateEndpointConnectionID(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expect a value but got an error: %+v", err) - } - if v.Error { - t.Fatal("Expect an error but didn't get one") - } - - if actual.SubscriptionId != v.Expected.SubscriptionId { - t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) - } - - if actual.ResourceGroupName != v.Expected.ResourceGroupName { - t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) - } - - if actual.ResourceName != v.Expected.ResourceName { - t.Fatalf("Expected %q but got %q for ResourceName", v.Expected.ResourceName, actual.ResourceName) - } - - if actual.PrivateEndpointConnectionName != v.Expected.PrivateEndpointConnectionName { - t.Fatalf("Expected %q but got %q for PrivateEndpointConnectionName", v.Expected.PrivateEndpointConnectionName, actual.PrivateEndpointConnectionName) - } - - } -} - -func TestParsePrivateEndpointConnectionIDInsensitively(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *PrivateEndpointConnectionId - }{ - { - // Incomplete URI - Input: "", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hEaLtHcArEaPiS", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/services", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hEaLtHcArEaPiS/sErViCeS", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/services/resourceValue", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hEaLtHcArEaPiS/sErViCeS/rEsOuRcEvAlUe", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/services/resourceValue/privateEndpointConnections", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hEaLtHcArEaPiS/sErViCeS/rEsOuRcEvAlUe/pRiVaTeEnDpOiNtCoNnEcTiOnS", - Error: true, - }, - { - // Valid URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/services/resourceValue/privateEndpointConnections/privateEndpointConnectionValue", - Expected: &PrivateEndpointConnectionId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "example-resource-group", - ResourceName: "resourceValue", - PrivateEndpointConnectionName: "privateEndpointConnectionValue", - }, - }, - { - // Invalid (Valid Uri with Extra segment) - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/services/resourceValue/privateEndpointConnections/privateEndpointConnectionValue/extra", - Error: true, - }, - { - // Valid URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hEaLtHcArEaPiS/sErViCeS/rEsOuRcEvAlUe/pRiVaTeEnDpOiNtCoNnEcTiOnS/pRiVaTeEnDpOiNtCoNnEcTiOnVaLuE", - Expected: &PrivateEndpointConnectionId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", - ResourceName: "rEsOuRcEvAlUe", - PrivateEndpointConnectionName: "pRiVaTeEnDpOiNtCoNnEcTiOnVaLuE", - }, - }, - { - // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hEaLtHcArEaPiS/sErViCeS/rEsOuRcEvAlUe/pRiVaTeEnDpOiNtCoNnEcTiOnS/pRiVaTeEnDpOiNtCoNnEcTiOnVaLuE/extra", - Error: true, - }, - } - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := ParsePrivateEndpointConnectionIDInsensitively(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expect a value but got an error: %+v", err) - } - if v.Error { - t.Fatal("Expect an error but didn't get one") - } - - if actual.SubscriptionId != v.Expected.SubscriptionId { - t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) - } - - if actual.ResourceGroupName != v.Expected.ResourceGroupName { - t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) - } - - if actual.ResourceName != v.Expected.ResourceName { - t.Fatalf("Expected %q but got %q for ResourceName", v.Expected.ResourceName, actual.ResourceName) - } - - if actual.PrivateEndpointConnectionName != v.Expected.PrivateEndpointConnectionName { - t.Fatalf("Expected %q but got %q for PrivateEndpointConnectionName", v.Expected.PrivateEndpointConnectionName, actual.PrivateEndpointConnectionName) - } - - } -} - -func TestSegmentsForPrivateEndpointConnectionId(t *testing.T) { - segments := PrivateEndpointConnectionId{}.Segments() - if len(segments) == 0 { - t.Fatalf("PrivateEndpointConnectionId has no segments") - } - - uniqueNames := make(map[string]struct{}, 0) - for _, segment := range segments { - uniqueNames[segment.Name] = struct{}{} - } - if len(uniqueNames) != len(segments) { - t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) - } -} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/privateendpointconnections/id_service.go b/internal/services/healthcare/sdk/2021-06-01-preview/privateendpointconnections/id_service.go deleted file mode 100644 index cb8692be3199..000000000000 --- a/internal/services/healthcare/sdk/2021-06-01-preview/privateendpointconnections/id_service.go +++ /dev/null @@ -1,124 +0,0 @@ -package privateendpointconnections - -import ( - "fmt" - "strings" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -var _ resourceids.ResourceId = ServiceId{} - -// ServiceId is a struct representing the Resource ID for a Service -type ServiceId struct { - SubscriptionId string - ResourceGroupName string - ResourceName string -} - -// NewServiceID returns a new ServiceId struct -func NewServiceID(subscriptionId string, resourceGroupName string, resourceName string) ServiceId { - return ServiceId{ - SubscriptionId: subscriptionId, - ResourceGroupName: resourceGroupName, - ResourceName: resourceName, - } -} - -// ParseServiceID parses 'input' into a ServiceId -func ParseServiceID(input string) (*ServiceId, error) { - parser := resourceids.NewParserFromResourceIdType(ServiceId{}) - parsed, err := parser.Parse(input, false) - if err != nil { - return nil, fmt.Errorf("parsing %q: %+v", input, err) - } - - var ok bool - id := ServiceId{} - - if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { - return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) - } - - if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { - return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) - } - - if id.ResourceName, ok = parsed.Parsed["resourceName"]; !ok { - return nil, fmt.Errorf("the segment 'resourceName' was not found in the resource id %q", input) - } - - return &id, nil -} - -// ParseServiceIDInsensitively parses 'input' case-insensitively into a ServiceId -// note: this method should only be used for API response data and not user input -func ParseServiceIDInsensitively(input string) (*ServiceId, error) { - parser := resourceids.NewParserFromResourceIdType(ServiceId{}) - parsed, err := parser.Parse(input, true) - if err != nil { - return nil, fmt.Errorf("parsing %q: %+v", input, err) - } - - var ok bool - id := ServiceId{} - - if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { - return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) - } - - if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { - return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) - } - - if id.ResourceName, ok = parsed.Parsed["resourceName"]; !ok { - return nil, fmt.Errorf("the segment 'resourceName' was not found in the resource id %q", input) - } - - return &id, nil -} - -// ValidateServiceID checks that 'input' can be parsed as a Service ID -func ValidateServiceID(input interface{}, key string) (warnings []string, errors []error) { - v, ok := input.(string) - if !ok { - errors = append(errors, fmt.Errorf("expected %q to be a string", key)) - return - } - - if _, err := ParseServiceID(v); err != nil { - errors = append(errors, err) - } - - return -} - -// ID returns the formatted Service ID -func (id ServiceId) ID() string { - fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.HealthcareApis/services/%s" - return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ResourceName) -} - -// Segments returns a slice of Resource ID Segments which comprise this Service ID -func (id ServiceId) Segments() []resourceids.Segment { - return []resourceids.Segment{ - resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), - resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), - resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), - resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), - resourceids.StaticSegment("staticProviders", "providers", "providers"), - resourceids.ResourceProviderSegment("staticMicrosoftHealthcareApis", "Microsoft.HealthcareApis", "Microsoft.HealthcareApis"), - resourceids.StaticSegment("staticServices", "services", "services"), - resourceids.UserSpecifiedSegment("resourceName", "resourceValue"), - } -} - -// String returns a human-readable description of this Service ID -func (id ServiceId) String() string { - components := []string{ - fmt.Sprintf("Subscription: %q", id.SubscriptionId), - fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), - fmt.Sprintf("Resource Name: %q", id.ResourceName), - } - return fmt.Sprintf("Service (%s)", strings.Join(components, "\n")) -} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/privateendpointconnections/id_service_test.go b/internal/services/healthcare/sdk/2021-06-01-preview/privateendpointconnections/id_service_test.go deleted file mode 100644 index d879c6948696..000000000000 --- a/internal/services/healthcare/sdk/2021-06-01-preview/privateendpointconnections/id_service_test.go +++ /dev/null @@ -1,279 +0,0 @@ -package privateendpointconnections - -import ( - "testing" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -var _ resourceids.ResourceId = ServiceId{} - -func TestNewServiceID(t *testing.T) { - id := NewServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "resourceValue") - - if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { - t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") - } - - if id.ResourceGroupName != "example-resource-group" { - t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") - } - - if id.ResourceName != "resourceValue" { - t.Fatalf("Expected %q but got %q for Segment 'ResourceName'", id.ResourceName, "resourceValue") - } -} - -func TestFormatServiceID(t *testing.T) { - actual := NewServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "resourceValue").ID() - expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/services/resourceValue" - if actual != expected { - t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) - } -} - -func TestParseServiceID(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *ServiceId - }{ - { - // Incomplete URI - Input: "", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/services", - Error: true, - }, - { - // Valid URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/services/resourceValue", - Expected: &ServiceId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "example-resource-group", - ResourceName: "resourceValue", - }, - }, - { - // Invalid (Valid Uri with Extra segment) - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/services/resourceValue/extra", - Error: true, - }, - } - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := ParseServiceID(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expect a value but got an error: %+v", err) - } - if v.Error { - t.Fatal("Expect an error but didn't get one") - } - - if actual.SubscriptionId != v.Expected.SubscriptionId { - t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) - } - - if actual.ResourceGroupName != v.Expected.ResourceGroupName { - t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) - } - - if actual.ResourceName != v.Expected.ResourceName { - t.Fatalf("Expected %q but got %q for ResourceName", v.Expected.ResourceName, actual.ResourceName) - } - - } -} - -func TestParseServiceIDInsensitively(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *ServiceId - }{ - { - // Incomplete URI - Input: "", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hEaLtHcArEaPiS", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/services", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hEaLtHcArEaPiS/sErViCeS", - Error: true, - }, - { - // Valid URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/services/resourceValue", - Expected: &ServiceId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "example-resource-group", - ResourceName: "resourceValue", - }, - }, - { - // Invalid (Valid Uri with Extra segment) - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/services/resourceValue/extra", - Error: true, - }, - { - // Valid URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hEaLtHcArEaPiS/sErViCeS/rEsOuRcEvAlUe", - Expected: &ServiceId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", - ResourceName: "rEsOuRcEvAlUe", - }, - }, - { - // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hEaLtHcArEaPiS/sErViCeS/rEsOuRcEvAlUe/extra", - Error: true, - }, - } - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := ParseServiceIDInsensitively(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expect a value but got an error: %+v", err) - } - if v.Error { - t.Fatal("Expect an error but didn't get one") - } - - if actual.SubscriptionId != v.Expected.SubscriptionId { - t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) - } - - if actual.ResourceGroupName != v.Expected.ResourceGroupName { - t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) - } - - if actual.ResourceName != v.Expected.ResourceName { - t.Fatalf("Expected %q but got %q for ResourceName", v.Expected.ResourceName, actual.ResourceName) - } - - } -} - -func TestSegmentsForServiceId(t *testing.T) { - segments := ServiceId{}.Segments() - if len(segments) == 0 { - t.Fatalf("ServiceId has no segments") - } - - uniqueNames := make(map[string]struct{}, 0) - for _, segment := range segments { - uniqueNames[segment.Name] = struct{}{} - } - if len(uniqueNames) != len(segments) { - t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) - } -} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/privateendpointconnections/method_createorupdate_autorest.go b/internal/services/healthcare/sdk/2021-06-01-preview/privateendpointconnections/method_createorupdate_autorest.go deleted file mode 100644 index 986cb8f4f626..000000000000 --- a/internal/services/healthcare/sdk/2021-06-01-preview/privateendpointconnections/method_createorupdate_autorest.go +++ /dev/null @@ -1,75 +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" -) - -type CreateOrUpdateResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// CreateOrUpdate ... -func (c PrivateEndpointConnectionsClient) CreateOrUpdate(ctx context.Context, id PrivateEndpointConnectionId, input PrivateEndpointConnection) (result CreateOrUpdateResponse, err error) { - req, err := c.preparerForCreateOrUpdate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "privateendpointconnections.PrivateEndpointConnectionsClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result, err = c.senderForCreateOrUpdate(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "privateendpointconnections.PrivateEndpointConnectionsClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed -func (c PrivateEndpointConnectionsClient) CreateOrUpdateThenPoll(ctx context.Context, id PrivateEndpointConnectionId, input PrivateEndpointConnection) 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 PrivateEndpointConnectionsClient) preparerForCreateOrUpdate(ctx context.Context, id PrivateEndpointConnectionId, input PrivateEndpointConnection) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForCreateOrUpdate sends the CreateOrUpdate request. The method will close the -// http.Response Body if it receives an error. -func (c PrivateEndpointConnectionsClient) senderForCreateOrUpdate(ctx context.Context, req *http.Request) (future CreateOrUpdateResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - future.Poller, err = polling.NewLongRunningPollerFromResponse(ctx, resp, c.Client) - return -} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/privateendpointconnections/method_delete_autorest.go b/internal/services/healthcare/sdk/2021-06-01-preview/privateendpointconnections/method_delete_autorest.go deleted file mode 100644 index 3c4a86df694f..000000000000 --- a/internal/services/healthcare/sdk/2021-06-01-preview/privateendpointconnections/method_delete_autorest.go +++ /dev/null @@ -1,74 +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" -) - -type DeleteResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// Delete ... -func (c PrivateEndpointConnectionsClient) Delete(ctx context.Context, id PrivateEndpointConnectionId) (result DeleteResponse, err error) { - req, err := c.preparerForDelete(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "privateendpointconnections.PrivateEndpointConnectionsClient", "Delete", nil, "Failure preparing request") - return - } - - result, err = c.senderForDelete(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "privateendpointconnections.PrivateEndpointConnectionsClient", "Delete", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// DeleteThenPoll performs Delete then polls until it's completed -func (c PrivateEndpointConnectionsClient) DeleteThenPoll(ctx context.Context, id PrivateEndpointConnectionId) error { - result, err := c.Delete(ctx, id) - if err != nil { - return fmt.Errorf("performing Delete: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after Delete: %+v", err) - } - - return nil -} - -// preparerForDelete prepares the Delete request. -func (c PrivateEndpointConnectionsClient) preparerForDelete(ctx context.Context, id PrivateEndpointConnectionId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForDelete sends the Delete request. The method will close the -// http.Response Body if it receives an error. -func (c PrivateEndpointConnectionsClient) senderForDelete(ctx context.Context, req *http.Request) (future DeleteResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - future.Poller, err = polling.NewLongRunningPollerFromResponse(ctx, resp, c.Client) - return -} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/privateendpointconnections/method_get_autorest.go b/internal/services/healthcare/sdk/2021-06-01-preview/privateendpointconnections/method_get_autorest.go deleted file mode 100644 index 349a61376bc5..000000000000 --- a/internal/services/healthcare/sdk/2021-06-01-preview/privateendpointconnections/method_get_autorest.go +++ /dev/null @@ -1,64 +0,0 @@ -package privateendpointconnections - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -type GetResponse struct { - HttpResponse *http.Response - Model *PrivateEndpointConnectionDescription -} - -// Get ... -func (c PrivateEndpointConnectionsClient) Get(ctx context.Context, id PrivateEndpointConnectionId) (result GetResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "privateendpointconnections.PrivateEndpointConnectionsClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "privateendpointconnections.PrivateEndpointConnectionsClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "privateendpointconnections.PrivateEndpointConnectionsClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c PrivateEndpointConnectionsClient) preparerForGet(ctx context.Context, id PrivateEndpointConnectionId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGet handles the response to the Get request. The method always -// closes the http.Response Body. -func (c PrivateEndpointConnectionsClient) responderForGet(resp *http.Response) (result GetResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - return -} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/privateendpointconnections/method_listbyservice_autorest.go b/internal/services/healthcare/sdk/2021-06-01-preview/privateendpointconnections/method_listbyservice_autorest.go deleted file mode 100644 index a908376bfddb..000000000000 --- a/internal/services/healthcare/sdk/2021-06-01-preview/privateendpointconnections/method_listbyservice_autorest.go +++ /dev/null @@ -1,65 +0,0 @@ -package privateendpointconnections - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -type ListByServiceResponse struct { - HttpResponse *http.Response - Model *PrivateEndpointConnectionListResultDescription -} - -// ListByService ... -func (c PrivateEndpointConnectionsClient) ListByService(ctx context.Context, id ServiceId) (result ListByServiceResponse, err error) { - req, err := c.preparerForListByService(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "privateendpointconnections.PrivateEndpointConnectionsClient", "ListByService", 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", "ListByService", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByService(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "privateendpointconnections.PrivateEndpointConnectionsClient", "ListByService", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForListByService prepares the ListByService request. -func (c PrivateEndpointConnectionsClient) 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/privateEndpointConnections", 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 PrivateEndpointConnectionsClient) responderForListByService(resp *http.Response) (result ListByServiceResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - return -} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/privateendpointconnections/model_privateendpoint.go b/internal/services/healthcare/sdk/2021-06-01-preview/privateendpointconnections/model_privateendpoint.go deleted file mode 100644 index 33ffc888d58a..000000000000 --- a/internal/services/healthcare/sdk/2021-06-01-preview/privateendpointconnections/model_privateendpoint.go +++ /dev/null @@ -1,5 +0,0 @@ -package privateendpointconnections - -type PrivateEndpoint struct { - Id *string `json:"id,omitempty"` -} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/privateendpointconnections/model_privateendpointconnection.go b/internal/services/healthcare/sdk/2021-06-01-preview/privateendpointconnections/model_privateendpointconnection.go deleted file mode 100644 index 597d3e71746a..000000000000 --- a/internal/services/healthcare/sdk/2021-06-01-preview/privateendpointconnections/model_privateendpointconnection.go +++ /dev/null @@ -1,8 +0,0 @@ -package privateendpointconnections - -type PrivateEndpointConnection struct { - Id *string `json:"id,omitempty"` - Name *string `json:"name,omitempty"` - Properties *PrivateEndpointConnectionProperties `json:"properties,omitempty"` - Type *string `json:"type,omitempty"` -} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/privateendpointconnections/model_privateendpointconnectiondescription.go b/internal/services/healthcare/sdk/2021-06-01-preview/privateendpointconnections/model_privateendpointconnectiondescription.go deleted file mode 100644 index 95543c352044..000000000000 --- a/internal/services/healthcare/sdk/2021-06-01-preview/privateendpointconnections/model_privateendpointconnectiondescription.go +++ /dev/null @@ -1,9 +0,0 @@ -package privateendpointconnections - -type PrivateEndpointConnectionDescription struct { - Id *string `json:"id,omitempty"` - Name *string `json:"name,omitempty"` - Properties *PrivateEndpointConnectionProperties `json:"properties,omitempty"` - SystemData *SystemData `json:"systemData,omitempty"` - Type *string `json:"type,omitempty"` -} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/privateendpointconnections/model_privateendpointconnectionlistresultdescription.go b/internal/services/healthcare/sdk/2021-06-01-preview/privateendpointconnections/model_privateendpointconnectionlistresultdescription.go deleted file mode 100644 index 579bed999b3d..000000000000 --- a/internal/services/healthcare/sdk/2021-06-01-preview/privateendpointconnections/model_privateendpointconnectionlistresultdescription.go +++ /dev/null @@ -1,5 +0,0 @@ -package privateendpointconnections - -type PrivateEndpointConnectionListResultDescription struct { - Value *[]PrivateEndpointConnectionDescription `json:"value,omitempty"` -} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/privateendpointconnections/model_privateendpointconnectionproperties.go b/internal/services/healthcare/sdk/2021-06-01-preview/privateendpointconnections/model_privateendpointconnectionproperties.go deleted file mode 100644 index 252bd91cbe86..000000000000 --- a/internal/services/healthcare/sdk/2021-06-01-preview/privateendpointconnections/model_privateendpointconnectionproperties.go +++ /dev/null @@ -1,7 +0,0 @@ -package privateendpointconnections - -type PrivateEndpointConnectionProperties struct { - PrivateEndpoint *PrivateEndpoint `json:"privateEndpoint,omitempty"` - PrivateLinkServiceConnectionState PrivateLinkServiceConnectionState `json:"privateLinkServiceConnectionState"` - ProvisioningState *PrivateEndpointConnectionProvisioningState `json:"provisioningState,omitempty"` -} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/privateendpointconnections/model_privatelinkserviceconnectionstate.go b/internal/services/healthcare/sdk/2021-06-01-preview/privateendpointconnections/model_privatelinkserviceconnectionstate.go deleted file mode 100644 index def138656add..000000000000 --- a/internal/services/healthcare/sdk/2021-06-01-preview/privateendpointconnections/model_privatelinkserviceconnectionstate.go +++ /dev/null @@ -1,7 +0,0 @@ -package privateendpointconnections - -type PrivateLinkServiceConnectionState struct { - ActionsRequired *string `json:"actionsRequired,omitempty"` - Description *string `json:"description,omitempty"` - Status *PrivateEndpointServiceConnectionStatus `json:"status,omitempty"` -} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/privateendpointconnections/model_systemdata.go b/internal/services/healthcare/sdk/2021-06-01-preview/privateendpointconnections/model_systemdata.go deleted file mode 100644 index 3d46829edeb6..000000000000 --- a/internal/services/healthcare/sdk/2021-06-01-preview/privateendpointconnections/model_systemdata.go +++ /dev/null @@ -1,40 +0,0 @@ -package privateendpointconnections - -import ( - "time" - - "github.com/hashicorp/go-azure-helpers/lang/dates" -) - -type SystemData struct { - CreatedAt *string `json:"createdAt,omitempty"` - CreatedBy *string `json:"createdBy,omitempty"` - CreatedByType *CreatedByType `json:"createdByType,omitempty"` - LastModifiedAt *string `json:"lastModifiedAt,omitempty"` - LastModifiedBy *string `json:"lastModifiedBy,omitempty"` - LastModifiedByType *CreatedByType `json:"lastModifiedByType,omitempty"` -} - -func (o SystemData) GetCreatedAtAsTime() (*time.Time, error) { - if o.CreatedAt == nil { - return nil, nil - } - return dates.ParseAsFormat(o.CreatedAt, "2006-01-02T15:04:05Z07:00") -} - -func (o SystemData) SetCreatedAtAsTime(input time.Time) { - formatted := input.Format("2006-01-02T15:04:05Z07:00") - o.CreatedAt = &formatted -} - -func (o SystemData) GetLastModifiedAtAsTime() (*time.Time, error) { - if o.LastModifiedAt == nil { - return nil, nil - } - return dates.ParseAsFormat(o.LastModifiedAt, "2006-01-02T15:04:05Z07:00") -} - -func (o SystemData) SetLastModifiedAtAsTime(input time.Time) { - formatted := input.Format("2006-01-02T15:04:05Z07:00") - o.LastModifiedAt = &formatted -} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/privateendpointconnections/version.go b/internal/services/healthcare/sdk/2021-06-01-preview/privateendpointconnections/version.go deleted file mode 100644 index 0e3da44caa60..000000000000 --- a/internal/services/healthcare/sdk/2021-06-01-preview/privateendpointconnections/version.go +++ /dev/null @@ -1,9 +0,0 @@ -package privateendpointconnections - -import "fmt" - -const defaultApiVersion = "2021-06-01-preview" - -func userAgent() string { - return fmt.Sprintf("pandora/privateendpointconnections/%s", defaultApiVersion) -} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/privatelinkresources/client.go b/internal/services/healthcare/sdk/2021-06-01-preview/privatelinkresources/client.go deleted file mode 100644 index 3ccc015d4fe1..000000000000 --- a/internal/services/healthcare/sdk/2021-06-01-preview/privatelinkresources/client.go +++ /dev/null @@ -1,15 +0,0 @@ -package privatelinkresources - -import "github.com/Azure/go-autorest/autorest" - -type PrivateLinkResourcesClient struct { - Client autorest.Client - baseUri string -} - -func NewPrivateLinkResourcesClientWithBaseURI(endpoint string) PrivateLinkResourcesClient { - return PrivateLinkResourcesClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, - } -} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/privatelinkresources/constants.go b/internal/services/healthcare/sdk/2021-06-01-preview/privatelinkresources/constants.go deleted file mode 100644 index 8b7848581899..000000000000 --- a/internal/services/healthcare/sdk/2021-06-01-preview/privatelinkresources/constants.go +++ /dev/null @@ -1,37 +0,0 @@ -package privatelinkresources - -import "strings" - -type CreatedByType string - -const ( - CreatedByTypeApplication CreatedByType = "Application" - CreatedByTypeKey CreatedByType = "Key" - CreatedByTypeManagedIdentity CreatedByType = "ManagedIdentity" - CreatedByTypeUser CreatedByType = "User" -) - -func PossibleValuesForCreatedByType() []string { - return []string{ - string(CreatedByTypeApplication), - string(CreatedByTypeKey), - string(CreatedByTypeManagedIdentity), - string(CreatedByTypeUser), - } -} - -func parseCreatedByType(input string) (*CreatedByType, error) { - vals := map[string]CreatedByType{ - "application": CreatedByTypeApplication, - "key": CreatedByTypeKey, - "managedidentity": CreatedByTypeManagedIdentity, - "user": CreatedByTypeUser, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := CreatedByType(input) - return &out, nil -} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/privatelinkresources/id_privatelinkresource.go b/internal/services/healthcare/sdk/2021-06-01-preview/privatelinkresources/id_privatelinkresource.go deleted file mode 100644 index 4a716efea2d6..000000000000 --- a/internal/services/healthcare/sdk/2021-06-01-preview/privatelinkresources/id_privatelinkresource.go +++ /dev/null @@ -1,137 +0,0 @@ -package privatelinkresources - -import ( - "fmt" - "strings" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -var _ resourceids.ResourceId = PrivateLinkResourceId{} - -// PrivateLinkResourceId is a struct representing the Resource ID for a Private Link Resource -type PrivateLinkResourceId struct { - SubscriptionId string - ResourceGroupName string - ResourceName string - GroupName string -} - -// NewPrivateLinkResourceID returns a new PrivateLinkResourceId struct -func NewPrivateLinkResourceID(subscriptionId string, resourceGroupName string, resourceName string, groupName string) PrivateLinkResourceId { - return PrivateLinkResourceId{ - SubscriptionId: subscriptionId, - ResourceGroupName: resourceGroupName, - ResourceName: resourceName, - GroupName: groupName, - } -} - -// ParsePrivateLinkResourceID parses 'input' into a PrivateLinkResourceId -func ParsePrivateLinkResourceID(input string) (*PrivateLinkResourceId, error) { - parser := resourceids.NewParserFromResourceIdType(PrivateLinkResourceId{}) - parsed, err := parser.Parse(input, false) - if err != nil { - return nil, fmt.Errorf("parsing %q: %+v", input, err) - } - - var ok bool - id := PrivateLinkResourceId{} - - if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { - return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) - } - - if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { - return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) - } - - if id.ResourceName, ok = parsed.Parsed["resourceName"]; !ok { - return nil, fmt.Errorf("the segment 'resourceName' was not found in the resource id %q", input) - } - - if id.GroupName, ok = parsed.Parsed["groupName"]; !ok { - return nil, fmt.Errorf("the segment 'groupName' was not found in the resource id %q", input) - } - - return &id, nil -} - -// ParsePrivateLinkResourceIDInsensitively parses 'input' case-insensitively into a PrivateLinkResourceId -// note: this method should only be used for API response data and not user input -func ParsePrivateLinkResourceIDInsensitively(input string) (*PrivateLinkResourceId, error) { - parser := resourceids.NewParserFromResourceIdType(PrivateLinkResourceId{}) - parsed, err := parser.Parse(input, true) - if err != nil { - return nil, fmt.Errorf("parsing %q: %+v", input, err) - } - - var ok bool - id := PrivateLinkResourceId{} - - if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { - return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) - } - - if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { - return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) - } - - if id.ResourceName, ok = parsed.Parsed["resourceName"]; !ok { - return nil, fmt.Errorf("the segment 'resourceName' was not found in the resource id %q", input) - } - - if id.GroupName, ok = parsed.Parsed["groupName"]; !ok { - return nil, fmt.Errorf("the segment 'groupName' was not found in the resource id %q", input) - } - - return &id, nil -} - -// ValidatePrivateLinkResourceID checks that 'input' can be parsed as a Private Link Resource ID -func ValidatePrivateLinkResourceID(input interface{}, key string) (warnings []string, errors []error) { - v, ok := input.(string) - if !ok { - errors = append(errors, fmt.Errorf("expected %q to be a string", key)) - return - } - - if _, err := ParsePrivateLinkResourceID(v); err != nil { - errors = append(errors, err) - } - - return -} - -// ID returns the formatted Private Link Resource ID -func (id PrivateLinkResourceId) ID() string { - fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.HealthcareApis/services/%s/privateLinkResources/%s" - return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ResourceName, id.GroupName) -} - -// Segments returns a slice of Resource ID Segments which comprise this Private Link Resource ID -func (id PrivateLinkResourceId) Segments() []resourceids.Segment { - return []resourceids.Segment{ - resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), - resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), - resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), - resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), - resourceids.StaticSegment("staticProviders", "providers", "providers"), - resourceids.ResourceProviderSegment("staticMicrosoftHealthcareApis", "Microsoft.HealthcareApis", "Microsoft.HealthcareApis"), - resourceids.StaticSegment("staticServices", "services", "services"), - resourceids.UserSpecifiedSegment("resourceName", "resourceValue"), - resourceids.StaticSegment("staticPrivateLinkResources", "privateLinkResources", "privateLinkResources"), - resourceids.UserSpecifiedSegment("groupName", "groupValue"), - } -} - -// String returns a human-readable description of this Private Link Resource ID -func (id PrivateLinkResourceId) String() string { - components := []string{ - fmt.Sprintf("Subscription: %q", id.SubscriptionId), - fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), - fmt.Sprintf("Resource Name: %q", id.ResourceName), - fmt.Sprintf("Group Name: %q", id.GroupName), - } - return fmt.Sprintf("Private Link Resource (%s)", strings.Join(components, "\n")) -} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/privatelinkresources/id_privatelinkresource_test.go b/internal/services/healthcare/sdk/2021-06-01-preview/privatelinkresources/id_privatelinkresource_test.go deleted file mode 100644 index a7334abc33b5..000000000000 --- a/internal/services/healthcare/sdk/2021-06-01-preview/privatelinkresources/id_privatelinkresource_test.go +++ /dev/null @@ -1,324 +0,0 @@ -package privatelinkresources - -import ( - "testing" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -var _ resourceids.ResourceId = PrivateLinkResourceId{} - -func TestNewPrivateLinkResourceID(t *testing.T) { - id := NewPrivateLinkResourceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "resourceValue", "groupValue") - - if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { - t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") - } - - if id.ResourceGroupName != "example-resource-group" { - t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") - } - - if id.ResourceName != "resourceValue" { - t.Fatalf("Expected %q but got %q for Segment 'ResourceName'", id.ResourceName, "resourceValue") - } - - if id.GroupName != "groupValue" { - t.Fatalf("Expected %q but got %q for Segment 'GroupName'", id.GroupName, "groupValue") - } -} - -func TestFormatPrivateLinkResourceID(t *testing.T) { - actual := NewPrivateLinkResourceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "resourceValue", "groupValue").ID() - expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/services/resourceValue/privateLinkResources/groupValue" - if actual != expected { - t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) - } -} - -func TestParsePrivateLinkResourceID(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *PrivateLinkResourceId - }{ - { - // Incomplete URI - Input: "", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/services", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/services/resourceValue", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/services/resourceValue/privateLinkResources", - Error: true, - }, - { - // Valid URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/services/resourceValue/privateLinkResources/groupValue", - Expected: &PrivateLinkResourceId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "example-resource-group", - ResourceName: "resourceValue", - GroupName: "groupValue", - }, - }, - { - // Invalid (Valid Uri with Extra segment) - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/services/resourceValue/privateLinkResources/groupValue/extra", - Error: true, - }, - } - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := ParsePrivateLinkResourceID(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expect a value but got an error: %+v", err) - } - if v.Error { - t.Fatal("Expect an error but didn't get one") - } - - if actual.SubscriptionId != v.Expected.SubscriptionId { - t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) - } - - if actual.ResourceGroupName != v.Expected.ResourceGroupName { - t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) - } - - if actual.ResourceName != v.Expected.ResourceName { - t.Fatalf("Expected %q but got %q for ResourceName", v.Expected.ResourceName, actual.ResourceName) - } - - if actual.GroupName != v.Expected.GroupName { - t.Fatalf("Expected %q but got %q for GroupName", v.Expected.GroupName, actual.GroupName) - } - - } -} - -func TestParsePrivateLinkResourceIDInsensitively(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *PrivateLinkResourceId - }{ - { - // Incomplete URI - Input: "", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hEaLtHcArEaPiS", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/services", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hEaLtHcArEaPiS/sErViCeS", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/services/resourceValue", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hEaLtHcArEaPiS/sErViCeS/rEsOuRcEvAlUe", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/services/resourceValue/privateLinkResources", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hEaLtHcArEaPiS/sErViCeS/rEsOuRcEvAlUe/pRiVaTeLiNkReSoUrCeS", - Error: true, - }, - { - // Valid URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/services/resourceValue/privateLinkResources/groupValue", - Expected: &PrivateLinkResourceId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "example-resource-group", - ResourceName: "resourceValue", - GroupName: "groupValue", - }, - }, - { - // Invalid (Valid Uri with Extra segment) - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/services/resourceValue/privateLinkResources/groupValue/extra", - Error: true, - }, - { - // Valid URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hEaLtHcArEaPiS/sErViCeS/rEsOuRcEvAlUe/pRiVaTeLiNkReSoUrCeS/gRoUpVaLuE", - Expected: &PrivateLinkResourceId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", - ResourceName: "rEsOuRcEvAlUe", - GroupName: "gRoUpVaLuE", - }, - }, - { - // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hEaLtHcArEaPiS/sErViCeS/rEsOuRcEvAlUe/pRiVaTeLiNkReSoUrCeS/gRoUpVaLuE/extra", - Error: true, - }, - } - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := ParsePrivateLinkResourceIDInsensitively(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expect a value but got an error: %+v", err) - } - if v.Error { - t.Fatal("Expect an error but didn't get one") - } - - if actual.SubscriptionId != v.Expected.SubscriptionId { - t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) - } - - if actual.ResourceGroupName != v.Expected.ResourceGroupName { - t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) - } - - if actual.ResourceName != v.Expected.ResourceName { - t.Fatalf("Expected %q but got %q for ResourceName", v.Expected.ResourceName, actual.ResourceName) - } - - if actual.GroupName != v.Expected.GroupName { - t.Fatalf("Expected %q but got %q for GroupName", v.Expected.GroupName, actual.GroupName) - } - - } -} - -func TestSegmentsForPrivateLinkResourceId(t *testing.T) { - segments := PrivateLinkResourceId{}.Segments() - if len(segments) == 0 { - t.Fatalf("PrivateLinkResourceId has no segments") - } - - uniqueNames := make(map[string]struct{}, 0) - for _, segment := range segments { - uniqueNames[segment.Name] = struct{}{} - } - if len(uniqueNames) != len(segments) { - t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) - } -} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/privatelinkresources/id_service.go b/internal/services/healthcare/sdk/2021-06-01-preview/privatelinkresources/id_service.go deleted file mode 100644 index f87dd953cbc0..000000000000 --- a/internal/services/healthcare/sdk/2021-06-01-preview/privatelinkresources/id_service.go +++ /dev/null @@ -1,124 +0,0 @@ -package privatelinkresources - -import ( - "fmt" - "strings" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -var _ resourceids.ResourceId = ServiceId{} - -// ServiceId is a struct representing the Resource ID for a Service -type ServiceId struct { - SubscriptionId string - ResourceGroupName string - ResourceName string -} - -// NewServiceID returns a new ServiceId struct -func NewServiceID(subscriptionId string, resourceGroupName string, resourceName string) ServiceId { - return ServiceId{ - SubscriptionId: subscriptionId, - ResourceGroupName: resourceGroupName, - ResourceName: resourceName, - } -} - -// ParseServiceID parses 'input' into a ServiceId -func ParseServiceID(input string) (*ServiceId, error) { - parser := resourceids.NewParserFromResourceIdType(ServiceId{}) - parsed, err := parser.Parse(input, false) - if err != nil { - return nil, fmt.Errorf("parsing %q: %+v", input, err) - } - - var ok bool - id := ServiceId{} - - if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { - return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) - } - - if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { - return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) - } - - if id.ResourceName, ok = parsed.Parsed["resourceName"]; !ok { - return nil, fmt.Errorf("the segment 'resourceName' was not found in the resource id %q", input) - } - - return &id, nil -} - -// ParseServiceIDInsensitively parses 'input' case-insensitively into a ServiceId -// note: this method should only be used for API response data and not user input -func ParseServiceIDInsensitively(input string) (*ServiceId, error) { - parser := resourceids.NewParserFromResourceIdType(ServiceId{}) - parsed, err := parser.Parse(input, true) - if err != nil { - return nil, fmt.Errorf("parsing %q: %+v", input, err) - } - - var ok bool - id := ServiceId{} - - if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { - return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) - } - - if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { - return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) - } - - if id.ResourceName, ok = parsed.Parsed["resourceName"]; !ok { - return nil, fmt.Errorf("the segment 'resourceName' was not found in the resource id %q", input) - } - - return &id, nil -} - -// ValidateServiceID checks that 'input' can be parsed as a Service ID -func ValidateServiceID(input interface{}, key string) (warnings []string, errors []error) { - v, ok := input.(string) - if !ok { - errors = append(errors, fmt.Errorf("expected %q to be a string", key)) - return - } - - if _, err := ParseServiceID(v); err != nil { - errors = append(errors, err) - } - - return -} - -// ID returns the formatted Service ID -func (id ServiceId) ID() string { - fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.HealthcareApis/services/%s" - return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ResourceName) -} - -// Segments returns a slice of Resource ID Segments which comprise this Service ID -func (id ServiceId) Segments() []resourceids.Segment { - return []resourceids.Segment{ - resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), - resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), - resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), - resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), - resourceids.StaticSegment("staticProviders", "providers", "providers"), - resourceids.ResourceProviderSegment("staticMicrosoftHealthcareApis", "Microsoft.HealthcareApis", "Microsoft.HealthcareApis"), - resourceids.StaticSegment("staticServices", "services", "services"), - resourceids.UserSpecifiedSegment("resourceName", "resourceValue"), - } -} - -// String returns a human-readable description of this Service ID -func (id ServiceId) String() string { - components := []string{ - fmt.Sprintf("Subscription: %q", id.SubscriptionId), - fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), - fmt.Sprintf("Resource Name: %q", id.ResourceName), - } - return fmt.Sprintf("Service (%s)", strings.Join(components, "\n")) -} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/privatelinkresources/id_service_test.go b/internal/services/healthcare/sdk/2021-06-01-preview/privatelinkresources/id_service_test.go deleted file mode 100644 index 32a385125ba0..000000000000 --- a/internal/services/healthcare/sdk/2021-06-01-preview/privatelinkresources/id_service_test.go +++ /dev/null @@ -1,279 +0,0 @@ -package privatelinkresources - -import ( - "testing" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -var _ resourceids.ResourceId = ServiceId{} - -func TestNewServiceID(t *testing.T) { - id := NewServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "resourceValue") - - if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { - t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") - } - - if id.ResourceGroupName != "example-resource-group" { - t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") - } - - if id.ResourceName != "resourceValue" { - t.Fatalf("Expected %q but got %q for Segment 'ResourceName'", id.ResourceName, "resourceValue") - } -} - -func TestFormatServiceID(t *testing.T) { - actual := NewServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "resourceValue").ID() - expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/services/resourceValue" - if actual != expected { - t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) - } -} - -func TestParseServiceID(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *ServiceId - }{ - { - // Incomplete URI - Input: "", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/services", - Error: true, - }, - { - // Valid URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/services/resourceValue", - Expected: &ServiceId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "example-resource-group", - ResourceName: "resourceValue", - }, - }, - { - // Invalid (Valid Uri with Extra segment) - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/services/resourceValue/extra", - Error: true, - }, - } - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := ParseServiceID(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expect a value but got an error: %+v", err) - } - if v.Error { - t.Fatal("Expect an error but didn't get one") - } - - if actual.SubscriptionId != v.Expected.SubscriptionId { - t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) - } - - if actual.ResourceGroupName != v.Expected.ResourceGroupName { - t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) - } - - if actual.ResourceName != v.Expected.ResourceName { - t.Fatalf("Expected %q but got %q for ResourceName", v.Expected.ResourceName, actual.ResourceName) - } - - } -} - -func TestParseServiceIDInsensitively(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *ServiceId - }{ - { - // Incomplete URI - Input: "", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hEaLtHcArEaPiS", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/services", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hEaLtHcArEaPiS/sErViCeS", - Error: true, - }, - { - // Valid URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/services/resourceValue", - Expected: &ServiceId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "example-resource-group", - ResourceName: "resourceValue", - }, - }, - { - // Invalid (Valid Uri with Extra segment) - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/services/resourceValue/extra", - Error: true, - }, - { - // Valid URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hEaLtHcArEaPiS/sErViCeS/rEsOuRcEvAlUe", - Expected: &ServiceId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", - ResourceName: "rEsOuRcEvAlUe", - }, - }, - { - // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hEaLtHcArEaPiS/sErViCeS/rEsOuRcEvAlUe/extra", - Error: true, - }, - } - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := ParseServiceIDInsensitively(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expect a value but got an error: %+v", err) - } - if v.Error { - t.Fatal("Expect an error but didn't get one") - } - - if actual.SubscriptionId != v.Expected.SubscriptionId { - t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) - } - - if actual.ResourceGroupName != v.Expected.ResourceGroupName { - t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) - } - - if actual.ResourceName != v.Expected.ResourceName { - t.Fatalf("Expected %q but got %q for ResourceName", v.Expected.ResourceName, actual.ResourceName) - } - - } -} - -func TestSegmentsForServiceId(t *testing.T) { - segments := ServiceId{}.Segments() - if len(segments) == 0 { - t.Fatalf("ServiceId has no segments") - } - - uniqueNames := make(map[string]struct{}, 0) - for _, segment := range segments { - uniqueNames[segment.Name] = struct{}{} - } - if len(uniqueNames) != len(segments) { - t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) - } -} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/privatelinkresources/method_get_autorest.go b/internal/services/healthcare/sdk/2021-06-01-preview/privatelinkresources/method_get_autorest.go deleted file mode 100644 index 097c32ab3809..000000000000 --- a/internal/services/healthcare/sdk/2021-06-01-preview/privatelinkresources/method_get_autorest.go +++ /dev/null @@ -1,64 +0,0 @@ -package privatelinkresources - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -type GetResponse struct { - HttpResponse *http.Response - Model *PrivateLinkResourceDescription -} - -// Get ... -func (c PrivateLinkResourcesClient) Get(ctx context.Context, id PrivateLinkResourceId) (result GetResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "privatelinkresources.PrivateLinkResourcesClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "privatelinkresources.PrivateLinkResourcesClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "privatelinkresources.PrivateLinkResourcesClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c PrivateLinkResourcesClient) preparerForGet(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)) -} - -// responderForGet handles the response to the Get request. The method always -// closes the http.Response Body. -func (c PrivateLinkResourcesClient) responderForGet(resp *http.Response) (result GetResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - return -} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/privatelinkresources/method_listbyservice_autorest.go b/internal/services/healthcare/sdk/2021-06-01-preview/privatelinkresources/method_listbyservice_autorest.go deleted file mode 100644 index a13255a4d1bb..000000000000 --- a/internal/services/healthcare/sdk/2021-06-01-preview/privatelinkresources/method_listbyservice_autorest.go +++ /dev/null @@ -1,65 +0,0 @@ -package privatelinkresources - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -type ListByServiceResponse struct { - HttpResponse *http.Response - Model *PrivateLinkResourceListResultDescription -} - -// ListByService ... -func (c PrivateLinkResourcesClient) ListByService(ctx context.Context, id ServiceId) (result ListByServiceResponse, err error) { - req, err := c.preparerForListByService(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "privatelinkresources.PrivateLinkResourcesClient", "ListByService", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "privatelinkresources.PrivateLinkResourcesClient", "ListByService", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByService(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "privatelinkresources.PrivateLinkResourcesClient", "ListByService", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForListByService prepares the ListByService request. -func (c PrivateLinkResourcesClient) 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/privateLinkResources", 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 PrivateLinkResourcesClient) responderForListByService(resp *http.Response) (result ListByServiceResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - return -} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/privatelinkresources/model_privatelinkresourcedescription.go b/internal/services/healthcare/sdk/2021-06-01-preview/privatelinkresources/model_privatelinkresourcedescription.go deleted file mode 100644 index cd11d5179a60..000000000000 --- a/internal/services/healthcare/sdk/2021-06-01-preview/privatelinkresources/model_privatelinkresourcedescription.go +++ /dev/null @@ -1,9 +0,0 @@ -package privatelinkresources - -type PrivateLinkResourceDescription struct { - Id *string `json:"id,omitempty"` - Name *string `json:"name,omitempty"` - Properties *PrivateLinkResourceProperties `json:"properties,omitempty"` - SystemData *SystemData `json:"systemData,omitempty"` - Type *string `json:"type,omitempty"` -} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/privatelinkresources/model_privatelinkresourcelistresultdescription.go b/internal/services/healthcare/sdk/2021-06-01-preview/privatelinkresources/model_privatelinkresourcelistresultdescription.go deleted file mode 100644 index 9bf0baa227c8..000000000000 --- a/internal/services/healthcare/sdk/2021-06-01-preview/privatelinkresources/model_privatelinkresourcelistresultdescription.go +++ /dev/null @@ -1,5 +0,0 @@ -package privatelinkresources - -type PrivateLinkResourceListResultDescription struct { - Value *[]PrivateLinkResourceDescription `json:"value,omitempty"` -} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/privatelinkresources/model_privatelinkresourceproperties.go b/internal/services/healthcare/sdk/2021-06-01-preview/privatelinkresources/model_privatelinkresourceproperties.go deleted file mode 100644 index 51bc838c1fbd..000000000000 --- a/internal/services/healthcare/sdk/2021-06-01-preview/privatelinkresources/model_privatelinkresourceproperties.go +++ /dev/null @@ -1,7 +0,0 @@ -package privatelinkresources - -type PrivateLinkResourceProperties struct { - GroupId *string `json:"groupId,omitempty"` - RequiredMembers *[]string `json:"requiredMembers,omitempty"` - RequiredZoneNames *[]string `json:"requiredZoneNames,omitempty"` -} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/privatelinkresources/model_systemdata.go b/internal/services/healthcare/sdk/2021-06-01-preview/privatelinkresources/model_systemdata.go deleted file mode 100644 index f9327b762df1..000000000000 --- a/internal/services/healthcare/sdk/2021-06-01-preview/privatelinkresources/model_systemdata.go +++ /dev/null @@ -1,40 +0,0 @@ -package privatelinkresources - -import ( - "time" - - "github.com/hashicorp/go-azure-helpers/lang/dates" -) - -type SystemData struct { - CreatedAt *string `json:"createdAt,omitempty"` - CreatedBy *string `json:"createdBy,omitempty"` - CreatedByType *CreatedByType `json:"createdByType,omitempty"` - LastModifiedAt *string `json:"lastModifiedAt,omitempty"` - LastModifiedBy *string `json:"lastModifiedBy,omitempty"` - LastModifiedByType *CreatedByType `json:"lastModifiedByType,omitempty"` -} - -func (o SystemData) GetCreatedAtAsTime() (*time.Time, error) { - if o.CreatedAt == nil { - return nil, nil - } - return dates.ParseAsFormat(o.CreatedAt, "2006-01-02T15:04:05Z07:00") -} - -func (o SystemData) SetCreatedAtAsTime(input time.Time) { - formatted := input.Format("2006-01-02T15:04:05Z07:00") - o.CreatedAt = &formatted -} - -func (o SystemData) GetLastModifiedAtAsTime() (*time.Time, error) { - if o.LastModifiedAt == nil { - return nil, nil - } - return dates.ParseAsFormat(o.LastModifiedAt, "2006-01-02T15:04:05Z07:00") -} - -func (o SystemData) SetLastModifiedAtAsTime(input time.Time) { - formatted := input.Format("2006-01-02T15:04:05Z07:00") - o.LastModifiedAt = &formatted -} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/privatelinkresources/version.go b/internal/services/healthcare/sdk/2021-06-01-preview/privatelinkresources/version.go deleted file mode 100644 index 3b010fbce310..000000000000 --- a/internal/services/healthcare/sdk/2021-06-01-preview/privatelinkresources/version.go +++ /dev/null @@ -1,9 +0,0 @@ -package privatelinkresources - -import "fmt" - -const defaultApiVersion = "2021-06-01-preview" - -func userAgent() string { - return fmt.Sprintf("pandora/privatelinkresources/%s", defaultApiVersion) -} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/proxy/client.go b/internal/services/healthcare/sdk/2021-06-01-preview/proxy/client.go deleted file mode 100644 index 6acefce56ad5..000000000000 --- a/internal/services/healthcare/sdk/2021-06-01-preview/proxy/client.go +++ /dev/null @@ -1,15 +0,0 @@ -package proxy - -import "github.com/Azure/go-autorest/autorest" - -type ProxyClient struct { - Client autorest.Client - baseUri string -} - -func NewProxyClientWithBaseURI(endpoint string) ProxyClient { - return ProxyClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, - } -} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/proxy/constants.go b/internal/services/healthcare/sdk/2021-06-01-preview/proxy/constants.go deleted file mode 100644 index 6e0c4744ebfc..000000000000 --- a/internal/services/healthcare/sdk/2021-06-01-preview/proxy/constants.go +++ /dev/null @@ -1,31 +0,0 @@ -package proxy - -import "strings" - -type ServiceNameUnavailabilityReason string - -const ( - ServiceNameUnavailabilityReasonAlreadyExists ServiceNameUnavailabilityReason = "AlreadyExists" - ServiceNameUnavailabilityReasonInvalid ServiceNameUnavailabilityReason = "Invalid" -) - -func PossibleValuesForServiceNameUnavailabilityReason() []string { - return []string{ - string(ServiceNameUnavailabilityReasonAlreadyExists), - string(ServiceNameUnavailabilityReasonInvalid), - } -} - -func parseServiceNameUnavailabilityReason(input string) (*ServiceNameUnavailabilityReason, error) { - vals := map[string]ServiceNameUnavailabilityReason{ - "alreadyexists": ServiceNameUnavailabilityReasonAlreadyExists, - "invalid": ServiceNameUnavailabilityReasonInvalid, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := ServiceNameUnavailabilityReason(input) - return &out, nil -} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/proxy/method_serviceschecknameavailability_autorest.go b/internal/services/healthcare/sdk/2021-06-01-preview/proxy/method_serviceschecknameavailability_autorest.go deleted file mode 100644 index b44d479fa8e6..000000000000 --- a/internal/services/healthcare/sdk/2021-06-01-preview/proxy/method_serviceschecknameavailability_autorest.go +++ /dev/null @@ -1,67 +0,0 @@ -package proxy - -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" -) - -type ServicesCheckNameAvailabilityResponse struct { - HttpResponse *http.Response - Model *ServicesNameAvailabilityInfo -} - -// ServicesCheckNameAvailability ... -func (c ProxyClient) ServicesCheckNameAvailability(ctx context.Context, id commonids.SubscriptionId, input CheckNameAvailabilityParameters) (result ServicesCheckNameAvailabilityResponse, err error) { - req, err := c.preparerForServicesCheckNameAvailability(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "proxy.ProxyClient", "ServicesCheckNameAvailability", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "proxy.ProxyClient", "ServicesCheckNameAvailability", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForServicesCheckNameAvailability(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "proxy.ProxyClient", "ServicesCheckNameAvailability", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForServicesCheckNameAvailability prepares the ServicesCheckNameAvailability request. -func (c ProxyClient) preparerForServicesCheckNameAvailability(ctx context.Context, id commonids.SubscriptionId, input CheckNameAvailabilityParameters) (*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.HealthcareApis/checkNameAvailability", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForServicesCheckNameAvailability handles the response to the ServicesCheckNameAvailability request. The method always -// closes the http.Response Body. -func (c ProxyClient) responderForServicesCheckNameAvailability(resp *http.Response) (result ServicesCheckNameAvailabilityResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - return -} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/proxy/model_checknameavailabilityparameters.go b/internal/services/healthcare/sdk/2021-06-01-preview/proxy/model_checknameavailabilityparameters.go deleted file mode 100644 index 0759b12e6f95..000000000000 --- a/internal/services/healthcare/sdk/2021-06-01-preview/proxy/model_checknameavailabilityparameters.go +++ /dev/null @@ -1,6 +0,0 @@ -package proxy - -type CheckNameAvailabilityParameters struct { - Name string `json:"name"` - Type string `json:"type"` -} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/proxy/model_servicesnameavailabilityinfo.go b/internal/services/healthcare/sdk/2021-06-01-preview/proxy/model_servicesnameavailabilityinfo.go deleted file mode 100644 index 1a5e4c9f2cfa..000000000000 --- a/internal/services/healthcare/sdk/2021-06-01-preview/proxy/model_servicesnameavailabilityinfo.go +++ /dev/null @@ -1,7 +0,0 @@ -package proxy - -type ServicesNameAvailabilityInfo struct { - Message *string `json:"message,omitempty"` - NameAvailable *bool `json:"nameAvailable,omitempty"` - Reason *ServiceNameUnavailabilityReason `json:"reason,omitempty"` -} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/proxy/version.go b/internal/services/healthcare/sdk/2021-06-01-preview/proxy/version.go deleted file mode 100644 index f29045459778..000000000000 --- a/internal/services/healthcare/sdk/2021-06-01-preview/proxy/version.go +++ /dev/null @@ -1,9 +0,0 @@ -package proxy - -import "fmt" - -const defaultApiVersion = "2021-06-01-preview" - -func userAgent() string { - return fmt.Sprintf("pandora/proxy/%s", defaultApiVersion) -} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/resource/client.go b/internal/services/healthcare/sdk/2021-06-01-preview/resource/client.go deleted file mode 100644 index d9f8bbb20ce1..000000000000 --- a/internal/services/healthcare/sdk/2021-06-01-preview/resource/client.go +++ /dev/null @@ -1,15 +0,0 @@ -package resource - -import "github.com/Azure/go-autorest/autorest" - -type ResourceClient struct { - Client autorest.Client - baseUri string -} - -func NewResourceClientWithBaseURI(endpoint string) ResourceClient { - return ResourceClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, - } -} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/resource/constants.go b/internal/services/healthcare/sdk/2021-06-01-preview/resource/constants.go deleted file mode 100644 index cf424b1eea1a..000000000000 --- a/internal/services/healthcare/sdk/2021-06-01-preview/resource/constants.go +++ /dev/null @@ -1,210 +0,0 @@ -package resource - -import "strings" - -type CreatedByType string - -const ( - CreatedByTypeApplication CreatedByType = "Application" - CreatedByTypeKey CreatedByType = "Key" - CreatedByTypeManagedIdentity CreatedByType = "ManagedIdentity" - CreatedByTypeUser CreatedByType = "User" -) - -func PossibleValuesForCreatedByType() []string { - return []string{ - string(CreatedByTypeApplication), - string(CreatedByTypeKey), - string(CreatedByTypeManagedIdentity), - string(CreatedByTypeUser), - } -} - -func parseCreatedByType(input string) (*CreatedByType, error) { - vals := map[string]CreatedByType{ - "application": CreatedByTypeApplication, - "key": CreatedByTypeKey, - "managedidentity": CreatedByTypeManagedIdentity, - "user": CreatedByTypeUser, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := CreatedByType(input) - return &out, nil -} - -type Kind string - -const ( - KindFhir Kind = "fhir" - KindFhirNegativeRFour Kind = "fhir-R4" - KindFhirNegativeStuThree Kind = "fhir-Stu3" -) - -func PossibleValuesForKind() []string { - return []string{ - string(KindFhir), - string(KindFhirNegativeRFour), - string(KindFhirNegativeStuThree), - } -} - -func parseKind(input string) (*Kind, error) { - vals := map[string]Kind{ - "fhir": KindFhir, - "fhir-r4": KindFhirNegativeRFour, - "fhir-stu3": KindFhirNegativeStuThree, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := Kind(input) - return &out, nil -} - -type PrivateEndpointConnectionProvisioningState string - -const ( - PrivateEndpointConnectionProvisioningStateCreating PrivateEndpointConnectionProvisioningState = "Creating" - PrivateEndpointConnectionProvisioningStateDeleting PrivateEndpointConnectionProvisioningState = "Deleting" - PrivateEndpointConnectionProvisioningStateFailed PrivateEndpointConnectionProvisioningState = "Failed" - PrivateEndpointConnectionProvisioningStateSucceeded PrivateEndpointConnectionProvisioningState = "Succeeded" -) - -func PossibleValuesForPrivateEndpointConnectionProvisioningState() []string { - return []string{ - string(PrivateEndpointConnectionProvisioningStateCreating), - string(PrivateEndpointConnectionProvisioningStateDeleting), - string(PrivateEndpointConnectionProvisioningStateFailed), - string(PrivateEndpointConnectionProvisioningStateSucceeded), - } -} - -func parsePrivateEndpointConnectionProvisioningState(input string) (*PrivateEndpointConnectionProvisioningState, error) { - vals := map[string]PrivateEndpointConnectionProvisioningState{ - "creating": PrivateEndpointConnectionProvisioningStateCreating, - "deleting": PrivateEndpointConnectionProvisioningStateDeleting, - "failed": PrivateEndpointConnectionProvisioningStateFailed, - "succeeded": PrivateEndpointConnectionProvisioningStateSucceeded, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := PrivateEndpointConnectionProvisioningState(input) - return &out, nil -} - -type PrivateEndpointServiceConnectionStatus string - -const ( - PrivateEndpointServiceConnectionStatusApproved PrivateEndpointServiceConnectionStatus = "Approved" - PrivateEndpointServiceConnectionStatusPending PrivateEndpointServiceConnectionStatus = "Pending" - PrivateEndpointServiceConnectionStatusRejected PrivateEndpointServiceConnectionStatus = "Rejected" -) - -func PossibleValuesForPrivateEndpointServiceConnectionStatus() []string { - return []string{ - string(PrivateEndpointServiceConnectionStatusApproved), - string(PrivateEndpointServiceConnectionStatusPending), - string(PrivateEndpointServiceConnectionStatusRejected), - } -} - -func parsePrivateEndpointServiceConnectionStatus(input string) (*PrivateEndpointServiceConnectionStatus, error) { - vals := map[string]PrivateEndpointServiceConnectionStatus{ - "approved": PrivateEndpointServiceConnectionStatusApproved, - "pending": PrivateEndpointServiceConnectionStatusPending, - "rejected": PrivateEndpointServiceConnectionStatusRejected, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := PrivateEndpointServiceConnectionStatus(input) - return &out, nil -} - -type ProvisioningState string - -const ( - ProvisioningStateAccepted ProvisioningState = "Accepted" - ProvisioningStateCanceled ProvisioningState = "Canceled" - ProvisioningStateCreating ProvisioningState = "Creating" - ProvisioningStateDeleting ProvisioningState = "Deleting" - ProvisioningStateDeprovisioned ProvisioningState = "Deprovisioned" - ProvisioningStateFailed ProvisioningState = "Failed" - ProvisioningStateSucceeded ProvisioningState = "Succeeded" - ProvisioningStateUpdating ProvisioningState = "Updating" - ProvisioningStateVerifying ProvisioningState = "Verifying" -) - -func PossibleValuesForProvisioningState() []string { - return []string{ - string(ProvisioningStateAccepted), - string(ProvisioningStateCanceled), - string(ProvisioningStateCreating), - string(ProvisioningStateDeleting), - string(ProvisioningStateDeprovisioned), - string(ProvisioningStateFailed), - string(ProvisioningStateSucceeded), - string(ProvisioningStateUpdating), - string(ProvisioningStateVerifying), - } -} - -func parseProvisioningState(input string) (*ProvisioningState, error) { - vals := map[string]ProvisioningState{ - "accepted": ProvisioningStateAccepted, - "canceled": ProvisioningStateCanceled, - "creating": ProvisioningStateCreating, - "deleting": ProvisioningStateDeleting, - "deprovisioned": ProvisioningStateDeprovisioned, - "failed": ProvisioningStateFailed, - "succeeded": ProvisioningStateSucceeded, - "updating": ProvisioningStateUpdating, - "verifying": ProvisioningStateVerifying, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := ProvisioningState(input) - return &out, nil -} - -type PublicNetworkAccess string - -const ( - PublicNetworkAccessDisabled PublicNetworkAccess = "Disabled" - PublicNetworkAccessEnabled PublicNetworkAccess = "Enabled" -) - -func PossibleValuesForPublicNetworkAccess() []string { - return []string{ - string(PublicNetworkAccessDisabled), - string(PublicNetworkAccessEnabled), - } -} - -func parsePublicNetworkAccess(input string) (*PublicNetworkAccess, error) { - vals := map[string]PublicNetworkAccess{ - "disabled": PublicNetworkAccessDisabled, - "enabled": PublicNetworkAccessEnabled, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := PublicNetworkAccess(input) - return &out, nil -} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/resource/id_service.go b/internal/services/healthcare/sdk/2021-06-01-preview/resource/id_service.go deleted file mode 100644 index 89356f6a5a16..000000000000 --- a/internal/services/healthcare/sdk/2021-06-01-preview/resource/id_service.go +++ /dev/null @@ -1,124 +0,0 @@ -package resource - -import ( - "fmt" - "strings" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -var _ resourceids.ResourceId = ServiceId{} - -// ServiceId is a struct representing the Resource ID for a Service -type ServiceId struct { - SubscriptionId string - ResourceGroupName string - ResourceName string -} - -// NewServiceID returns a new ServiceId struct -func NewServiceID(subscriptionId string, resourceGroupName string, resourceName string) ServiceId { - return ServiceId{ - SubscriptionId: subscriptionId, - ResourceGroupName: resourceGroupName, - ResourceName: resourceName, - } -} - -// ParseServiceID parses 'input' into a ServiceId -func ParseServiceID(input string) (*ServiceId, error) { - parser := resourceids.NewParserFromResourceIdType(ServiceId{}) - parsed, err := parser.Parse(input, false) - if err != nil { - return nil, fmt.Errorf("parsing %q: %+v", input, err) - } - - var ok bool - id := ServiceId{} - - if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { - return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) - } - - if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { - return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) - } - - if id.ResourceName, ok = parsed.Parsed["resourceName"]; !ok { - return nil, fmt.Errorf("the segment 'resourceName' was not found in the resource id %q", input) - } - - return &id, nil -} - -// ParseServiceIDInsensitively parses 'input' case-insensitively into a ServiceId -// note: this method should only be used for API response data and not user input -func ParseServiceIDInsensitively(input string) (*ServiceId, error) { - parser := resourceids.NewParserFromResourceIdType(ServiceId{}) - parsed, err := parser.Parse(input, true) - if err != nil { - return nil, fmt.Errorf("parsing %q: %+v", input, err) - } - - var ok bool - id := ServiceId{} - - if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { - return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) - } - - if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { - return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) - } - - if id.ResourceName, ok = parsed.Parsed["resourceName"]; !ok { - return nil, fmt.Errorf("the segment 'resourceName' was not found in the resource id %q", input) - } - - return &id, nil -} - -// ValidateServiceID checks that 'input' can be parsed as a Service ID -func ValidateServiceID(input interface{}, key string) (warnings []string, errors []error) { - v, ok := input.(string) - if !ok { - errors = append(errors, fmt.Errorf("expected %q to be a string", key)) - return - } - - if _, err := ParseServiceID(v); err != nil { - errors = append(errors, err) - } - - return -} - -// ID returns the formatted Service ID -func (id ServiceId) ID() string { - fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.HealthcareApis/services/%s" - return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ResourceName) -} - -// Segments returns a slice of Resource ID Segments which comprise this Service ID -func (id ServiceId) Segments() []resourceids.Segment { - return []resourceids.Segment{ - resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), - resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), - resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), - resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), - resourceids.StaticSegment("staticProviders", "providers", "providers"), - resourceids.ResourceProviderSegment("staticMicrosoftHealthcareApis", "Microsoft.HealthcareApis", "Microsoft.HealthcareApis"), - resourceids.StaticSegment("staticServices", "services", "services"), - resourceids.UserSpecifiedSegment("resourceName", "resourceValue"), - } -} - -// String returns a human-readable description of this Service ID -func (id ServiceId) String() string { - components := []string{ - fmt.Sprintf("Subscription: %q", id.SubscriptionId), - fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), - fmt.Sprintf("Resource Name: %q", id.ResourceName), - } - return fmt.Sprintf("Service (%s)", strings.Join(components, "\n")) -} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/resource/id_service_test.go b/internal/services/healthcare/sdk/2021-06-01-preview/resource/id_service_test.go deleted file mode 100644 index d10df20a6de0..000000000000 --- a/internal/services/healthcare/sdk/2021-06-01-preview/resource/id_service_test.go +++ /dev/null @@ -1,279 +0,0 @@ -package resource - -import ( - "testing" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -var _ resourceids.ResourceId = ServiceId{} - -func TestNewServiceID(t *testing.T) { - id := NewServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "resourceValue") - - if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { - t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") - } - - if id.ResourceGroupName != "example-resource-group" { - t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") - } - - if id.ResourceName != "resourceValue" { - t.Fatalf("Expected %q but got %q for Segment 'ResourceName'", id.ResourceName, "resourceValue") - } -} - -func TestFormatServiceID(t *testing.T) { - actual := NewServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "resourceValue").ID() - expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/services/resourceValue" - if actual != expected { - t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) - } -} - -func TestParseServiceID(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *ServiceId - }{ - { - // Incomplete URI - Input: "", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/services", - Error: true, - }, - { - // Valid URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/services/resourceValue", - Expected: &ServiceId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "example-resource-group", - ResourceName: "resourceValue", - }, - }, - { - // Invalid (Valid Uri with Extra segment) - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/services/resourceValue/extra", - Error: true, - }, - } - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := ParseServiceID(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expect a value but got an error: %+v", err) - } - if v.Error { - t.Fatal("Expect an error but didn't get one") - } - - if actual.SubscriptionId != v.Expected.SubscriptionId { - t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) - } - - if actual.ResourceGroupName != v.Expected.ResourceGroupName { - t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) - } - - if actual.ResourceName != v.Expected.ResourceName { - t.Fatalf("Expected %q but got %q for ResourceName", v.Expected.ResourceName, actual.ResourceName) - } - - } -} - -func TestParseServiceIDInsensitively(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *ServiceId - }{ - { - // Incomplete URI - Input: "", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hEaLtHcArEaPiS", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/services", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hEaLtHcArEaPiS/sErViCeS", - Error: true, - }, - { - // Valid URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/services/resourceValue", - Expected: &ServiceId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "example-resource-group", - ResourceName: "resourceValue", - }, - }, - { - // Invalid (Valid Uri with Extra segment) - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/services/resourceValue/extra", - Error: true, - }, - { - // Valid URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hEaLtHcArEaPiS/sErViCeS/rEsOuRcEvAlUe", - Expected: &ServiceId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", - ResourceName: "rEsOuRcEvAlUe", - }, - }, - { - // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hEaLtHcArEaPiS/sErViCeS/rEsOuRcEvAlUe/extra", - Error: true, - }, - } - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := ParseServiceIDInsensitively(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expect a value but got an error: %+v", err) - } - if v.Error { - t.Fatal("Expect an error but didn't get one") - } - - if actual.SubscriptionId != v.Expected.SubscriptionId { - t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) - } - - if actual.ResourceGroupName != v.Expected.ResourceGroupName { - t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) - } - - if actual.ResourceName != v.Expected.ResourceName { - t.Fatalf("Expected %q but got %q for ResourceName", v.Expected.ResourceName, actual.ResourceName) - } - - } -} - -func TestSegmentsForServiceId(t *testing.T) { - segments := ServiceId{}.Segments() - if len(segments) == 0 { - t.Fatalf("ServiceId has no segments") - } - - uniqueNames := make(map[string]struct{}, 0) - for _, segment := range segments { - uniqueNames[segment.Name] = struct{}{} - } - if len(uniqueNames) != len(segments) { - t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) - } -} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/resource/method_servicescreateorupdate_autorest.go b/internal/services/healthcare/sdk/2021-06-01-preview/resource/method_servicescreateorupdate_autorest.go deleted file mode 100644 index 2f038ae8eecf..000000000000 --- a/internal/services/healthcare/sdk/2021-06-01-preview/resource/method_servicescreateorupdate_autorest.go +++ /dev/null @@ -1,75 +0,0 @@ -package resource - -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" -) - -type ServicesCreateOrUpdateResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// ServicesCreateOrUpdate ... -func (c ResourceClient) ServicesCreateOrUpdate(ctx context.Context, id ServiceId, input ServicesDescription) (result ServicesCreateOrUpdateResponse, err error) { - req, err := c.preparerForServicesCreateOrUpdate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "resource.ResourceClient", "ServicesCreateOrUpdate", nil, "Failure preparing request") - return - } - - result, err = c.senderForServicesCreateOrUpdate(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "resource.ResourceClient", "ServicesCreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// ServicesCreateOrUpdateThenPoll performs ServicesCreateOrUpdate then polls until it's completed -func (c ResourceClient) ServicesCreateOrUpdateThenPoll(ctx context.Context, id ServiceId, input ServicesDescription) error { - result, err := c.ServicesCreateOrUpdate(ctx, id, input) - if err != nil { - return fmt.Errorf("performing ServicesCreateOrUpdate: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after ServicesCreateOrUpdate: %+v", err) - } - - return nil -} - -// preparerForServicesCreateOrUpdate prepares the ServicesCreateOrUpdate request. -func (c ResourceClient) preparerForServicesCreateOrUpdate(ctx context.Context, id ServiceId, input ServicesDescription) (*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)) -} - -// senderForServicesCreateOrUpdate sends the ServicesCreateOrUpdate request. The method will close the -// http.Response Body if it receives an error. -func (c ResourceClient) senderForServicesCreateOrUpdate(ctx context.Context, req *http.Request) (future ServicesCreateOrUpdateResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - future.Poller, err = polling.NewLongRunningPollerFromResponse(ctx, resp, c.Client) - return -} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/resource/method_servicesdelete_autorest.go b/internal/services/healthcare/sdk/2021-06-01-preview/resource/method_servicesdelete_autorest.go deleted file mode 100644 index dbe35e0b6207..000000000000 --- a/internal/services/healthcare/sdk/2021-06-01-preview/resource/method_servicesdelete_autorest.go +++ /dev/null @@ -1,74 +0,0 @@ -package resource - -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" -) - -type ServicesDeleteResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// ServicesDelete ... -func (c ResourceClient) ServicesDelete(ctx context.Context, id ServiceId) (result ServicesDeleteResponse, err error) { - req, err := c.preparerForServicesDelete(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "resource.ResourceClient", "ServicesDelete", nil, "Failure preparing request") - return - } - - result, err = c.senderForServicesDelete(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "resource.ResourceClient", "ServicesDelete", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// ServicesDeleteThenPoll performs ServicesDelete then polls until it's completed -func (c ResourceClient) ServicesDeleteThenPoll(ctx context.Context, id ServiceId) error { - result, err := c.ServicesDelete(ctx, id) - if err != nil { - return fmt.Errorf("performing ServicesDelete: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after ServicesDelete: %+v", err) - } - - return nil -} - -// preparerForServicesDelete prepares the ServicesDelete request. -func (c ResourceClient) preparerForServicesDelete(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)) -} - -// senderForServicesDelete sends the ServicesDelete request. The method will close the -// http.Response Body if it receives an error. -func (c ResourceClient) senderForServicesDelete(ctx context.Context, req *http.Request) (future ServicesDeleteResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - future.Poller, err = polling.NewLongRunningPollerFromResponse(ctx, resp, c.Client) - return -} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/resource/method_servicesget_autorest.go b/internal/services/healthcare/sdk/2021-06-01-preview/resource/method_servicesget_autorest.go deleted file mode 100644 index 6bf9442cb8a1..000000000000 --- a/internal/services/healthcare/sdk/2021-06-01-preview/resource/method_servicesget_autorest.go +++ /dev/null @@ -1,64 +0,0 @@ -package resource - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -type ServicesGetResponse struct { - HttpResponse *http.Response - Model *ServicesDescription -} - -// ServicesGet ... -func (c ResourceClient) ServicesGet(ctx context.Context, id ServiceId) (result ServicesGetResponse, err error) { - req, err := c.preparerForServicesGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "resource.ResourceClient", "ServicesGet", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "resource.ResourceClient", "ServicesGet", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForServicesGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "resource.ResourceClient", "ServicesGet", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForServicesGet prepares the ServicesGet request. -func (c ResourceClient) preparerForServicesGet(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)) -} - -// responderForServicesGet handles the response to the ServicesGet request. The method always -// closes the http.Response Body. -func (c ResourceClient) responderForServicesGet(resp *http.Response) (result ServicesGetResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - return -} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/resource/method_servicesupdate_autorest.go b/internal/services/healthcare/sdk/2021-06-01-preview/resource/method_servicesupdate_autorest.go deleted file mode 100644 index 9f8acc63f12a..000000000000 --- a/internal/services/healthcare/sdk/2021-06-01-preview/resource/method_servicesupdate_autorest.go +++ /dev/null @@ -1,75 +0,0 @@ -package resource - -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" -) - -type ServicesUpdateResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// ServicesUpdate ... -func (c ResourceClient) ServicesUpdate(ctx context.Context, id ServiceId, input ServicesPatchDescription) (result ServicesUpdateResponse, err error) { - req, err := c.preparerForServicesUpdate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "resource.ResourceClient", "ServicesUpdate", nil, "Failure preparing request") - return - } - - result, err = c.senderForServicesUpdate(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "resource.ResourceClient", "ServicesUpdate", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// ServicesUpdateThenPoll performs ServicesUpdate then polls until it's completed -func (c ResourceClient) ServicesUpdateThenPoll(ctx context.Context, id ServiceId, input ServicesPatchDescription) error { - result, err := c.ServicesUpdate(ctx, id, input) - if err != nil { - return fmt.Errorf("performing ServicesUpdate: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after ServicesUpdate: %+v", err) - } - - return nil -} - -// preparerForServicesUpdate prepares the ServicesUpdate request. -func (c ResourceClient) preparerForServicesUpdate(ctx context.Context, id ServiceId, input ServicesPatchDescription) (*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)) -} - -// senderForServicesUpdate sends the ServicesUpdate request. The method will close the -// http.Response Body if it receives an error. -func (c ResourceClient) senderForServicesUpdate(ctx context.Context, req *http.Request) (future ServicesUpdateResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - future.Poller, err = polling.NewLongRunningPollerFromResponse(ctx, resp, c.Client) - return -} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/resource/model_privateendpoint.go b/internal/services/healthcare/sdk/2021-06-01-preview/resource/model_privateendpoint.go deleted file mode 100644 index 91d2298ebef4..000000000000 --- a/internal/services/healthcare/sdk/2021-06-01-preview/resource/model_privateendpoint.go +++ /dev/null @@ -1,5 +0,0 @@ -package resource - -type PrivateEndpoint struct { - Id *string `json:"id,omitempty"` -} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/resource/model_privateendpointconnection.go b/internal/services/healthcare/sdk/2021-06-01-preview/resource/model_privateendpointconnection.go deleted file mode 100644 index 8a588e9071b9..000000000000 --- a/internal/services/healthcare/sdk/2021-06-01-preview/resource/model_privateendpointconnection.go +++ /dev/null @@ -1,8 +0,0 @@ -package resource - -type PrivateEndpointConnection struct { - Id *string `json:"id,omitempty"` - Name *string `json:"name,omitempty"` - Properties *PrivateEndpointConnectionProperties `json:"properties,omitempty"` - Type *string `json:"type,omitempty"` -} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/resource/model_privateendpointconnectionproperties.go b/internal/services/healthcare/sdk/2021-06-01-preview/resource/model_privateendpointconnectionproperties.go deleted file mode 100644 index f2b79dce8bc5..000000000000 --- a/internal/services/healthcare/sdk/2021-06-01-preview/resource/model_privateendpointconnectionproperties.go +++ /dev/null @@ -1,7 +0,0 @@ -package resource - -type PrivateEndpointConnectionProperties struct { - PrivateEndpoint *PrivateEndpoint `json:"privateEndpoint,omitempty"` - PrivateLinkServiceConnectionState PrivateLinkServiceConnectionState `json:"privateLinkServiceConnectionState"` - ProvisioningState *PrivateEndpointConnectionProvisioningState `json:"provisioningState,omitempty"` -} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/resource/model_privatelinkserviceconnectionstate.go b/internal/services/healthcare/sdk/2021-06-01-preview/resource/model_privatelinkserviceconnectionstate.go deleted file mode 100644 index 3617e3db806b..000000000000 --- a/internal/services/healthcare/sdk/2021-06-01-preview/resource/model_privatelinkserviceconnectionstate.go +++ /dev/null @@ -1,7 +0,0 @@ -package resource - -type PrivateLinkServiceConnectionState struct { - ActionsRequired *string `json:"actionsRequired,omitempty"` - Description *string `json:"description,omitempty"` - Status *PrivateEndpointServiceConnectionStatus `json:"status,omitempty"` -} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/resource/model_serviceaccesspolicyentry.go b/internal/services/healthcare/sdk/2021-06-01-preview/resource/model_serviceaccesspolicyentry.go deleted file mode 100644 index bb7d73d7f581..000000000000 --- a/internal/services/healthcare/sdk/2021-06-01-preview/resource/model_serviceaccesspolicyentry.go +++ /dev/null @@ -1,5 +0,0 @@ -package resource - -type ServiceAccessPolicyEntry struct { - ObjectId string `json:"objectId"` -} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/resource/model_serviceacrconfigurationinfo.go b/internal/services/healthcare/sdk/2021-06-01-preview/resource/model_serviceacrconfigurationinfo.go deleted file mode 100644 index 45d58c3f22c2..000000000000 --- a/internal/services/healthcare/sdk/2021-06-01-preview/resource/model_serviceacrconfigurationinfo.go +++ /dev/null @@ -1,5 +0,0 @@ -package resource - -type ServiceAcrConfigurationInfo struct { - LoginServers *[]string `json:"loginServers,omitempty"` -} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/resource/model_serviceauthenticationconfigurationinfo.go b/internal/services/healthcare/sdk/2021-06-01-preview/resource/model_serviceauthenticationconfigurationinfo.go deleted file mode 100644 index b15aeecb91eb..000000000000 --- a/internal/services/healthcare/sdk/2021-06-01-preview/resource/model_serviceauthenticationconfigurationinfo.go +++ /dev/null @@ -1,7 +0,0 @@ -package resource - -type ServiceAuthenticationConfigurationInfo struct { - Audience *string `json:"audience,omitempty"` - Authority *string `json:"authority,omitempty"` - SmartProxyEnabled *bool `json:"smartProxyEnabled,omitempty"` -} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/resource/model_servicecorsconfigurationinfo.go b/internal/services/healthcare/sdk/2021-06-01-preview/resource/model_servicecorsconfigurationinfo.go deleted file mode 100644 index 3222eb38f35f..000000000000 --- a/internal/services/healthcare/sdk/2021-06-01-preview/resource/model_servicecorsconfigurationinfo.go +++ /dev/null @@ -1,9 +0,0 @@ -package resource - -type ServiceCorsConfigurationInfo struct { - AllowCredentials *bool `json:"allowCredentials,omitempty"` - Headers *[]string `json:"headers,omitempty"` - MaxAge *int64 `json:"maxAge,omitempty"` - Methods *[]string `json:"methods,omitempty"` - Origins *[]string `json:"origins,omitempty"` -} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/resource/model_servicecosmosdbconfigurationinfo.go b/internal/services/healthcare/sdk/2021-06-01-preview/resource/model_servicecosmosdbconfigurationinfo.go deleted file mode 100644 index bbdfe7992e43..000000000000 --- a/internal/services/healthcare/sdk/2021-06-01-preview/resource/model_servicecosmosdbconfigurationinfo.go +++ /dev/null @@ -1,6 +0,0 @@ -package resource - -type ServiceCosmosDbConfigurationInfo struct { - KeyVaultKeyUri *string `json:"keyVaultKeyUri,omitempty"` - OfferThroughput *int64 `json:"offerThroughput,omitempty"` -} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/resource/model_serviceexportconfigurationinfo.go b/internal/services/healthcare/sdk/2021-06-01-preview/resource/model_serviceexportconfigurationinfo.go deleted file mode 100644 index 35ea1dbe59c1..000000000000 --- a/internal/services/healthcare/sdk/2021-06-01-preview/resource/model_serviceexportconfigurationinfo.go +++ /dev/null @@ -1,5 +0,0 @@ -package resource - -type ServiceExportConfigurationInfo struct { - StorageAccountName *string `json:"storageAccountName,omitempty"` -} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/resource/model_servicesdescription.go b/internal/services/healthcare/sdk/2021-06-01-preview/resource/model_servicesdescription.go deleted file mode 100644 index 94364d8f618b..000000000000 --- a/internal/services/healthcare/sdk/2021-06-01-preview/resource/model_servicesdescription.go +++ /dev/null @@ -1,18 +0,0 @@ -package resource - -import ( - "github.com/hashicorp/go-azure-helpers/resourcemanager/identity" -) - -type ServicesDescription struct { - Etag *string `json:"etag,omitempty"` - Id *string `json:"id,omitempty"` - Identity *identity.SystemAssigned `json:"identity,omitempty"` - Kind Kind `json:"kind"` - Location string `json:"location"` - Name *string `json:"name,omitempty"` - Properties *ServicesProperties `json:"properties,omitempty"` - SystemData *SystemData `json:"systemData,omitempty"` - Tags *map[string]string `json:"tags,omitempty"` - Type *string `json:"type,omitempty"` -} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/resource/model_servicespatchdescription.go b/internal/services/healthcare/sdk/2021-06-01-preview/resource/model_servicespatchdescription.go deleted file mode 100644 index d1bcdfe6c558..000000000000 --- a/internal/services/healthcare/sdk/2021-06-01-preview/resource/model_servicespatchdescription.go +++ /dev/null @@ -1,6 +0,0 @@ -package resource - -type ServicesPatchDescription struct { - Properties *ServicesPropertiesUpdateParameters `json:"properties,omitempty"` - Tags *map[string]string `json:"tags,omitempty"` -} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/resource/model_servicesproperties.go b/internal/services/healthcare/sdk/2021-06-01-preview/resource/model_servicesproperties.go deleted file mode 100644 index 83dd58e7f604..000000000000 --- a/internal/services/healthcare/sdk/2021-06-01-preview/resource/model_servicesproperties.go +++ /dev/null @@ -1,13 +0,0 @@ -package resource - -type ServicesProperties struct { - AccessPolicies *[]ServiceAccessPolicyEntry `json:"accessPolicies,omitempty"` - AcrConfiguration *ServiceAcrConfigurationInfo `json:"acrConfiguration,omitempty"` - AuthenticationConfiguration *ServiceAuthenticationConfigurationInfo `json:"authenticationConfiguration,omitempty"` - CorsConfiguration *ServiceCorsConfigurationInfo `json:"corsConfiguration,omitempty"` - CosmosDbConfiguration *ServiceCosmosDbConfigurationInfo `json:"cosmosDbConfiguration,omitempty"` - ExportConfiguration *ServiceExportConfigurationInfo `json:"exportConfiguration,omitempty"` - PrivateEndpointConnections *[]PrivateEndpointConnection `json:"privateEndpointConnections,omitempty"` - ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` - PublicNetworkAccess *PublicNetworkAccess `json:"publicNetworkAccess,omitempty"` -} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/resource/model_servicespropertiesupdateparameters.go b/internal/services/healthcare/sdk/2021-06-01-preview/resource/model_servicespropertiesupdateparameters.go deleted file mode 100644 index bdee5e5622b7..000000000000 --- a/internal/services/healthcare/sdk/2021-06-01-preview/resource/model_servicespropertiesupdateparameters.go +++ /dev/null @@ -1,5 +0,0 @@ -package resource - -type ServicesPropertiesUpdateParameters struct { - PublicNetworkAccess *PublicNetworkAccess `json:"publicNetworkAccess,omitempty"` -} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/resource/model_systemdata.go b/internal/services/healthcare/sdk/2021-06-01-preview/resource/model_systemdata.go deleted file mode 100644 index 8d282622850b..000000000000 --- a/internal/services/healthcare/sdk/2021-06-01-preview/resource/model_systemdata.go +++ /dev/null @@ -1,40 +0,0 @@ -package resource - -import ( - "time" - - "github.com/hashicorp/go-azure-helpers/lang/dates" -) - -type SystemData struct { - CreatedAt *string `json:"createdAt,omitempty"` - CreatedBy *string `json:"createdBy,omitempty"` - CreatedByType *CreatedByType `json:"createdByType,omitempty"` - LastModifiedAt *string `json:"lastModifiedAt,omitempty"` - LastModifiedBy *string `json:"lastModifiedBy,omitempty"` - LastModifiedByType *CreatedByType `json:"lastModifiedByType,omitempty"` -} - -func (o SystemData) GetCreatedAtAsTime() (*time.Time, error) { - if o.CreatedAt == nil { - return nil, nil - } - return dates.ParseAsFormat(o.CreatedAt, "2006-01-02T15:04:05Z07:00") -} - -func (o SystemData) SetCreatedAtAsTime(input time.Time) { - formatted := input.Format("2006-01-02T15:04:05Z07:00") - o.CreatedAt = &formatted -} - -func (o SystemData) GetLastModifiedAtAsTime() (*time.Time, error) { - if o.LastModifiedAt == nil { - return nil, nil - } - return dates.ParseAsFormat(o.LastModifiedAt, "2006-01-02T15:04:05Z07:00") -} - -func (o SystemData) SetLastModifiedAtAsTime(input time.Time) { - formatted := input.Format("2006-01-02T15:04:05Z07:00") - o.LastModifiedAt = &formatted -} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/resource/version.go b/internal/services/healthcare/sdk/2021-06-01-preview/resource/version.go deleted file mode 100644 index ee7683965bcd..000000000000 --- a/internal/services/healthcare/sdk/2021-06-01-preview/resource/version.go +++ /dev/null @@ -1,9 +0,0 @@ -package resource - -import "fmt" - -const defaultApiVersion = "2021-06-01-preview" - -func userAgent() string { - return fmt.Sprintf("pandora/resource/%s", defaultApiVersion) -} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/workspaces/client.go b/internal/services/healthcare/sdk/2021-06-01-preview/workspaces/client.go deleted file mode 100644 index bc9eafbb30e3..000000000000 --- a/internal/services/healthcare/sdk/2021-06-01-preview/workspaces/client.go +++ /dev/null @@ -1,15 +0,0 @@ -package workspaces - -import "github.com/Azure/go-autorest/autorest" - -type WorkspacesClient struct { - Client autorest.Client - baseUri string -} - -func NewWorkspacesClientWithBaseURI(endpoint string) WorkspacesClient { - return WorkspacesClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, - } -} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/workspaces/constants.go b/internal/services/healthcare/sdk/2021-06-01-preview/workspaces/constants.go deleted file mode 100644 index 40caca680578..000000000000 --- a/internal/services/healthcare/sdk/2021-06-01-preview/workspaces/constants.go +++ /dev/null @@ -1,98 +0,0 @@ -package workspaces - -import "strings" - -type CreatedByType string - -const ( - CreatedByTypeApplication CreatedByType = "Application" - CreatedByTypeKey CreatedByType = "Key" - CreatedByTypeManagedIdentity CreatedByType = "ManagedIdentity" - CreatedByTypeUser CreatedByType = "User" -) - -func PossibleValuesForCreatedByType() []string { - return []string{ - string(CreatedByTypeApplication), - string(CreatedByTypeKey), - string(CreatedByTypeManagedIdentity), - string(CreatedByTypeUser), - } -} - -func parseCreatedByType(input string) (*CreatedByType, error) { - vals := map[string]CreatedByType{ - "application": CreatedByTypeApplication, - "key": CreatedByTypeKey, - "managedidentity": CreatedByTypeManagedIdentity, - "user": CreatedByTypeUser, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := CreatedByType(input) - return &out, nil -} - -type ProvisioningState string - -const ( - ProvisioningStateAccepted ProvisioningState = "Accepted" - ProvisioningStateCanceled ProvisioningState = "Canceled" - ProvisioningStateCreating ProvisioningState = "Creating" - ProvisioningStateDeleting ProvisioningState = "Deleting" - ProvisioningStateDeprovisioned ProvisioningState = "Deprovisioned" - ProvisioningStateFailed ProvisioningState = "Failed" - ProvisioningStateMoving ProvisioningState = "Moving" - ProvisioningStateSucceeded ProvisioningState = "Succeeded" - ProvisioningStateSuspended ProvisioningState = "Suspended" - ProvisioningStateSystemMaintenance ProvisioningState = "SystemMaintenance" - ProvisioningStateUpdating ProvisioningState = "Updating" - ProvisioningStateVerifying ProvisioningState = "Verifying" - ProvisioningStateWarned ProvisioningState = "Warned" -) - -func PossibleValuesForProvisioningState() []string { - return []string{ - string(ProvisioningStateAccepted), - string(ProvisioningStateCanceled), - string(ProvisioningStateCreating), - string(ProvisioningStateDeleting), - string(ProvisioningStateDeprovisioned), - string(ProvisioningStateFailed), - string(ProvisioningStateMoving), - string(ProvisioningStateSucceeded), - string(ProvisioningStateSuspended), - string(ProvisioningStateSystemMaintenance), - string(ProvisioningStateUpdating), - string(ProvisioningStateVerifying), - string(ProvisioningStateWarned), - } -} - -func parseProvisioningState(input string) (*ProvisioningState, error) { - vals := map[string]ProvisioningState{ - "accepted": ProvisioningStateAccepted, - "canceled": ProvisioningStateCanceled, - "creating": ProvisioningStateCreating, - "deleting": ProvisioningStateDeleting, - "deprovisioned": ProvisioningStateDeprovisioned, - "failed": ProvisioningStateFailed, - "moving": ProvisioningStateMoving, - "succeeded": ProvisioningStateSucceeded, - "suspended": ProvisioningStateSuspended, - "systemmaintenance": ProvisioningStateSystemMaintenance, - "updating": ProvisioningStateUpdating, - "verifying": ProvisioningStateVerifying, - "warned": ProvisioningStateWarned, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := ProvisioningState(input) - return &out, nil -} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/workspaces/id_workspace.go b/internal/services/healthcare/sdk/2021-06-01-preview/workspaces/id_workspace.go deleted file mode 100644 index fbf5773dda06..000000000000 --- a/internal/services/healthcare/sdk/2021-06-01-preview/workspaces/id_workspace.go +++ /dev/null @@ -1,124 +0,0 @@ -package workspaces - -import ( - "fmt" - "strings" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -var _ resourceids.ResourceId = WorkspaceId{} - -// WorkspaceId is a struct representing the Resource ID for a Workspace -type WorkspaceId struct { - SubscriptionId string - ResourceGroupName string - WorkspaceName string -} - -// NewWorkspaceID returns a new WorkspaceId struct -func NewWorkspaceID(subscriptionId string, resourceGroupName string, workspaceName string) WorkspaceId { - return WorkspaceId{ - SubscriptionId: subscriptionId, - ResourceGroupName: resourceGroupName, - WorkspaceName: workspaceName, - } -} - -// ParseWorkspaceID parses 'input' into a WorkspaceId -func ParseWorkspaceID(input string) (*WorkspaceId, error) { - parser := resourceids.NewParserFromResourceIdType(WorkspaceId{}) - parsed, err := parser.Parse(input, false) - if err != nil { - return nil, fmt.Errorf("parsing %q: %+v", input, err) - } - - var ok bool - id := WorkspaceId{} - - if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { - return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) - } - - if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { - return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) - } - - if id.WorkspaceName, ok = parsed.Parsed["workspaceName"]; !ok { - return nil, fmt.Errorf("the segment 'workspaceName' was not found in the resource id %q", input) - } - - return &id, nil -} - -// ParseWorkspaceIDInsensitively parses 'input' case-insensitively into a WorkspaceId -// note: this method should only be used for API response data and not user input -func ParseWorkspaceIDInsensitively(input string) (*WorkspaceId, error) { - parser := resourceids.NewParserFromResourceIdType(WorkspaceId{}) - parsed, err := parser.Parse(input, true) - if err != nil { - return nil, fmt.Errorf("parsing %q: %+v", input, err) - } - - var ok bool - id := WorkspaceId{} - - if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { - return nil, fmt.Errorf("the segment 'subscriptionId' was not found in the resource id %q", input) - } - - if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { - return nil, fmt.Errorf("the segment 'resourceGroupName' was not found in the resource id %q", input) - } - - if id.WorkspaceName, ok = parsed.Parsed["workspaceName"]; !ok { - return nil, fmt.Errorf("the segment 'workspaceName' was not found in the resource id %q", input) - } - - return &id, nil -} - -// ValidateWorkspaceID checks that 'input' can be parsed as a Workspace ID -func ValidateWorkspaceID(input interface{}, key string) (warnings []string, errors []error) { - v, ok := input.(string) - if !ok { - errors = append(errors, fmt.Errorf("expected %q to be a string", key)) - return - } - - if _, err := ParseWorkspaceID(v); err != nil { - errors = append(errors, err) - } - - return -} - -// ID returns the formatted Workspace ID -func (id WorkspaceId) ID() string { - fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.HealthcareApis/workspaces/%s" - return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.WorkspaceName) -} - -// Segments returns a slice of Resource ID Segments which comprise this Workspace ID -func (id WorkspaceId) Segments() []resourceids.Segment { - return []resourceids.Segment{ - resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), - resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), - resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), - resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), - resourceids.StaticSegment("staticProviders", "providers", "providers"), - resourceids.ResourceProviderSegment("staticMicrosoftHealthcareApis", "Microsoft.HealthcareApis", "Microsoft.HealthcareApis"), - resourceids.StaticSegment("staticWorkspaces", "workspaces", "workspaces"), - resourceids.UserSpecifiedSegment("workspaceName", "workspaceValue"), - } -} - -// String returns a human-readable description of this Workspace ID -func (id WorkspaceId) String() string { - components := []string{ - fmt.Sprintf("Subscription: %q", id.SubscriptionId), - fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), - fmt.Sprintf("Workspace Name: %q", id.WorkspaceName), - } - return fmt.Sprintf("Workspace (%s)", strings.Join(components, "\n")) -} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/workspaces/id_workspace_test.go b/internal/services/healthcare/sdk/2021-06-01-preview/workspaces/id_workspace_test.go deleted file mode 100644 index 892b4435322e..000000000000 --- a/internal/services/healthcare/sdk/2021-06-01-preview/workspaces/id_workspace_test.go +++ /dev/null @@ -1,279 +0,0 @@ -package workspaces - -import ( - "testing" - - "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" -) - -var _ resourceids.ResourceId = WorkspaceId{} - -func TestNewWorkspaceID(t *testing.T) { - id := NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceValue") - - if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { - t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") - } - - if id.ResourceGroupName != "example-resource-group" { - t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") - } - - if id.WorkspaceName != "workspaceValue" { - t.Fatalf("Expected %q but got %q for Segment 'WorkspaceName'", id.WorkspaceName, "workspaceValue") - } -} - -func TestFormatWorkspaceID(t *testing.T) { - actual := NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceValue").ID() - expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/workspaces/workspaceValue" - if actual != expected { - t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) - } -} - -func TestParseWorkspaceID(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *WorkspaceId - }{ - { - // Incomplete URI - Input: "", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/workspaces", - Error: true, - }, - { - // Valid URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/workspaces/workspaceValue", - Expected: &WorkspaceId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "example-resource-group", - WorkspaceName: "workspaceValue", - }, - }, - { - // Invalid (Valid Uri with Extra segment) - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/workspaces/workspaceValue/extra", - Error: true, - }, - } - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := ParseWorkspaceID(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expect a value but got an error: %+v", err) - } - if v.Error { - t.Fatal("Expect an error but didn't get one") - } - - if actual.SubscriptionId != v.Expected.SubscriptionId { - t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) - } - - if actual.ResourceGroupName != v.Expected.ResourceGroupName { - t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) - } - - if actual.WorkspaceName != v.Expected.WorkspaceName { - t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) - } - - } -} - -func TestParseWorkspaceIDInsensitively(t *testing.T) { - testData := []struct { - Input string - Error bool - Expected *WorkspaceId - }{ - { - // Incomplete URI - Input: "", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hEaLtHcArEaPiS", - Error: true, - }, - { - // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/workspaces", - Error: true, - }, - { - // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hEaLtHcArEaPiS/wOrKsPaCeS", - Error: true, - }, - { - // Valid URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/workspaces/workspaceValue", - Expected: &WorkspaceId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "example-resource-group", - WorkspaceName: "workspaceValue", - }, - }, - { - // Invalid (Valid Uri with Extra segment) - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HealthcareApis/workspaces/workspaceValue/extra", - Error: true, - }, - { - // Valid URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hEaLtHcArEaPiS/wOrKsPaCeS/wOrKsPaCeVaLuE", - Expected: &WorkspaceId{ - SubscriptionId: "12345678-1234-9876-4563-123456789012", - ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", - WorkspaceName: "wOrKsPaCeVaLuE", - }, - }, - { - // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hEaLtHcArEaPiS/wOrKsPaCeS/wOrKsPaCeVaLuE/extra", - Error: true, - }, - } - for _, v := range testData { - t.Logf("[DEBUG] Testing %q", v.Input) - - actual, err := ParseWorkspaceIDInsensitively(v.Input) - if err != nil { - if v.Error { - continue - } - - t.Fatalf("Expect a value but got an error: %+v", err) - } - if v.Error { - t.Fatal("Expect an error but didn't get one") - } - - if actual.SubscriptionId != v.Expected.SubscriptionId { - t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) - } - - if actual.ResourceGroupName != v.Expected.ResourceGroupName { - t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) - } - - if actual.WorkspaceName != v.Expected.WorkspaceName { - t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) - } - - } -} - -func TestSegmentsForWorkspaceId(t *testing.T) { - segments := WorkspaceId{}.Segments() - if len(segments) == 0 { - t.Fatalf("WorkspaceId has no segments") - } - - uniqueNames := make(map[string]struct{}, 0) - for _, segment := range segments { - uniqueNames[segment.Name] = struct{}{} - } - if len(uniqueNames) != len(segments) { - t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) - } -} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/workspaces/method_createorupdate_autorest.go b/internal/services/healthcare/sdk/2021-06-01-preview/workspaces/method_createorupdate_autorest.go deleted file mode 100644 index d354068f8614..000000000000 --- a/internal/services/healthcare/sdk/2021-06-01-preview/workspaces/method_createorupdate_autorest.go +++ /dev/null @@ -1,75 +0,0 @@ -package workspaces - -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" -) - -type CreateOrUpdateResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// CreateOrUpdate ... -func (c WorkspacesClient) CreateOrUpdate(ctx context.Context, id WorkspaceId, input Workspace) (result CreateOrUpdateResponse, err error) { - req, err := c.preparerForCreateOrUpdate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "workspaces.WorkspacesClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result, err = c.senderForCreateOrUpdate(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "workspaces.WorkspacesClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed -func (c WorkspacesClient) CreateOrUpdateThenPoll(ctx context.Context, id WorkspaceId, input Workspace) 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 WorkspacesClient) preparerForCreateOrUpdate(ctx context.Context, id WorkspaceId, input Workspace) (*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 WorkspacesClient) senderForCreateOrUpdate(ctx context.Context, req *http.Request) (future CreateOrUpdateResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - future.Poller, err = polling.NewLongRunningPollerFromResponse(ctx, resp, c.Client) - return -} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/workspaces/method_delete_autorest.go b/internal/services/healthcare/sdk/2021-06-01-preview/workspaces/method_delete_autorest.go deleted file mode 100644 index c6053b007c77..000000000000 --- a/internal/services/healthcare/sdk/2021-06-01-preview/workspaces/method_delete_autorest.go +++ /dev/null @@ -1,74 +0,0 @@ -package workspaces - -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" -) - -type DeleteResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// Delete ... -func (c WorkspacesClient) Delete(ctx context.Context, id WorkspaceId) (result DeleteResponse, err error) { - req, err := c.preparerForDelete(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "workspaces.WorkspacesClient", "Delete", nil, "Failure preparing request") - return - } - - result, err = c.senderForDelete(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "workspaces.WorkspacesClient", "Delete", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// DeleteThenPoll performs Delete then polls until it's completed -func (c WorkspacesClient) DeleteThenPoll(ctx context.Context, id WorkspaceId) 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 WorkspacesClient) preparerForDelete(ctx context.Context, id WorkspaceId) (*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 WorkspacesClient) senderForDelete(ctx context.Context, req *http.Request) (future DeleteResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - future.Poller, err = polling.NewLongRunningPollerFromResponse(ctx, resp, c.Client) - return -} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/workspaces/method_get_autorest.go b/internal/services/healthcare/sdk/2021-06-01-preview/workspaces/method_get_autorest.go deleted file mode 100644 index 2402fbbfb144..000000000000 --- a/internal/services/healthcare/sdk/2021-06-01-preview/workspaces/method_get_autorest.go +++ /dev/null @@ -1,64 +0,0 @@ -package workspaces - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -type GetResponse struct { - HttpResponse *http.Response - Model *Workspace -} - -// Get ... -func (c WorkspacesClient) Get(ctx context.Context, id WorkspaceId) (result GetResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "workspaces.WorkspacesClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "workspaces.WorkspacesClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "workspaces.WorkspacesClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c WorkspacesClient) preparerForGet(ctx context.Context, id WorkspaceId) (*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 WorkspacesClient) responderForGet(resp *http.Response) (result GetResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - return -} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/workspaces/method_listbyresourcegroup_autorest.go b/internal/services/healthcare/sdk/2021-06-01-preview/workspaces/method_listbyresourcegroup_autorest.go deleted file mode 100644 index 1ae247c0aa96..000000000000 --- a/internal/services/healthcare/sdk/2021-06-01-preview/workspaces/method_listbyresourcegroup_autorest.go +++ /dev/null @@ -1,184 +0,0 @@ -package workspaces - -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" -) - -type ListByResourceGroupResponse struct { - HttpResponse *http.Response - Model *[]Workspace - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListByResourceGroupResponse, error) -} - -type ListByResourceGroupCompleteResult struct { - Items []Workspace -} - -func (r ListByResourceGroupResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListByResourceGroupResponse) LoadMore(ctx context.Context) (resp ListByResourceGroupResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListByResourceGroup ... -func (c WorkspacesClient) ListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (resp ListByResourceGroupResponse, err error) { - req, err := c.preparerForListByResourceGroup(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "workspaces.WorkspacesClient", "ListByResourceGroup", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "workspaces.WorkspacesClient", "ListByResourceGroup", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListByResourceGroup(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "workspaces.WorkspacesClient", "ListByResourceGroup", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// ListByResourceGroupComplete retrieves all of the results into a single object -func (c WorkspacesClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (ListByResourceGroupCompleteResult, error) { - return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, WorkspacePredicate{}) -} - -// ListByResourceGroupCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c WorkspacesClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate WorkspacePredicate) (resp ListByResourceGroupCompleteResult, err error) { - items := make([]Workspace, 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 -} - -// preparerForListByResourceGroup prepares the ListByResourceGroup request. -func (c WorkspacesClient) 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.HealthcareApis/workspaces", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListByResourceGroupWithNextLink prepares the ListByResourceGroup request with the given nextLink token. -func (c WorkspacesClient) 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 WorkspacesClient) responderForListByResourceGroup(resp *http.Response) (result ListByResourceGroupResponse, err error) { - type page struct { - Values []Workspace `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 ListByResourceGroupResponse, err error) { - req, err := c.preparerForListByResourceGroupWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "workspaces.WorkspacesClient", "ListByResourceGroup", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "workspaces.WorkspacesClient", "ListByResourceGroup", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByResourceGroup(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "workspaces.WorkspacesClient", "ListByResourceGroup", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/workspaces/method_listbysubscription_autorest.go b/internal/services/healthcare/sdk/2021-06-01-preview/workspaces/method_listbysubscription_autorest.go deleted file mode 100644 index 0c5834156c71..000000000000 --- a/internal/services/healthcare/sdk/2021-06-01-preview/workspaces/method_listbysubscription_autorest.go +++ /dev/null @@ -1,184 +0,0 @@ -package workspaces - -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" -) - -type ListBySubscriptionResponse struct { - HttpResponse *http.Response - Model *[]Workspace - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListBySubscriptionResponse, error) -} - -type ListBySubscriptionCompleteResult struct { - Items []Workspace -} - -func (r ListBySubscriptionResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListBySubscriptionResponse) LoadMore(ctx context.Context) (resp ListBySubscriptionResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListBySubscription ... -func (c WorkspacesClient) ListBySubscription(ctx context.Context, id commonids.SubscriptionId) (resp ListBySubscriptionResponse, err error) { - req, err := c.preparerForListBySubscription(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "workspaces.WorkspacesClient", "ListBySubscription", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "workspaces.WorkspacesClient", "ListBySubscription", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListBySubscription(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "workspaces.WorkspacesClient", "ListBySubscription", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// ListBySubscriptionComplete retrieves all of the results into a single object -func (c WorkspacesClient) ListBySubscriptionComplete(ctx context.Context, id commonids.SubscriptionId) (ListBySubscriptionCompleteResult, error) { - return c.ListBySubscriptionCompleteMatchingPredicate(ctx, id, WorkspacePredicate{}) -} - -// ListBySubscriptionCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c WorkspacesClient) ListBySubscriptionCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate WorkspacePredicate) (resp ListBySubscriptionCompleteResult, err error) { - items := make([]Workspace, 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 -} - -// preparerForListBySubscription prepares the ListBySubscription request. -func (c WorkspacesClient) 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.HealthcareApis/workspaces", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListBySubscriptionWithNextLink prepares the ListBySubscription request with the given nextLink token. -func (c WorkspacesClient) 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 WorkspacesClient) responderForListBySubscription(resp *http.Response) (result ListBySubscriptionResponse, err error) { - type page struct { - Values []Workspace `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 ListBySubscriptionResponse, err error) { - req, err := c.preparerForListBySubscriptionWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "workspaces.WorkspacesClient", "ListBySubscription", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "workspaces.WorkspacesClient", "ListBySubscription", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListBySubscription(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "workspaces.WorkspacesClient", "ListBySubscription", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/workspaces/method_update_autorest.go b/internal/services/healthcare/sdk/2021-06-01-preview/workspaces/method_update_autorest.go deleted file mode 100644 index d60952d2207d..000000000000 --- a/internal/services/healthcare/sdk/2021-06-01-preview/workspaces/method_update_autorest.go +++ /dev/null @@ -1,75 +0,0 @@ -package workspaces - -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" -) - -type UpdateResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// Update ... -func (c WorkspacesClient) Update(ctx context.Context, id WorkspaceId, input ResourceTags) (result UpdateResponse, err error) { - req, err := c.preparerForUpdate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "workspaces.WorkspacesClient", "Update", nil, "Failure preparing request") - return - } - - result, err = c.senderForUpdate(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "workspaces.WorkspacesClient", "Update", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// UpdateThenPoll performs Update then polls until it's completed -func (c WorkspacesClient) UpdateThenPoll(ctx context.Context, id WorkspaceId, input ResourceTags) 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 WorkspacesClient) preparerForUpdate(ctx context.Context, id WorkspaceId, input ResourceTags) (*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 WorkspacesClient) senderForUpdate(ctx context.Context, req *http.Request) (future UpdateResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - future.Poller, err = polling.NewLongRunningPollerFromResponse(ctx, resp, c.Client) - return -} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/workspaces/model_resourcetags.go b/internal/services/healthcare/sdk/2021-06-01-preview/workspaces/model_resourcetags.go deleted file mode 100644 index 550bf57173a5..000000000000 --- a/internal/services/healthcare/sdk/2021-06-01-preview/workspaces/model_resourcetags.go +++ /dev/null @@ -1,5 +0,0 @@ -package workspaces - -type ResourceTags struct { - Tags *map[string]string `json:"tags,omitempty"` -} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/workspaces/model_systemdata.go b/internal/services/healthcare/sdk/2021-06-01-preview/workspaces/model_systemdata.go deleted file mode 100644 index c7da0009ca71..000000000000 --- a/internal/services/healthcare/sdk/2021-06-01-preview/workspaces/model_systemdata.go +++ /dev/null @@ -1,40 +0,0 @@ -package workspaces - -import ( - "time" - - "github.com/hashicorp/go-azure-helpers/lang/dates" -) - -type SystemData struct { - CreatedAt *string `json:"createdAt,omitempty"` - CreatedBy *string `json:"createdBy,omitempty"` - CreatedByType *CreatedByType `json:"createdByType,omitempty"` - LastModifiedAt *string `json:"lastModifiedAt,omitempty"` - LastModifiedBy *string `json:"lastModifiedBy,omitempty"` - LastModifiedByType *CreatedByType `json:"lastModifiedByType,omitempty"` -} - -func (o SystemData) GetCreatedAtAsTime() (*time.Time, error) { - if o.CreatedAt == nil { - return nil, nil - } - return dates.ParseAsFormat(o.CreatedAt, "2006-01-02T15:04:05Z07:00") -} - -func (o SystemData) SetCreatedAtAsTime(input time.Time) { - formatted := input.Format("2006-01-02T15:04:05Z07:00") - o.CreatedAt = &formatted -} - -func (o SystemData) GetLastModifiedAtAsTime() (*time.Time, error) { - if o.LastModifiedAt == nil { - return nil, nil - } - return dates.ParseAsFormat(o.LastModifiedAt, "2006-01-02T15:04:05Z07:00") -} - -func (o SystemData) SetLastModifiedAtAsTime(input time.Time) { - formatted := input.Format("2006-01-02T15:04:05Z07:00") - o.LastModifiedAt = &formatted -} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/workspaces/model_workspace.go b/internal/services/healthcare/sdk/2021-06-01-preview/workspaces/model_workspace.go deleted file mode 100644 index 940ed6e98599..000000000000 --- a/internal/services/healthcare/sdk/2021-06-01-preview/workspaces/model_workspace.go +++ /dev/null @@ -1,12 +0,0 @@ -package workspaces - -type Workspace struct { - Etag *string `json:"etag,omitempty"` - Id *string `json:"id,omitempty"` - Location *string `json:"location,omitempty"` - Name *string `json:"name,omitempty"` - Properties *WorkspaceProperties `json:"properties,omitempty"` - SystemData *SystemData `json:"systemData,omitempty"` - Tags *map[string]string `json:"tags,omitempty"` - Type *string `json:"type,omitempty"` -} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/workspaces/model_workspaceproperties.go b/internal/services/healthcare/sdk/2021-06-01-preview/workspaces/model_workspaceproperties.go deleted file mode 100644 index ed0d90894d8e..000000000000 --- a/internal/services/healthcare/sdk/2021-06-01-preview/workspaces/model_workspaceproperties.go +++ /dev/null @@ -1,5 +0,0 @@ -package workspaces - -type WorkspaceProperties struct { - ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` -} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/workspaces/predicates.go b/internal/services/healthcare/sdk/2021-06-01-preview/workspaces/predicates.go deleted file mode 100644 index 50ea8247215e..000000000000 --- a/internal/services/healthcare/sdk/2021-06-01-preview/workspaces/predicates.go +++ /dev/null @@ -1,34 +0,0 @@ -package workspaces - -type WorkspacePredicate struct { - Etag *string - Id *string - Location *string - Name *string - Type *string -} - -func (p WorkspacePredicate) Matches(input Workspace) bool { - - if p.Etag != nil && (input.Etag == nil && *p.Etag != *input.Etag) { - return false - } - - if p.Id != nil && (input.Id == nil && *p.Id != *input.Id) { - return false - } - - if p.Location != nil && (input.Location == nil && *p.Location != *input.Location) { - return false - } - - if p.Name != nil && (input.Name == nil && *p.Name != *input.Name) { - return false - } - - if p.Type != nil && (input.Type == nil && *p.Type != *input.Type) { - return false - } - - return true -} diff --git a/internal/services/healthcare/sdk/2021-06-01-preview/workspaces/version.go b/internal/services/healthcare/sdk/2021-06-01-preview/workspaces/version.go deleted file mode 100644 index 8029fe6f0a14..000000000000 --- a/internal/services/healthcare/sdk/2021-06-01-preview/workspaces/version.go +++ /dev/null @@ -1,9 +0,0 @@ -package workspaces - -import "fmt" - -const defaultApiVersion = "2021-06-01-preview" - -func userAgent() string { - return fmt.Sprintf("pandora/workspaces/%s", defaultApiVersion) -} From f26bd8da456c0f072272472d93f20b0e7b6951be Mon Sep 17 00:00:00 2001 From: xiaxin18 Date: Mon, 21 Mar 2022 19:20:16 +0800 Subject: [PATCH 17/22] for acctest --- .../healthcare_dicom_resource_test.go | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/internal/services/healthcare/healthcare_dicom_resource_test.go b/internal/services/healthcare/healthcare_dicom_resource_test.go index 31411acc3ade..6f10493e33a1 100644 --- a/internal/services/healthcare/healthcare_dicom_resource_test.go +++ b/internal/services/healthcare/healthcare_dicom_resource_test.go @@ -118,10 +118,10 @@ func (r HealthCareDicomResource) basic(data acceptance.TestData) string { resource "azurerm_healthcare_dicom_service" "test" { name = "dicom%d" workspace_id = azurerm_healthcare_workspace.test.id - location = "%s" + location = "east us" depends_on = [azurerm_healthcare_workspace.test] } -`, r.template(data), data.RandomIntOfLength(8), data.Locations.Primary) +`, r.template(data), data.RandomIntOfLength(8)) } func (r HealthCareDicomResource) complete(data acceptance.TestData) string { @@ -131,7 +131,7 @@ func (r HealthCareDicomResource) complete(data acceptance.TestData) string { resource "azurerm_healthcare_dicom_service" "test" { name = "dicom%d" workspace_id = azurerm_healthcare_workspace.test.id - location = "%s" + location = "east us" identity { type = "SystemAssigned" @@ -142,7 +142,7 @@ resource "azurerm_healthcare_dicom_service" "test" { } depends_on = [azurerm_healthcare_workspace.test] } -`, r.template(data), data.RandomIntOfLength(8), data.Locations.Primary) +`, r.template(data), data.RandomIntOfLength(8)) } func (r HealthCareDicomResource) update(data acceptance.TestData) string { @@ -152,14 +152,14 @@ func (r HealthCareDicomResource) update(data acceptance.TestData) string { resource "azurerm_healthcare_dicom_service" "test" { name = "dicom%d" workspace_id = azurerm_healthcare_workspace.test.id - location = "%s" + location = "east us" tags = { environment = "Prod" } depends_on = [azurerm_healthcare_workspace.test] } -`, r.template(data), data.RandomIntOfLength(8), data.Locations.Primary) +`, r.template(data), data.RandomIntOfLength(8)) } func (r HealthCareDicomResource) userAssignedIdentity(data acceptance.TestData) string { @@ -175,7 +175,7 @@ resource "azurerm_user_assigned_identity" "test" { resource "azurerm_healthcare_dicom_service" "test" { name = "dicom%d" workspace_id = azurerm_healthcare_workspace.test.id - location = "%s" + location = "east us" identity { type = "UserAssigned" @@ -187,7 +187,7 @@ resource "azurerm_healthcare_dicom_service" "test" { } depends_on = [azurerm_healthcare_workspace.test, azurerm_user_assigned_identity.test] } -`, r.template(data), data.RandomInteger, data.RandomIntOfLength(8), data.Locations.Primary) +`, r.template(data), data.RandomInteger, data.RandomIntOfLength(8)) } func (r HealthCareDicomResource) requiresImport(data acceptance.TestData) string { @@ -209,7 +209,7 @@ provider "azurerm" { resource "azurerm_resource_group" "test" { name = "acctestRG-dicom-%d" - location = "%s" + location = "east us" } resource "azurerm_healthcare_workspace" "test" { @@ -217,5 +217,5 @@ resource "azurerm_healthcare_workspace" "test" { resource_group_name = azurerm_resource_group.test.name location = azurerm_resource_group.test.location } -`, data.RandomInteger, data.Locations.Primary, data.RandomIntOfLength(8)) +`, data.RandomInteger, data.RandomIntOfLength(8)) } From 03eb7e763af7ed037b446ee17dacfaeb8d25b735 Mon Sep 17 00:00:00 2001 From: xiaxin18 Date: Mon, 21 Mar 2022 23:10:24 +0800 Subject: [PATCH 18/22] update --- .../healthcare_dicom_resource_test.go | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/internal/services/healthcare/healthcare_dicom_resource_test.go b/internal/services/healthcare/healthcare_dicom_resource_test.go index 6f10493e33a1..2c7b58bef31f 100644 --- a/internal/services/healthcare/healthcare_dicom_resource_test.go +++ b/internal/services/healthcare/healthcare_dicom_resource_test.go @@ -118,10 +118,10 @@ func (r HealthCareDicomResource) basic(data acceptance.TestData) string { resource "azurerm_healthcare_dicom_service" "test" { name = "dicom%d" workspace_id = azurerm_healthcare_workspace.test.id - location = "east us" + location = "%s" depends_on = [azurerm_healthcare_workspace.test] } -`, r.template(data), data.RandomIntOfLength(8)) +`, r.template(data), data.RandomIntOfLength(10), data.Locations.Primary) } func (r HealthCareDicomResource) complete(data acceptance.TestData) string { @@ -131,7 +131,7 @@ func (r HealthCareDicomResource) complete(data acceptance.TestData) string { resource "azurerm_healthcare_dicom_service" "test" { name = "dicom%d" workspace_id = azurerm_healthcare_workspace.test.id - location = "east us" + location = "%s" identity { type = "SystemAssigned" @@ -142,7 +142,7 @@ resource "azurerm_healthcare_dicom_service" "test" { } depends_on = [azurerm_healthcare_workspace.test] } -`, r.template(data), data.RandomIntOfLength(8)) +`, r.template(data), data.RandomIntOfLength(10), data.Locations.Primary) } func (r HealthCareDicomResource) update(data acceptance.TestData) string { @@ -152,14 +152,14 @@ func (r HealthCareDicomResource) update(data acceptance.TestData) string { resource "azurerm_healthcare_dicom_service" "test" { name = "dicom%d" workspace_id = azurerm_healthcare_workspace.test.id - location = "east us" + location = "%s" tags = { environment = "Prod" } depends_on = [azurerm_healthcare_workspace.test] } -`, r.template(data), data.RandomIntOfLength(8)) +`, r.template(data), data.RandomIntOfLength(10), data.Locations.Primary) } func (r HealthCareDicomResource) userAssignedIdentity(data acceptance.TestData) string { @@ -175,7 +175,7 @@ resource "azurerm_user_assigned_identity" "test" { resource "azurerm_healthcare_dicom_service" "test" { name = "dicom%d" workspace_id = azurerm_healthcare_workspace.test.id - location = "east us" + location = "%s" identity { type = "UserAssigned" @@ -187,7 +187,7 @@ resource "azurerm_healthcare_dicom_service" "test" { } depends_on = [azurerm_healthcare_workspace.test, azurerm_user_assigned_identity.test] } -`, r.template(data), data.RandomInteger, data.RandomIntOfLength(8)) +`, r.template(data), data.RandomInteger, data.RandomIntOfLength(10), data.Locations.Primary) } func (r HealthCareDicomResource) requiresImport(data acceptance.TestData) string { @@ -209,7 +209,7 @@ provider "azurerm" { resource "azurerm_resource_group" "test" { name = "acctestRG-dicom-%d" - location = "east us" + location = "%s" } resource "azurerm_healthcare_workspace" "test" { @@ -217,5 +217,5 @@ resource "azurerm_healthcare_workspace" "test" { resource_group_name = azurerm_resource_group.test.name location = azurerm_resource_group.test.location } -`, data.RandomInteger, data.RandomIntOfLength(8)) +`, data.RandomInteger, data.Locations.Primary, data.RandomIntOfLength(10)) } From f201b353d17dfd6f23613f4b1fa748cb6b8324e6 Mon Sep 17 00:00:00 2001 From: xiaxin18 Date: Tue, 29 Mar 2022 11:14:42 +0800 Subject: [PATCH 19/22] update docs --- website/docs/d/healthcare_dicom.html.markdown | 22 ++++++------- website/docs/r/healthcare_dicom.html.markdown | 32 +++++++++---------- 2 files changed, 27 insertions(+), 27 deletions(-) diff --git a/website/docs/d/healthcare_dicom.html.markdown b/website/docs/d/healthcare_dicom.html.markdown index 16a4757feba3..870218d21c5b 100644 --- a/website/docs/d/healthcare_dicom.html.markdown +++ b/website/docs/d/healthcare_dicom.html.markdown @@ -3,12 +3,12 @@ subcategory: "Healthcare" layout: "azurerm" page_title: "Azure Resource Manager: azurerm_healthcare_dicom_service" description: |- - Get information about an existing Healthcare Dicom Service + Get information about an existing Healthcare DICOM (Digital Imaging and Communications in Medicine) Service --- # Data Source: azurerm_healthcare_dicom_service -Use this data source to access information about an existing Healthcare Dicom Service +Use this data source to access information about an existing Healthcare DICOM Service ## Example Usage @@ -25,26 +25,26 @@ output "azurerm_healthcare_dicom_service" { ## Argument Reference -* `name` - The name of the Healthcare Dicom Service +* `name` - The name of the Healthcare DICOM Service -* `workspace_id` - The name of the Healthcare Workspace in which the Healthcare Dicom Service exists. +* `workspace_id` - The name of the Healthcare Workspace in which the Healthcare DICOM Service exists. ## Attributes Reference The following attributes are exported: -* `id` - The ID of the Healthcare Dicom Service. +* `id` - The ID of the Healthcare DICOM Service. -* `location` - The Azure Region where the Healthcare Dicom Service is located. +* `location` - The Azure Region where the Healthcare DICOM Service is located. -* `authentication_configuration` - The `authentication_configuration` block as defined below. +* `authentication` - The `authentication` block as defined below. -* `service_url` - The url of the Healthcare Dicom Services. +* `service_url` - The url of the Healthcare DICOM Services. -* `tags` - A map of tags assigned to the Healthcare Dicom Service. +* `tags` - A map of tags assigned to the Healthcare DICOM Service. --- -An `authentication_configuration` supports the following: +An `authentication` supports the following: * `authority` - The Azure Active Directory (tenant) that serves as the authentication authority to access the service. The default authority is the Directory defined in the authentication scheme in use when running Terraform. Authority must be registered to Azure AD and in the following format: https://{Azure-AD-endpoint}/{tenant-id}. @@ -55,4 +55,4 @@ An `authentication_configuration` supports the following: The `timeouts` block allows you to specify [timeouts](https://www.terraform.io/docs/configuration/resources.html#timeouts) for certain actions: -* `read` - (Defaults to 5 minutes) Used when retrieving the Healthcare Dicom Service. +* `read` - (Defaults to 5 minutes) Used when retrieving the Healthcare DICOM Service. diff --git a/website/docs/r/healthcare_dicom.html.markdown b/website/docs/r/healthcare_dicom.html.markdown index f5e716ccfd63..c9979c7fadfb 100644 --- a/website/docs/r/healthcare_dicom.html.markdown +++ b/website/docs/r/healthcare_dicom.html.markdown @@ -3,12 +3,12 @@ subcategory: "Healthcare" layout: "azurerm" page_title: "Azure Resource Manager: azurerm_healthcare_dicom_service" description: |- - Manages a Healthcare Dicom Service. + Manages a Healthcare DICOM (Digital Imaging and Communications in Medicine) Service. --- # azurerm_healthcare_dicom_service -Manages a Healthcare Dicom Service +Manages a Healthcare DICOM Service ## Example Usage @@ -38,11 +38,11 @@ resource "azurerm_healthcare_dicom_service" "test" { The following arguments are supported: -* `name` - (Required) Specifies the name of the Healthcare Dicom Service. Changing this forces a new Healthcare Dicom Service to be created. +* `name` - (Required) Specifies the name of the Healthcare DICOM Service. Changing this forces a new Healthcare DICOM Service to be created. -* `workspace_id` - (Required) Specifies the name of the Healthcare Workspace where the Healthcare Dicom Service should exist. Changing this forces a new Healthcare Dicom Service to be created. +* `workspace_id` - (Required) Specifies the name of the Healthcare Workspace where the Healthcare DICOM Service should exist. Changing this forces a new Healthcare DICOM Service to be created. -* `location` - (Required) Specifies the Azure Region where the Healthcare Dicom Service should be created. Changing this forces a new Healthcare Dicom Service to be created. +* `location` - (Required) Specifies the Azure Region where the Healthcare DICOM Service should be created. Changing this forces a new Healthcare DICOM Service to be created. * `identity` - (Optional) An `identity` block as defined below. @@ -52,22 +52,22 @@ The following arguments are supported: An `identity` block supports the following: -* `type` - (Required) The type of identity used for the Healthcare Dicom service. Possible values are `SystemAssigned` and `UserAssigned`. If `UserAssigned` is set, an `identity_ids` must be set as well. +* `type` - (Required) The type of identity used for the Healthcare DICOM service. Possible values are `SystemAssigned` and `UserAssigned`. If `UserAssigned` is set, an `identity_ids` must be set as well. -* `identity_ids` - (Optional) A list of User Assigned Identity IDs which should be assigned to this Healthcare Dicom service. +* `identity_ids` - (Optional) A list of User Assigned Identity IDs which should be assigned to this Healthcare DICOM service. ## Attributes Reference The following attributes are exported: -* `id` - The ID of the Healthcare Dicom Service. +* `id` - The ID of the Healthcare DICOM Service. -* `authentication_configuration` - The `authentication_configuration` block as defined below. +* `authentication` - The `authentication` block as defined below. -* `service_url` - The url of the Healthcare Dicom Services. +* `service_url` - The url of the Healthcare DICOM Services. --- -An `authentication_configuration` supports the following: +An `authentication` supports the following: * `authority` - The Azure Active Directory (tenant) that serves as the authentication authority to access the service. The default authority is the Directory defined in the authentication scheme in use when running Terraform. Authority must be registered to Azure AD and in the following format: https://{Azure-AD-endpoint}/{tenant-id}. @@ -77,14 +77,14 @@ An `authentication_configuration` supports the following: ## Timeouts The `timeouts` block allows you to specify [timeouts](https://www.terraform.io/docs/configuration/resources.html#timeouts) for certain actions: -* `create` - (Defaults to 30 minutes) Used when creating the Healthcare Dicom Service. - * `update` - (Defaults to 30 minutes) Used when updating the Healthcare Dicom Service. - * `read` - (Defaults to 5 minutes) Used when retrieving the Healthcare Dicom Service. - * `delete` - (Defaults to 30 minutes) Used when deleting the Healthcare Dicom Service. +* `create` - (Defaults to 30 minutes) Used when creating the Healthcare DICOM Service. + * `update` - (Defaults to 30 minutes) Used when updating the Healthcare DICOM Service. + * `read` - (Defaults to 5 minutes) Used when retrieving the Healthcare DICOM Service. + * `delete` - (Defaults to 30 minutes) Used when deleting the Healthcare DICOM Service. ## Import -Healthcare Dicom Service can be imported using the resource`id`, e.g. +Healthcare DICOM Service can be imported using the resource`id`, e.g. ```shell terraform import azurerm_healthcare_dicom_service.example /subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/group1/providers/Microsoft.HealthcareApis/workspaces/workspace1/dicomservices/service1 From 8339ad25fd508666e97e60b3d19db052551e2f57 Mon Sep 17 00:00:00 2001 From: xiaxin18 Date: Tue, 29 Mar 2022 13:27:01 +0800 Subject: [PATCH 20/22] update docs --- website/docs/r/service_plan.html.markdown | 1 - 1 file changed, 1 deletion(-) diff --git a/website/docs/r/service_plan.html.markdown b/website/docs/r/service_plan.html.markdown index 859a56d499a4..b82371072afe 100644 --- a/website/docs/r/service_plan.html.markdown +++ b/website/docs/r/service_plan.html.markdown @@ -28,7 +28,6 @@ resource "azurerm_service_plan" "example" { location = "West Europe" os_type = "Linux" sku_name = "P1V2" - os_type = "Windows" } ``` From 9c46bc2ed1414df2b49c34b11102e1741c8906f8 Mon Sep 17 00:00:00 2001 From: xiaxyi Date: Mon, 18 Apr 2022 15:23:35 +0800 Subject: [PATCH 21/22] resolve conflicts --- website/docs/r/service_plan.html.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/docs/r/service_plan.html.markdown b/website/docs/r/service_plan.html.markdown index b82371072afe..01f653c0ff86 100644 --- a/website/docs/r/service_plan.html.markdown +++ b/website/docs/r/service_plan.html.markdown @@ -27,7 +27,7 @@ resource "azurerm_service_plan" "example" { resource_group_name = azurerm_resource_group.example.name location = "West Europe" os_type = "Linux" - sku_name = "P1V2" + sku_name = "P1v2" } ``` From 28c75a38087c10cd8cee5972ff17f06b393d0229 Mon Sep 17 00:00:00 2001 From: kt Date: Mon, 2 May 2022 14:05:18 -0700 Subject: [PATCH 22/22] Update website/docs/r/healthcare_dicom.html.markdown --- website/docs/r/healthcare_dicom.html.markdown | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/website/docs/r/healthcare_dicom.html.markdown b/website/docs/r/healthcare_dicom.html.markdown index c9979c7fadfb..58d7b288464b 100644 --- a/website/docs/r/healthcare_dicom.html.markdown +++ b/website/docs/r/healthcare_dicom.html.markdown @@ -78,9 +78,9 @@ An `authentication` supports the following: The `timeouts` block allows you to specify [timeouts](https://www.terraform.io/docs/configuration/resources.html#timeouts) for certain actions: * `create` - (Defaults to 30 minutes) Used when creating the Healthcare DICOM Service. - * `update` - (Defaults to 30 minutes) Used when updating the Healthcare DICOM Service. - * `read` - (Defaults to 5 minutes) Used when retrieving the Healthcare DICOM Service. - * `delete` - (Defaults to 30 minutes) Used when deleting the Healthcare DICOM Service. +* `update` - (Defaults to 30 minutes) Used when updating the Healthcare DICOM Service. +* `read` - (Defaults to 5 minutes) Used when retrieving the Healthcare DICOM Service. +* `delete` - (Defaults to 30 minutes) Used when deleting the Healthcare DICOM Service. ## Import